Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
//
// AssemblyInfo.cs
//
// Author:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Ximian, Inc. http://www.ximian.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.Reflection;
using System.Resources;
using System.Diagnostics;
using System.Runtime.CompilerServices;
#if NET_2_0
using System.Runtime.ConstrainedExecution;
#endif
using System.Runtime.InteropServices;
// General Information about the cscompmgd assembly
[assembly: AssemblyVersion (Consts.VsVersion)]
[assembly: AssemblyFileVersion (Consts.VsFileVersion)]
[assembly: CLSCompliant (true)]
[assembly: ComVisible (false)]
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../msfinal.pub")]
[assembly: AssemblyTitle ("cscompmgd.dll")]
[assembly: AssemblyDefaultAlias ("cscompmgd.dll")]
[assembly: AssemblyDescription ("cscompmgd.dll")]
[assembly: AssemblyCompany (Consts.MonoCompany)]
[assembly: AssemblyProduct (Consts.MonoProduct)]
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
[assembly: SatelliteContractVersion (Consts.VsVersion)]
[assembly: AssemblyInformationalVersion (Consts.VsFileVersion)]
[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: ReliabilityContract (Consistency.MayCorruptProcess, Cer.None)]

View File

@@ -0,0 +1,22 @@
2008-04-25 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* AssemblyInfo.cs: Change to use more constants
2008-04-09 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* AssemblyInfo.cs: Add missing attributes
2005-11-05 Kornél Pál <kornelpal@hotmail.com>
* AssemblyInfo.cs: Use Consts.VsFileVersion as AssemblyFileVersion and
AssemblyInformationalVersion.
2005-08-07 Gert Driesen <drieseng@users.sourceforge.net>
* AssemblyInfo.cs: Fixed attributes to match MS.NET.
2004-04-06 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* AssemblyInfo.cs: Added
* ChangeLog: Added
* Locale.cs: Added

View File

@@ -0,0 +1,16 @@
2004-05-11 Jacskon Harper <jackson@ximian.com>
* Makefile: Specify correct lowercase assembly name.
2004-02-22 Atsushi Enomoto <atsushi@ximian.com>
* Added Cscompmgd_test.dll.sources.
* Makefile: Removed NO_TEST=yes
2003-07-03 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* Cscompmgd.build: Removed unneeded unsafe compiler switch
2002-12-07 Jackson Harper <jackson@latitudegeo.com>
* Cscompmgd.build: Added file

View File

@@ -0,0 +1,7 @@
Assembly/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
Microsoft.CSharp/Compiler.cs
Microsoft.CSharp/CompilerError.cs
Microsoft.CSharp/ErrorLevel.cs
../../build/common/MonoTODOAttribute.cs

View File

@@ -0,0 +1 @@
Microsoft.CSharp/CompilerTest.cs

View File

@@ -0,0 +1,10 @@
thisdir = class/Cscompmgd
SUBDIRS =
include ../../build/rules.make
LIBRARY = Cscompmgd.dll
LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169
LIBRARY_NAME = cscompmgd.dll
include ../../build/library.make

View File

@@ -0,0 +1,83 @@
2006-05-30 Gert Driesen <drieseng@users.sourceforge.net>
* ErrorLevel.cs: Removed extra Serializable attribute in 2.0 profile.
2005-04-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* Compiler.cs: redirect standard error. Patch by Toby Miller that fixes
bug #74067.
2004-12-14 Jackson Harper <jackson@ximian.com>
* Compiler.cs: mcs writes to stderr now. Also read stdout so we do
not block if mcs writes a lot of data to is.
2004-07-02 Jackson Harper <jackson@ximian.com>
* Compiler.cs:
* CompilerError.cs:
* ErrorLevel.cs: Make obsolete in 2.0
2004-05-11 Gert Driesen (drieseng@users.sourceforge.net)
* Compiler.cs: marked ctor private to match MS.NET
2003-02-23 Jackson Harper <jackson@latitudegeo.com>
* CompilerError.cs: Use fields not properties, and remove unneeded finalizer
2002-12-15 Jackson Harper <jackson@latitudegeo.com>
* CompilerError.cs ErrorLevel.cs: Moved ErrorLevel enum into its own file
2002-12-12 Jackson Harper <jackson@latitudegeo.com>
* Compiler.cs: Partially implemented bugreport option, also only allow valid options now
2002-12-07 Jackson Harper <jackson@latitudegeo.com>
* Compiler.cs: Moved StreamWriter creation into a try block
2002-12-07 Jackson Harper <jackson@latitudegeo.com>
* Compiler.cs: Source text is now implemented so you can pass strings of C# code to be compiled
2002-12-07 Jackson Harper <jackson@latitudegeo.com>
* TODOAttribute.cs: Added file
2002-12-07 Jackson Harper <jackson@latitudegeo.com>
* Compiler.cs CompilerError.cs: Moved file
2002-11-11 Jackson Harper <jackson@latitudegeo.com>
* CompilerError.cs: Reordered ErrorLevel enumeration to match MS values
2002-11-11 Jackson Harper <jackson@latitudegeo.com>
* CompilerError.cs: Error levels are now lower case to match MS spec
2002-11-9 Jackson Harper <jackson@latitudegeo.com>
* CompilerError.cs: ToString() Do not show source file info if there was no source file in the error message
2002-11-6 Jackson Harper <jackson@latitudegeo.com>
* Compiler.cs: No longers waits untill mcs is finished running to read output, this should prevent
crashes from buffers filling up.
2002-11-4 Jackson Harper <jackson@latitudegeo.com>
* Compiler.cs CompilerError.cs: Fixed (C) in header
2002-11-4 Jackson Harper <jackson@latitudegeo.com>
* Compiler.cs: Added file
2002-11-4 Jackson Harper <jackson@latitudegeo.com>
* CompilerError.cs: Changed FileName property to the correct name 'SourceFile'
2002-10-30 Jackson Harper <jackson@latitudegeo.com>
* CompilerError.cs: Added class

