You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -14,6 +14,11 @@ RESOURCE_FILES = \
|
||||
resources/Question.wav
|
||||
endif
|
||||
|
||||
RESX_RESOURCE_STRING = \
|
||||
../../../external/corefx/src/System.Collections.Concurrent/src/Resources/Strings.resx \
|
||||
../../../external/corefx/src/System.Collections/src/Resources/Strings.resx \
|
||||
../../../external/corefx/src/System.Buffers/src/Resources/Strings.resx
|
||||
|
||||
TEST_RESOURCES = \
|
||||
Test/System/test-uri-props.txt \
|
||||
Test/System/test-uri-props-manual.txt \
|
||||
|
@@ -1,463 +0,0 @@
|
||||
//
|
||||
// Mono.CSharp CSharpCodeCompiler Class implementation
|
||||
//
|
||||
// Authors:
|
||||
// Sean Kasun (seank@users.sf.net)
|
||||
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||||
//
|
||||
// Copyright (c) Novell, Inc. (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace Mono.CSharp
|
||||
{
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
internal class CSharpCodeCompiler : CSharpCodeGenerator, ICodeCompiler
|
||||
{
|
||||
Mutex mcsOutMutex;
|
||||
StringCollection mcsOutput;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public CSharpCodeCompiler()
|
||||
{
|
||||
}
|
||||
|
||||
public CSharpCodeCompiler (IDictionary <string, string> providerOptions) :
|
||||
base (providerOptions)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
public CompilerResults CompileAssemblyFromDom (CompilerParameters options, CodeCompileUnit e)
|
||||
{
|
||||
return CompileAssemblyFromDomBatch (options, new CodeCompileUnit[] { e });
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
try {
|
||||
return CompileFromDomBatch (options, ea);
|
||||
} finally {
|
||||
options.TempFiles.Delete ();
|
||||
}
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromFile (CompilerParameters options, string fileName)
|
||||
{
|
||||
return CompileAssemblyFromFileBatch (options, new string[] { fileName });
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromFileBatch (CompilerParameters options, string[] fileNames)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
try {
|
||||
return CompileFromFileBatch (options, fileNames);
|
||||
} finally {
|
||||
options.TempFiles.Delete ();
|
||||
}
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromSource (CompilerParameters options, string source)
|
||||
{
|
||||
return CompileAssemblyFromSourceBatch (options, new string[] { source });
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromSourceBatch (CompilerParameters options, string[] sources)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
try {
|
||||
return CompileFromSourceBatch (options, sources);
|
||||
} finally {
|
||||
options.TempFiles.Delete ();
|
||||
}
|
||||
}
|
||||
|
||||
private CompilerResults CompileFromFileBatch (CompilerParameters options, string[] fileNames)
|
||||
{
|
||||
if (null == options)
|
||||
throw new ArgumentNullException("options");
|
||||
if (null == fileNames)
|
||||
throw new ArgumentNullException("fileNames");
|
||||
|
||||
CompilerResults results=new CompilerResults(options.TempFiles);
|
||||
Process mcs=new Process();
|
||||
|
||||
// FIXME: these lines had better be platform independent.
|
||||
if (Path.DirectorySeparatorChar == '\\') {
|
||||
mcs.StartInfo.FileName = MonoToolsLocator.Mono;
|
||||
mcs.StartInfo.Arguments = "\"" + MonoToolsLocator.McsCSharpCompiler + "\" ";
|
||||
} else {
|
||||
mcs.StartInfo.FileName = MonoToolsLocator.McsCSharpCompiler;
|
||||
}
|
||||
|
||||
mcs.StartInfo.Arguments += BuildArgs (options, fileNames, ProviderOptions);
|
||||
|
||||
mcsOutput = new StringCollection ();
|
||||
mcsOutMutex = new Mutex ();
|
||||
/*
|
||||
string monoPath = Environment.GetEnvironmentVariable ("MONO_PATH");
|
||||
if (monoPath != null)
|
||||
monoPath = String.Empty;
|
||||
|
||||
string privateBinPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
|
||||
if (privateBinPath != null && privateBinPath.Length > 0)
|
||||
monoPath = String.Format ("{0}:{1}", privateBinPath, monoPath);
|
||||
|
||||
if (monoPath.Length > 0) {
|
||||
StringDictionary dict = mcs.StartInfo.EnvironmentVariables;
|
||||
if (dict.ContainsKey ("MONO_PATH"))
|
||||
dict ["MONO_PATH"] = monoPath;
|
||||
else
|
||||
dict.Add ("MONO_PATH", monoPath);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* reset MONO_GC_PARAMS - we are invoking compiler possibly with another GC that
|
||||
* may not handle some of the options causing compilation failure
|
||||
*/
|
||||
mcs.StartInfo.EnvironmentVariables ["MONO_GC_PARAMS"] = String.Empty;
|
||||
|
||||
mcs.StartInfo.CreateNoWindow=true;
|
||||
mcs.StartInfo.UseShellExecute=false;
|
||||
mcs.StartInfo.RedirectStandardOutput=true;
|
||||
mcs.StartInfo.RedirectStandardError=true;
|
||||
mcs.ErrorDataReceived += new DataReceivedEventHandler (McsStderrDataReceived);
|
||||
|
||||
// Use same text decoder as mcs and not user set values in Console
|
||||
mcs.StartInfo.StandardOutputEncoding =
|
||||
mcs.StartInfo.StandardErrorEncoding = Encoding.UTF8;
|
||||
|
||||
try {
|
||||
mcs.Start();
|
||||
} catch (Exception e) {
|
||||
Win32Exception exc = e as Win32Exception;
|
||||
if (exc != null) {
|
||||
throw new SystemException (String.Format ("Error running {0}: {1}", mcs.StartInfo.FileName,
|
||||
Win32Exception.GetErrorMessage (exc.NativeErrorCode)));
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
try {
|
||||
mcs.BeginOutputReadLine ();
|
||||
mcs.BeginErrorReadLine ();
|
||||
mcs.WaitForExit();
|
||||
|
||||
results.NativeCompilerReturnValue = mcs.ExitCode;
|
||||
} finally {
|
||||
mcs.CancelErrorRead ();
|
||||
mcs.CancelOutputRead ();
|
||||
mcs.Close();
|
||||
}
|
||||
|
||||
StringCollection sc = mcsOutput;
|
||||
|
||||
bool loadIt=true;
|
||||
foreach (string error_line in mcsOutput) {
|
||||
CompilerError error = CreateErrorFromString (error_line);
|
||||
if (error != null) {
|
||||
results.Errors.Add (error);
|
||||
if (!error.IsWarning)
|
||||
loadIt = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.Count > 0) {
|
||||
sc.Insert (0, mcs.StartInfo.FileName + " " + mcs.StartInfo.Arguments + Environment.NewLine);
|
||||
results.Output = sc;
|
||||
}
|
||||
|
||||
if (loadIt) {
|
||||
if (!File.Exists (options.OutputAssembly)) {
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
foreach (string s in sc)
|
||||
sb.Append (s + Environment.NewLine);
|
||||
|
||||
throw new Exception ("Compiler failed to produce the assembly. Output: '" + sb.ToString () + "'");
|
||||
}
|
||||
|
||||
if (options.GenerateInMemory) {
|
||||
using (FileStream fs = File.OpenRead(options.OutputAssembly)) {
|
||||
byte[] buffer = new byte[fs.Length];
|
||||
fs.Read(buffer, 0, buffer.Length);
|
||||
results.CompiledAssembly = Assembly.Load(buffer, null);
|
||||
fs.Close();
|
||||
}
|
||||
} else {
|
||||
// Avoid setting CompiledAssembly right now since the output might be a netmodule
|
||||
results.PathToAssembly = options.OutputAssembly;
|
||||
}
|
||||
} else {
|
||||
results.CompiledAssembly = null;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
void McsStderrDataReceived (object sender, DataReceivedEventArgs args)
|
||||
{
|
||||
if (args.Data != null) {
|
||||
mcsOutMutex.WaitOne ();
|
||||
mcsOutput.Add (args.Data);
|
||||
mcsOutMutex.ReleaseMutex ();
|
||||
}
|
||||
}
|
||||
|
||||
private static string BuildArgs(CompilerParameters options,string[] fileNames, IDictionary <string, string> providerOptions)
|
||||
{
|
||||
StringBuilder args=new StringBuilder();
|
||||
if (options.GenerateExecutable)
|
||||
args.Append("/target:exe ");
|
||||
else
|
||||
args.Append("/target:library ");
|
||||
|
||||
string privateBinPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
|
||||
if (privateBinPath != null && privateBinPath.Length > 0)
|
||||
args.AppendFormat ("/lib:\"{0}\" ", privateBinPath);
|
||||
|
||||
if (options.Win32Resource != null)
|
||||
args.AppendFormat("/win32res:\"{0}\" ",
|
||||
options.Win32Resource);
|
||||
|
||||
if (options.IncludeDebugInformation)
|
||||
args.Append("/debug+ /optimize- ");
|
||||
else
|
||||
args.Append("/debug- /optimize+ ");
|
||||
|
||||
if (options.TreatWarningsAsErrors)
|
||||
args.Append("/warnaserror ");
|
||||
|
||||
if (options.WarningLevel >= 0)
|
||||
args.AppendFormat ("/warn:{0} ", options.WarningLevel);
|
||||
|
||||
if (options.OutputAssembly == null || options.OutputAssembly.Length == 0) {
|
||||
string extension = (options.GenerateExecutable ? "exe" : "dll");
|
||||
options.OutputAssembly = GetTempFileNameWithExtension (options.TempFiles, extension,
|
||||
!options.GenerateInMemory);
|
||||
}
|
||||
args.AppendFormat("/out:\"{0}\" ",options.OutputAssembly);
|
||||
|
||||
foreach (string import in options.ReferencedAssemblies) {
|
||||
if (import == null || import.Length == 0)
|
||||
continue;
|
||||
|
||||
args.AppendFormat("/r:\"{0}\" ",import);
|
||||
}
|
||||
|
||||
if (options.CompilerOptions != null) {
|
||||
args.Append (options.CompilerOptions);
|
||||
args.Append (" ");
|
||||
}
|
||||
|
||||
foreach (string embeddedResource in options.EmbeddedResources) {
|
||||
args.AppendFormat("/resource:\"{0}\" ", embeddedResource);
|
||||
}
|
||||
|
||||
foreach (string linkedResource in options.LinkedResources) {
|
||||
args.AppendFormat("/linkresource:\"{0}\" ", linkedResource);
|
||||
}
|
||||
|
||||
if (providerOptions != null && providerOptions.Count > 0) {
|
||||
string langver;
|
||||
|
||||
if (!providerOptions.TryGetValue ("CompilerVersion", out langver))
|
||||
langver = "3.5";
|
||||
|
||||
if (langver.Length >= 1 && langver [0] == 'v')
|
||||
langver = langver.Substring (1);
|
||||
|
||||
switch (langver) {
|
||||
case "2.0":
|
||||
args.Append ("/langversion:ISO-2 ");
|
||||
break;
|
||||
|
||||
case "3.5":
|
||||
// current default, omit the switch
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
args.Append ("/noconfig ");
|
||||
|
||||
args.Append (" -- ");
|
||||
foreach (string source in fileNames)
|
||||
args.AppendFormat("\"{0}\" ",source);
|
||||
return args.ToString();
|
||||
}
|
||||
|
||||
// Keep in sync with mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs
|
||||
const string ErrorRegexPattern = @"
|
||||
^
|
||||
(\s*(?<file>[^\(]+) # filename (optional)
|
||||
(\((?<line>\d*)(,(?<column>\d*[\+]*))?\))? # line+column (optional)
|
||||
:\s+)?
|
||||
(?<level>\w+) # error|warning
|
||||
\s+
|
||||
(?<number>[^:]*\d) # CS1234
|
||||
:
|
||||
\s*
|
||||
(?<message>.*)$";
|
||||
|
||||
static readonly Regex RelatedSymbolsRegex = new Regex(
|
||||
@"
|
||||
\(Location\ of\ the\ symbol\ related\ to\ previous\ (warning|error)\)
|
||||
",
|
||||
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
private static CompilerError CreateErrorFromString(string error_string)
|
||||
{
|
||||
if (error_string.StartsWith ("BETA"))
|
||||
return null;
|
||||
|
||||
if (error_string == null || error_string == "")
|
||||
return null;
|
||||
|
||||
CompilerError error=new CompilerError();
|
||||
Regex reg = new Regex (ErrorRegexPattern, RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace);
|
||||
Match match=reg.Match(error_string);
|
||||
if (!match.Success) {
|
||||
match = RelatedSymbolsRegex.Match (error_string);
|
||||
if (!match.Success) {
|
||||
// We had some sort of runtime crash
|
||||
error.ErrorText = error_string;
|
||||
error.IsWarning = false;
|
||||
error.ErrorNumber = "";
|
||||
return error;
|
||||
} else {
|
||||
// This line is a continuation of previous warning of error
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (String.Empty != match.Result("${file}"))
|
||||
error.FileName=match.Result("${file}");
|
||||
if (String.Empty != match.Result("${line}"))
|
||||
error.Line=Int32.Parse(match.Result("${line}"));
|
||||
if (String.Empty != match.Result("${column}"))
|
||||
error.Column=Int32.Parse(match.Result("${column}").Trim('+'));
|
||||
|
||||
string level = match.Result ("${level}");
|
||||
if (level == "warning")
|
||||
error.IsWarning = true;
|
||||
else if (level != "error")
|
||||
return null; // error CS8028 will confuse the regex.
|
||||
|
||||
error.ErrorNumber=match.Result("${number}");
|
||||
error.ErrorText=match.Result("${message}");
|
||||
return error;
|
||||
}
|
||||
|
||||
private static string GetTempFileNameWithExtension (TempFileCollection temp_files, string extension, bool keepFile)
|
||||
{
|
||||
return temp_files.AddExtension (extension, keepFile);
|
||||
}
|
||||
|
||||
private static string GetTempFileNameWithExtension (TempFileCollection temp_files, string extension)
|
||||
{
|
||||
return temp_files.AddExtension (extension);
|
||||
}
|
||||
|
||||
private CompilerResults CompileFromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
if (ea == null) {
|
||||
throw new ArgumentNullException ("ea");
|
||||
}
|
||||
|
||||
string[] fileNames = new string[ea.Length];
|
||||
StringCollection assemblies = options.ReferencedAssemblies;
|
||||
|
||||
for (int i = 0; i < ea.Length; i++) {
|
||||
CodeCompileUnit compileUnit = ea[i];
|
||||
fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".cs");
|
||||
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
|
||||
StreamWriter s = new StreamWriter (f, Encoding.UTF8);
|
||||
if (compileUnit.ReferencedAssemblies != null) {
|
||||
foreach (string str in compileUnit.ReferencedAssemblies) {
|
||||
if (!assemblies.Contains (str))
|
||||
assemblies.Add (str);
|
||||
}
|
||||
}
|
||||
|
||||
((ICodeGenerator) this).GenerateCodeFromCompileUnit (compileUnit, s, new CodeGeneratorOptions ());
|
||||
s.Close ();
|
||||
f.Close ();
|
||||
}
|
||||
return CompileAssemblyFromFileBatch (options, fileNames);
|
||||
}
|
||||
|
||||
private CompilerResults CompileFromSourceBatch (CompilerParameters options, string[] sources)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
if (sources == null) {
|
||||
throw new ArgumentNullException ("sources");
|
||||
}
|
||||
|
||||
string[] fileNames = new string[sources.Length];
|
||||
|
||||
for (int i = 0; i < sources.Length; i++) {
|
||||
fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".cs");
|
||||
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
|
||||
using (StreamWriter s = new StreamWriter (f, Encoding.UTF8)) {
|
||||
s.Write (sources[i]);
|
||||
s.Close ();
|
||||
}
|
||||
f.Close ();
|
||||
}
|
||||
return CompileFromFileBatch (options, fileNames);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,97 +0,0 @@
|
||||
//
|
||||
// Microsoft.CSharp CSharpCodeProvider Class implementation
|
||||
//
|
||||
// Author:
|
||||
// Daniel Stodden (stodden@in.tum.de)
|
||||
//
|
||||
// (C) 2002 Ximian, Inc.
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Security.Permissions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.CSharp {
|
||||
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
|
||||
public class CSharpCodeProvider : CodeDomProvider {
|
||||
IDictionary <string, string> providerOptions;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public CSharpCodeProvider()
|
||||
{
|
||||
}
|
||||
|
||||
public CSharpCodeProvider (IDictionary <string, string> providerOptions)
|
||||
{
|
||||
this.providerOptions = providerOptions;
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
public override string FileExtension {
|
||||
get {
|
||||
return "cs";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
[Obsolete ("Use CodeDomProvider class")]
|
||||
public override ICodeCompiler CreateCompiler()
|
||||
{
|
||||
if (providerOptions != null && providerOptions.Count > 0)
|
||||
return new Mono.CSharp.CSharpCodeCompiler (providerOptions);
|
||||
return new Mono.CSharp.CSharpCodeCompiler();
|
||||
}
|
||||
|
||||
[Obsolete ("Use CodeDomProvider class")]
|
||||
public override ICodeGenerator CreateGenerator()
|
||||
{
|
||||
if (providerOptions != null && providerOptions.Count > 0)
|
||||
return new Mono.CSharp.CSharpCodeGenerator (providerOptions);
|
||||
return new Mono.CSharp.CSharpCodeGenerator();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override TypeConverter GetConverter (Type type)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override void GenerateCodeFromMember (CodeTypeMember member, TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,345 +0,0 @@
|
||||
//
|
||||
// Microsoft VisualBasic VBCodeCompiler Class implementation
|
||||
//
|
||||
// Authors:
|
||||
// Jochen Wezel (jwezel@compumaster.de)
|
||||
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||||
//
|
||||
// (c) 2003 Jochen Wezel (http://www.compumaster.de)
|
||||
// (c) 2003 Ximian, Inc. (http://www.ximian.com)
|
||||
//
|
||||
// Modifications:
|
||||
// 2003-11-28 JW: create reference to Microsoft.VisualBasic if not explicitly done
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Microsoft.VisualBasic
|
||||
{
|
||||
internal class VBCodeCompiler : VBCodeGenerator, ICodeCompiler
|
||||
{
|
||||
public CompilerResults CompileAssemblyFromDom (CompilerParameters options, CodeCompileUnit e)
|
||||
{
|
||||
return CompileAssemblyFromDomBatch (options, new CodeCompileUnit[] { e });
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
try {
|
||||
return CompileFromDomBatch (options, ea);
|
||||
} finally {
|
||||
options.TempFiles.Delete ();
|
||||
}
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromFile (CompilerParameters options, string fileName)
|
||||
{
|
||||
return CompileAssemblyFromFileBatch (options, new string[] { fileName });
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromFileBatch (CompilerParameters options, string[] fileNames)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
try {
|
||||
return CompileFromFileBatch (options, fileNames);
|
||||
} finally {
|
||||
options.TempFiles.Delete ();
|
||||
}
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromSource (CompilerParameters options, string source)
|
||||
{
|
||||
return CompileAssemblyFromSourceBatch (options, new string[] { source });
|
||||
}
|
||||
|
||||
public CompilerResults CompileAssemblyFromSourceBatch (CompilerParameters options, string[] sources)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
try {
|
||||
return CompileFromSourceBatch (options, sources);
|
||||
} finally {
|
||||
options.TempFiles.Delete ();
|
||||
}
|
||||
}
|
||||
|
||||
static string BuildArgs (CompilerParameters options, string[] fileNames)
|
||||
{
|
||||
StringBuilder args = new StringBuilder ();
|
||||
args.Append ("/quiet ");
|
||||
if (options.GenerateExecutable)
|
||||
args.Append ("/target:exe ");
|
||||
else
|
||||
args.Append ("/target:library ");
|
||||
|
||||
/* Disabled. It causes problems now. -- Gonzalo
|
||||
if (options.IncludeDebugInformation)
|
||||
args.AppendFormat("/debug ");
|
||||
*/
|
||||
|
||||
if (options.TreatWarningsAsErrors)
|
||||
args.Append ("/warnaserror ");
|
||||
|
||||
/* Disabled. vbnc does not support warninglevels.
|
||||
if (options.WarningLevel != -1)
|
||||
args.AppendFormat ("/wlevel:{0} ", options.WarningLevel);
|
||||
*/
|
||||
|
||||
if (options.OutputAssembly == null || options.OutputAssembly.Length == 0) {
|
||||
string ext = (options.GenerateExecutable ? "exe" : "dll");
|
||||
options.OutputAssembly = GetTempFileNameWithExtension (options.TempFiles, ext, !options.GenerateInMemory);
|
||||
}
|
||||
|
||||
args.AppendFormat ("/out:\"{0}\" ", options.OutputAssembly);
|
||||
|
||||
bool Reference2MSVBFound;
|
||||
Reference2MSVBFound = false;
|
||||
if (null != options.ReferencedAssemblies) {
|
||||
foreach (string import in options.ReferencedAssemblies) {
|
||||
if (string.Compare (import, "Microsoft.VisualBasic", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
|
||||
Reference2MSVBFound = true;
|
||||
args.AppendFormat ("/r:\"{0}\" ", import);
|
||||
}
|
||||
}
|
||||
|
||||
// add standard import to Microsoft.VisualBasic if missing
|
||||
if (!Reference2MSVBFound)
|
||||
args.Append ("/r:\"Microsoft.VisualBasic.dll\" ");
|
||||
|
||||
if (options.CompilerOptions != null) {
|
||||
args.Append (options.CompilerOptions);
|
||||
args.Append (" ");
|
||||
}
|
||||
/* Disabled, vbnc does not support this.
|
||||
args.Append (" -- "); // makes vbnc not try to process filenames as options
|
||||
*/
|
||||
foreach (string source in fileNames)
|
||||
args.AppendFormat (" \"{0}\" ", source);
|
||||
|
||||
return args.ToString ();
|
||||
}
|
||||
|
||||
static CompilerError CreateErrorFromString (string error_string)
|
||||
{
|
||||
CompilerError error = new CompilerError ();
|
||||
Regex reg = new Regex (@"^(\s*(?<file>.*)?\((?<line>\d*)(,(?<column>\d*))?\)\s+)?:\s*" +
|
||||
@"(?<level>Error|Warning)?\s*(?<number>.*):\s(?<message>.*)",
|
||||
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
|
||||
|
||||
Match match = reg.Match (error_string);
|
||||
if (!match.Success) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (String.Empty != match.Result ("${file}"))
|
||||
error.FileName = match.Result ("${file}").Trim ();
|
||||
|
||||
if (String.Empty != match.Result ("${line}"))
|
||||
error.Line = Int32.Parse (match.Result ("${line}"));
|
||||
|
||||
if (String.Empty != match.Result ("${column}"))
|
||||
error.Column = Int32.Parse (match.Result ("${column}"));
|
||||
|
||||
if (match.Result ("${level}").Trim () == "Warning")
|
||||
error.IsWarning = true;
|
||||
|
||||
error.ErrorNumber = match.Result ("${number}");
|
||||
error.ErrorText = match.Result ("${message}");
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
private static string GetTempFileNameWithExtension (TempFileCollection temp_files, string extension, bool keepFile)
|
||||
{
|
||||
return temp_files.AddExtension (extension, keepFile);
|
||||
}
|
||||
|
||||
private static string GetTempFileNameWithExtension (TempFileCollection temp_files, string extension)
|
||||
{
|
||||
return temp_files.AddExtension (extension);
|
||||
}
|
||||
|
||||
private CompilerResults CompileFromFileBatch (CompilerParameters options, string[] fileNames)
|
||||
{
|
||||
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
if (fileNames == null) {
|
||||
throw new ArgumentNullException ("fileNames");
|
||||
}
|
||||
|
||||
CompilerResults results = new CompilerResults (options.TempFiles);
|
||||
Process vbnc = new Process ();
|
||||
|
||||
string vbnc_output = "";
|
||||
string[] vbnc_output_lines;
|
||||
// FIXME: these lines had better be platform independent.
|
||||
if (Path.DirectorySeparatorChar == '\\') {
|
||||
vbnc.StartInfo.FileName = MonoToolsLocator.Mono;
|
||||
vbnc.StartInfo.Arguments = MonoToolsLocator.VBCompiler + ' ' + BuildArgs (options, fileNames);
|
||||
} else {
|
||||
vbnc.StartInfo.FileName = MonoToolsLocator.VBCompiler;
|
||||
vbnc.StartInfo.Arguments = BuildArgs (options, fileNames);
|
||||
}
|
||||
//Console.WriteLine (vbnc.StartInfo.Arguments);
|
||||
vbnc.StartInfo.CreateNoWindow = true;
|
||||
vbnc.StartInfo.UseShellExecute = false;
|
||||
vbnc.StartInfo.RedirectStandardOutput = true;
|
||||
try {
|
||||
vbnc.Start ();
|
||||
} catch (Exception e) {
|
||||
Win32Exception exc = e as Win32Exception;
|
||||
if (exc != null) {
|
||||
throw new SystemException (String.Format ("Error running {0}: {1}", vbnc.StartInfo.FileName,
|
||||
Win32Exception.GetErrorMessage (exc.NativeErrorCode)));
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
try {
|
||||
vbnc_output = vbnc.StandardOutput.ReadToEnd ();
|
||||
vbnc.WaitForExit ();
|
||||
} finally {
|
||||
results.NativeCompilerReturnValue = vbnc.ExitCode;
|
||||
vbnc.Close ();
|
||||
}
|
||||
|
||||
bool loadIt = true;
|
||||
if (results.NativeCompilerReturnValue == 1) {
|
||||
loadIt = false;
|
||||
vbnc_output_lines = vbnc_output.Split (Environment.NewLine.ToCharArray ());
|
||||
foreach (string error_line in vbnc_output_lines) {
|
||||
CompilerError error = CreateErrorFromString (error_line);
|
||||
if (null != error) {
|
||||
results.Errors.Add (error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((loadIt == false && !results.Errors.HasErrors) // Failed, but no errors? Probably couldn't parse the compiler output correctly.
|
||||
|| (results.NativeCompilerReturnValue != 0 && results.NativeCompilerReturnValue != 1)) // Neither success (0), nor failure (1), so it crashed.
|
||||
{
|
||||
// Show the entire output as one big error message.
|
||||
loadIt = false;
|
||||
CompilerError error = new CompilerError (string.Empty, 0, 0, "VBNC_CRASH", vbnc_output);
|
||||
results.Errors.Add (error);
|
||||
};
|
||||
|
||||
if (loadIt) {
|
||||
if (options.GenerateInMemory) {
|
||||
using (FileStream fs = File.OpenRead (options.OutputAssembly)) {
|
||||
byte[] buffer = new byte[fs.Length];
|
||||
fs.Read (buffer, 0, buffer.Length);
|
||||
results.CompiledAssembly = Assembly.Load (buffer, null);
|
||||
fs.Close ();
|
||||
}
|
||||
} else {
|
||||
results.CompiledAssembly = Assembly.LoadFrom (options.OutputAssembly);
|
||||
results.PathToAssembly = options.OutputAssembly;
|
||||
}
|
||||
} else {
|
||||
results.CompiledAssembly = null;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private CompilerResults CompileFromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
if (ea == null) {
|
||||
throw new ArgumentNullException ("ea");
|
||||
}
|
||||
|
||||
string[] fileNames = new string[ea.Length];
|
||||
StringCollection assemblies = options.ReferencedAssemblies;
|
||||
|
||||
for (int i = 0; i < ea.Length; i++) {
|
||||
CodeCompileUnit compileUnit = ea[i];
|
||||
fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".vb");
|
||||
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
|
||||
StreamWriter s = new StreamWriter (f);
|
||||
if (compileUnit.ReferencedAssemblies != null) {
|
||||
foreach (string str in compileUnit.ReferencedAssemblies) {
|
||||
if (!assemblies.Contains (str))
|
||||
assemblies.Add (str);
|
||||
}
|
||||
}
|
||||
|
||||
((ICodeGenerator) this).GenerateCodeFromCompileUnit (compileUnit, s, new CodeGeneratorOptions ());
|
||||
s.Close ();
|
||||
f.Close ();
|
||||
}
|
||||
return CompileAssemblyFromFileBatch (options, fileNames);
|
||||
}
|
||||
|
||||
private CompilerResults CompileFromSourceBatch (CompilerParameters options, string[] sources)
|
||||
{
|
||||
if (options == null) {
|
||||
throw new ArgumentNullException ("options");
|
||||
}
|
||||
|
||||
if (sources == null) {
|
||||
throw new ArgumentNullException ("sources");
|
||||
}
|
||||
|
||||
string[] fileNames = new string[sources.Length];
|
||||
|
||||
for (int i = 0; i < sources.Length; i++) {
|
||||
fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".vb");
|
||||
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
|
||||
using (StreamWriter s = new StreamWriter (f)) {
|
||||
s.Write (sources[i]);
|
||||
s.Close ();
|
||||
}
|
||||
f.Close ();
|
||||
}
|
||||
return CompileFromFileBatch (options, fileNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,87 +0,0 @@
|
||||
//
|
||||
// Microsoft.VisualBasic.VBCodeProvider.cs
|
||||
//
|
||||
// Author:
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2003 Andreas Nahr
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace Microsoft.VisualBasic {
|
||||
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
|
||||
public class VBCodeProvider : CodeDomProvider {
|
||||
|
||||
public VBCodeProvider()
|
||||
{
|
||||
}
|
||||
|
||||
public VBCodeProvider(System.Collections.Generic.IDictionary<string, string> providerOptions)
|
||||
{
|
||||
// TODO: Do something meaningful here...
|
||||
}
|
||||
|
||||
public override string FileExtension {
|
||||
get {
|
||||
return "vb";
|
||||
}
|
||||
}
|
||||
|
||||
public override LanguageOptions LanguageOptions {
|
||||
get {
|
||||
return LanguageOptions.CaseInsensitive;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete ("Use CodeDomProvider class")]
|
||||
public override ICodeCompiler CreateCompiler()
|
||||
{
|
||||
return new Microsoft.VisualBasic.VBCodeCompiler ();
|
||||
}
|
||||
|
||||
[Obsolete ("Use CodeDomProvider class")]
|
||||
public override ICodeGenerator CreateGenerator()
|
||||
{
|
||||
return new Microsoft.VisualBasic.VBCodeGenerator();
|
||||
}
|
||||
|
||||
public override TypeConverter GetConverter (Type type)
|
||||
{
|
||||
return TypeDescriptor.GetConverter (type);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override void GenerateCodeFromMember (CodeTypeMember member, TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -33,9 +33,8 @@ using Mono.Security.Interface;
|
||||
|
||||
using Mono.Net;
|
||||
using Mono.Net.Security;
|
||||
using Mono.Util;
|
||||
|
||||
using ObjCRuntime;
|
||||
using ObjCRuntimeInternal;
|
||||
|
||||
namespace Mono.AppleTls
|
||||
{
|
||||
@@ -682,7 +681,7 @@ namespace Mono.AppleTls
|
||||
[DllImport (SecurityLibrary)]
|
||||
extern static /* OSStatus */ SslStatus SSLSetIOFuncs (/* SSLContextRef */ IntPtr context, /* SSLReadFunc */ SslReadFunc readFunc, /* SSLWriteFunc */ SslWriteFunc writeFunc);
|
||||
|
||||
[MonoPInvokeCallback (typeof (SslReadFunc))]
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (SslReadFunc))]
|
||||
static SslStatus NativeReadCallback (IntPtr ptr, IntPtr data, ref IntPtr dataLength)
|
||||
{
|
||||
var handle = GCHandle.FromIntPtr (ptr);
|
||||
@@ -702,7 +701,7 @@ namespace Mono.AppleTls
|
||||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SslWriteFunc))]
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (SslWriteFunc))]
|
||||
static SslStatus NativeWriteCallback (IntPtr ptr, IntPtr data, ref IntPtr dataLength)
|
||||
{
|
||||
var handle = GCHandle.FromIntPtr (ptr);
|
||||
|
@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Net;
|
||||
|
||||
using ObjCRuntime;
|
||||
using ObjCRuntimeInternal;
|
||||
|
||||
namespace Mono.AppleTls {
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#if MONO_FEATURE_APPLETLS
|
||||
// Copyright 2011-2015 Xamarin Inc. All rights reserved.
|
||||
|
||||
using ObjCRuntime;
|
||||
using ObjCRuntimeInternal;
|
||||
|
||||
namespace Mono.AppleTls {
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace ObjCRuntime {
|
||||
namespace ObjCRuntimeInternal {
|
||||
|
||||
internal interface INativeObject {
|
||||
IntPtr Handle {
|
||||
|
@@ -31,7 +31,7 @@ using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using ObjCRuntime;
|
||||
using ObjCRuntimeInternal;
|
||||
using Mono.Net;
|
||||
|
||||
#if MONO_FEATURE_BTLS
|
||||
|
@@ -34,7 +34,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
using ObjCRuntime;
|
||||
using ObjCRuntimeInternal;
|
||||
using Mono.Net;
|
||||
|
||||
namespace Mono.AppleTls {
|
||||
|
@@ -30,7 +30,7 @@
|
||||
//
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using ObjCRuntime;
|
||||
using ObjCRuntimeInternal;
|
||||
using Mono.Net;
|
||||
|
||||
namespace Mono.AppleTls {
|
||||
|
@@ -32,7 +32,7 @@ using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using ObjCRuntime;
|
||||
using ObjCRuntimeInternal;
|
||||
using Mono.Net;
|
||||
|
||||
namespace Mono.AppleTls {
|
||||
|
@@ -30,10 +30,6 @@ using System.Text;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if MONOTOUCH
|
||||
using MonoTouch;
|
||||
#endif
|
||||
|
||||
namespace Mono.Btls
|
||||
{
|
||||
class MonoBtlsBio : MonoBtlsObject
|
||||
@@ -308,9 +304,7 @@ namespace Mono.Btls
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if MONOTOUCH
|
||||
[MonoPInvokeCallback (typeof (BioReadFunc))]
|
||||
#endif
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (BioReadFunc))]
|
||||
static int OnRead (IntPtr instance, IntPtr data, int dataLength, out int wantMore)
|
||||
{
|
||||
var c = (MonoBtlsBioMono)GCHandle.FromIntPtr (instance).Target;
|
||||
@@ -331,9 +325,7 @@ namespace Mono.Btls
|
||||
return ok ? dataLength : -1;
|
||||
}
|
||||
|
||||
#if MONOTOUCH
|
||||
[MonoPInvokeCallback (typeof (BioWriteFunc))]
|
||||
#endif
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (BioWriteFunc))]
|
||||
static int OnWrite (IntPtr instance, IntPtr data, int dataLength)
|
||||
{
|
||||
var c = (MonoBtlsBioMono)GCHandle.FromIntPtr (instance).Target;
|
||||
@@ -345,9 +337,7 @@ namespace Mono.Btls
|
||||
}
|
||||
}
|
||||
|
||||
#if MONOTOUCH
|
||||
[MonoPInvokeCallback (typeof (BioControlFunc))]
|
||||
#endif
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (BioControlFunc))]
|
||||
static long Control (IntPtr instance, ControlCommand command, long arg)
|
||||
{
|
||||
var c = (MonoBtlsBioMono)GCHandle.FromIntPtr (instance).Target;
|
||||
|
@@ -203,8 +203,43 @@ namespace Mono.Btls
|
||||
|
||||
internal static void SetupCertificateStore (MonoBtlsX509Store store, MonoTlsSettings settings, bool server)
|
||||
{
|
||||
AddTrustedRoots (store, settings, server);
|
||||
if (settings?.CertificateSearchPaths == null)
|
||||
AddTrustedRoots (store, settings, server);
|
||||
|
||||
#if MONODROID
|
||||
SetupCertificateStore (store);
|
||||
return;
|
||||
#else
|
||||
if (settings?.CertificateSearchPaths == null) {
|
||||
SetupCertificateStore (store);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var path in settings.CertificateSearchPaths) {
|
||||
if (string.Equals (path, "@default", StringComparison.Ordinal)) {
|
||||
AddTrustedRoots (store, settings, server);
|
||||
AddUserStore (store);
|
||||
AddMachineStore (store);
|
||||
} else if (string.Equals (path, "@user", StringComparison.Ordinal))
|
||||
AddUserStore (store);
|
||||
else if (string.Equals (path, "@machine", StringComparison.Ordinal))
|
||||
AddMachineStore (store);
|
||||
else if (string.Equals (path, "@trusted", StringComparison.Ordinal))
|
||||
AddTrustedRoots (store, settings, server);
|
||||
else if (path.StartsWith ("@pem:", StringComparison.Ordinal)) {
|
||||
var realPath = path.Substring (5);
|
||||
if (Directory.Exists (realPath))
|
||||
store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.PEM);
|
||||
} else if (path.StartsWith ("@der:", StringComparison.Ordinal)) {
|
||||
var realPath = path.Substring (5);
|
||||
if (Directory.Exists (realPath))
|
||||
store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.ASN1);
|
||||
} else {
|
||||
if (Directory.Exists (path))
|
||||
store.AddDirectoryLookup (path, MonoBtlsX509FileType.PEM);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void SetupCertificateStore (MonoBtlsX509Store store)
|
||||
|
@@ -30,10 +30,6 @@ using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#if MONOTOUCH
|
||||
using MonoTouch;
|
||||
#endif
|
||||
|
||||
namespace Mono.Btls
|
||||
{
|
||||
delegate int MonoBtlsVerifyCallback (MonoBtlsX509StoreCtx ctx);
|
||||
@@ -250,9 +246,7 @@ namespace Mono.Btls
|
||||
|
||||
delegate int PrintErrorsCallbackFunc (IntPtr str, IntPtr len, IntPtr ctx);
|
||||
|
||||
#if MONOTOUCH
|
||||
[MonoPInvokeCallback (typeof (PrintErrorsCallbackFunc))]
|
||||
#endif
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (PrintErrorsCallbackFunc))]
|
||||
static int PrintErrorsCallback (IntPtr str, IntPtr len, IntPtr ctx)
|
||||
{
|
||||
var sb = (StringBuilder)GCHandle.FromIntPtr (ctx).Target;
|
||||
|
@@ -28,10 +28,6 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if MONOTOUCH
|
||||
using MonoTouch;
|
||||
#endif
|
||||
|
||||
namespace Mono.Btls
|
||||
{
|
||||
class MonoBtlsSslCtx : MonoBtlsObject
|
||||
@@ -141,9 +137,7 @@ namespace Mono.Btls
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if MONOTOUCH
|
||||
[MonoPInvokeCallback (typeof (NativeVerifyFunc))]
|
||||
#endif
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (NativeVerifyFunc))]
|
||||
static int NativeVerifyCallback (IntPtr instance, int preverify_ok, IntPtr store_ctx)
|
||||
{
|
||||
var c = (MonoBtlsSslCtx)GCHandle.FromIntPtr (instance).Target;
|
||||
@@ -164,9 +158,7 @@ namespace Mono.Btls
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if MONOTOUCH
|
||||
[MonoPInvokeCallback (typeof (NativeSelectFunc))]
|
||||
#endif
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (NativeSelectFunc))]
|
||||
static int NativeSelectCallback (IntPtr instance)
|
||||
{
|
||||
var c = (MonoBtlsSslCtx)GCHandle.FromIntPtr (instance).Target;
|
||||
|
@@ -93,9 +93,7 @@ namespace Mono.Btls
|
||||
|
||||
protected abstract MonoBtlsX509 OnGetBySubject (MonoBtlsX509Name name);
|
||||
|
||||
#if MONOTOUCH
|
||||
[MonoTouch.MonoPInvokeCallback (typeof (BySubjectFunc))]
|
||||
#endif
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (BySubjectFunc))]
|
||||
static int OnGetBySubject (IntPtr instance, IntPtr name_ptr, out IntPtr x509_ptr)
|
||||
{
|
||||
try {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user