View File

@@ -0,0 +1,292 @@
// Microsoft.CSharp.Compiler
//
// Author(s):
// Jackson Harper (Jackson@LatitudeGeo.com)
//
// (C) 2002 Jackson Harper, All rights reserved.
//
//
// 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.IO;
using System.Text;
using System.Collections;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Microsoft.CSharp {
#if NET_2_0
[System.Obsolete]
#endif
public class Compiler {
private Compiler()
{
}
[MonoTODO("Have not implemented bugreports")]
public static CompilerError[] Compile(string[] sourceTexts,
string[] sourceTextNames, string target, string[] imports,
IDictionary options)
{
VerifyArgs (sourceTexts, sourceTextNames, target);
string[] temp_cs_files;
CompilerError[] errors;
string bugreport_path = null;
StreamWriter bug_report = null;
temp_cs_files = CreateCsFiles (sourceTexts, sourceTextNames);
if (options != null)
bugreport_path = (string)options["bugreport"];
if (bugreport_path != null) {
bug_report = CreateBugReport (sourceTexts, sourceTextNames, bugreport_path);
}
try {
errors = CompileFiles (temp_cs_files, target, imports, options, bug_report);
} catch {
throw;
} finally {
foreach (string temp_file in temp_cs_files) {
FileInfo file = new FileInfo (temp_file);
file.Delete ();
}
if (bug_report != null)
bug_report.Close ();
}
return errors;
}
//
// Private Methods
//
private static CompilerError[] CompileFiles (string[] cs_files,
string target, string[] imports, IDictionary options, StreamWriter bug_report)
{
ArrayList error_list = new ArrayList ();
Process mcs = new Process ();
string mcs_output;
string[] mcs_output_lines;
mcs.StartInfo.FileName = "mcs";
mcs.StartInfo.Arguments = BuildArgs (cs_files,
target, imports, options);
mcs.StartInfo.CreateNoWindow = true;
mcs.StartInfo.UseShellExecute = false;
mcs.StartInfo.RedirectStandardOutput = true;
mcs.StartInfo.RedirectStandardError = true;
try {
mcs.Start ();
mcs_output = mcs.StandardError.ReadToEnd ();
mcs.StandardOutput.ReadToEnd ();
mcs.WaitForExit ();
} finally {
mcs.Close ();
}
mcs_output_lines = mcs_output.Split (
System.Environment.NewLine.ToCharArray ());
foreach (string error_line in mcs_output_lines) {
CompilerError error = CreateErrorFromString (error_line);
if (null != error)
error_list.Add (error);
}
if (bug_report != null) {
bug_report.WriteLine ("### Compiler Output");
bug_report.Write (mcs_output);
}
return (CompilerError[])error_list.ToArray (typeof(CompilerError));
}
/// <summary>
/// Converts an error string into a CompilerError object
/// Return null if the line was not an error string
/// </summary>
private static CompilerError CreateErrorFromString(string error_string)
{
CompilerError error = new CompilerError();
Regex reg = new Regex (@"^((?<file>.*)\((?<line>\d*)(,(?<column>\d*))?\)\s){0,}(?<level>\w+)\sCS(?<number>\d*):\s(?<message>.*)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
Match match = reg.Match (error_string);
if (!match.Success)
return null;
if (String.Empty != match.Result ("${file}"))
error.SourceFile = match.Result ("${file}");
if (String.Empty != match.Result ("${line}"))
error.SourceLine = Int32.Parse (match.Result ("${line}"));
if (String.Empty != match.Result ("${column}"))
error.SourceColumn = Int32.Parse (match.Result ("${column}"));
error.ErrorLevel = (ErrorLevel)Enum.Parse (typeof(ErrorLevel),
match.Result ("${level}"), true);
error.ErrorNumber = Int32.Parse (match.Result ("${number}"));
error.ErrorMessage = match.Result ("${message}");
return error;
}
private static string[] CreateCsFiles (string[] source_text, string[] source_name)
{
ArrayList temp_file_list = new ArrayList ();
for (int i=0; i<source_text.Length; i++) {
string temp_path = Path.GetTempFileName ();
StreamWriter writer = null;
try {
writer = new StreamWriter (temp_path);
writer.WriteLine (String.Format ("#line 1 \"{0}\"",
source_name[i]));
writer.Write (source_text[i]);
} catch {
} finally {
if (writer != null)
writer.Close ();
}
temp_file_list.Add (temp_path);
}
return (string[])temp_file_list.ToArray (typeof(string));
}
private static string BuildArgs(string[] source_files,
string target, string[] imports, IDictionary options)
{
StringBuilder args = new StringBuilder ();
args.AppendFormat ("/out:{0} ", target);
if (null != imports) {
foreach (string import in imports)
args.AppendFormat ("/r:{0} ", import);
}
if (null != options) {
foreach (object option in options.Keys) {
object value = options[option];
if (!ValidOption ((string)option))
continue;
args.AppendFormat ("{0} ", OptionString (option,value));
}
}
foreach (string source in source_files)
args.AppendFormat ("{0} ", source);
return args.ToString ();
}
private static string OptionString(object option, object value)
{
if (null != value)
return String.Format ("/{0}:{1}", option, value);
return String.Format("/{0}", option);
}
private static void VerifyArgs (string[] sourceTexts,
string[] sourceTextNames, string target)
{
if (null == sourceTexts)
throw new ArgumentNullException ("sourceTexts");
if (null == sourceTextNames)
throw new ArgumentNullException ("sourceTextNames");
if (null == target)
throw new ArgumentNullException ("target");
if (sourceTexts.Length <= 0 || sourceTextNames.Length <= 0)
throw new IndexOutOfRangeException ();
}
private static StreamWriter CreateBugReport (string[] source_texts,
string[] source_names, string path)
{
StreamWriter bug_report = null;
try {
bug_report = new StreamWriter (path);
bug_report.WriteLine ("### C# Compiler Defect Report," +
" created {0}", DateTime.Now);
// Compiler Version
// Runtime
// Operating System
// Username
for (int i=0; i<source_texts.Length; i++) {
bug_report.WriteLine ("### Source file: '{0}'",
source_names[i]);
bug_report.Write (source_texts[i]);
}
} catch {
if (bug_report != null)
bug_report.Close ();
throw;
}
return bug_report;
}
private static bool ValidOption (string option)
{
switch (option) {
case "addmodule":
case "baseaddress":
case "checked":
case "d":
case "debug":
case "doc":
case "filealign":
case "incr":
case "lib":
case "linkres":
case "m":
case "nostdlib":
case "nowarn":
case "o":
case "r":
case "res":
case "target":
case "unsafe":
case "w":
case "warnaserror":
case "win32icon":
case "win32res":
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,92 @@
// Microsoft.CSharp.CompilerError
//
// Author(s):
// Jackson Harper (Jackson@LatitudeGeo.com)
//
// (C) 2002 Jackson Harper, All rights reserved.
//
//
// 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.Text;
namespace Microsoft.CSharp {
#if NET_2_0
[System.Obsolete]
#endif
public class CompilerError {
public ErrorLevel ErrorLevel;
public string ErrorMessage;
public string SourceFile;
public int ErrorNumber;
public int SourceColumn;
public int SourceLine;
public CompilerError ()
{
ErrorLevel = ErrorLevel.None;
ErrorMessage = String.Empty;
SourceFile = String.Empty;
ErrorNumber = 0;
SourceColumn = 0;
SourceLine = 0;
}
//
// Public Methods
//
/// <summary>
/// Error message in form:
/// filename(line,column): AAAAA CSXXX: message
/// </summary>
public override string ToString()
{
StringBuilder builder = new StringBuilder ();
if (String.Empty != SourceFile)
builder.AppendFormat ("{0}({1},{2}) ",
SourceFile, SourceLine, SourceColumn);
builder.AppendFormat ("{0} CS{1}: {2}",
ErrorLevelString, ErrorNumber, ErrorMessage);
return builder.ToString ();
}
//
// Private Properties
//
private string ErrorLevelString {
get {
if (ErrorLevel.FatalError == ErrorLevel)
return "Error Fatal";
return ErrorLevel.ToString ().ToLower ();
}
}
}
}

View File

@@ -0,0 +1,41 @@
// Microsoft.CSharp.ErrorLevel
//
// Author(s):
// Jackson Harper (Jackson@LatitudeGeo.com)
//
// (C) 2002 Jackson Harper, All rights reserved.
//
//
// 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 Microsoft.CSharp {
#if NET_2_0
[System.Obsolete]
#endif
public enum ErrorLevel {
None,
Warning,
Error,
FatalError,
}
}

View File

@@ -0,0 +1,8 @@
2004-05-11 Raja R Harinath <rharinath@novell.com>
* CompilerTest.cs (constructor): Remove. Compiler is a static-only
class.
2004-02-22 Atsushi Enomot <atsushi@ximian.com>
* Added CompilerTest.cs (just for setting up)

View File

@@ -0,0 +1,25 @@
//
// CompilerTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) Ximian, Inc.
//
using System;
using Microsoft.CSharp;
using NUnit.Framework;
namespace MonoTests.Cscompmgd
{
[TestFixture]
public class CompilerTest
{
[SetUp]
public void GetReady ()
{
}
}
}