Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -65,7 +65,6 @@ namespace MonoCasTests.Microsoft.CSharp {
catch (NotImplementedException) {
// mono
}
#if NET_2_0
CodeTypeMember ctm = new CodeTypeMember ();
StringWriter sw = new StringWriter ();
CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
@@ -75,7 +74,6 @@ namespace MonoCasTests.Microsoft.CSharp {
catch (NotImplementedException) {
// mono
}
#endif
}
// LinkDemand

View File

@@ -80,13 +80,11 @@ namespace MonoTests.Microsoft.CSharp
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.StaticConstructors), "#20");
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.TryCatchStatements), "#21");
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.Win32Resources), "#22");
#if NET_2_0
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.DeclareIndexerProperties), "#23");
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.GenericTypeDeclaration), "#24");
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.GenericTypeReference), "#25");
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.PartialTypes), "#26");
Assert.IsTrue (codeGenerator.Supports (GeneratorSupport.Resources), "#27");
#endif
}
[Test]
@@ -106,9 +104,7 @@ namespace MonoTests.Microsoft.CSharp
options.GenerateExecutable = false;
options.GenerateInMemory = true;
options.TempFiles = new TempFileCollection (_tempDir);
#if NET_2_0
options.EmbeddedResources.Add (sourceFile);
#endif
ICodeCompiler compiler = _codeProvider.CreateCompiler ();
CompilerResults results = compiler.CompileAssemblyFromFile (options,
@@ -129,7 +125,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.AreEqual (1, tempFiles.Length, "#5");
Assert.AreEqual (sourceFile, tempFiles[0], "#6");
#if NET_2_0
string[] resources = compiledAssembly.GetManifestResourceNames();
Assert.IsNotNull (resources, "#7");
Assert.AreEqual (1, resources.Length, "#8");
@@ -141,7 +136,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.IsNull (info.FileName, "#13");
Assert.IsNull (info.ReferencedAssembly, "#14");
Assert.AreEqual ((ResourceLocation.Embedded | ResourceLocation.ContainedInManifestFile), info.ResourceLocation, "#15");
#endif
}
[Test]
@@ -171,10 +165,8 @@ namespace MonoTests.Microsoft.CSharp
options.GenerateInMemory = true;
options.OutputAssembly = string.Empty;
options.TempFiles = new TempFileCollection (_tempDir);
#if NET_2_0
options.EmbeddedResources.Add (sourceFile1);
options.LinkedResources.Add (sourceFile2);
#endif
ICodeCompiler compiler = _codeProvider.CreateCompiler ();
CompilerResults results = compiler.CompileAssemblyFromFileBatch (options,
@@ -202,7 +194,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.IsTrue (File.Exists (sourceFile1), "#C2");
Assert.IsTrue (File.Exists (sourceFile2), "#C3");
#if NET_2_0
string[] resources = compiledAssembly.GetManifestResourceNames();
Assert.IsNotNull (resources, "#D1");
Assert.AreEqual (2, resources.Length, "#D2");
@@ -233,7 +224,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.AreEqual ("file2.cs", info.FileName, "#F6");
Assert.IsNull (info.ReferencedAssembly, "#F7");
Assert.AreEqual ((ResourceLocation) 0, info.ResourceLocation, "#F8");
#endif
}
[Test]
@@ -262,10 +252,8 @@ namespace MonoTests.Microsoft.CSharp
options.GenerateExecutable = false;
options.GenerateInMemory = true;
options.TempFiles = new TempFileCollection (_tempDir);
#if NET_2_0
options.EmbeddedResources.Add (sourceFile1);
options.LinkedResources.Add (sourceFile2);
#endif
ICodeCompiler compiler = _codeProvider.CreateCompiler ();
CompilerResults results = compiler.CompileAssemblyFromFileBatch (options,
@@ -293,7 +281,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.IsTrue (File.Exists (sourceFile1), "#C2");
Assert.IsTrue (File.Exists (sourceFile2), "#C3");
#if NET_2_0
string[] resources = compiledAssembly.GetManifestResourceNames();
Assert.IsNotNull (resources, "#D1");
Assert.AreEqual (2, resources.Length, "#D2");
@@ -324,7 +311,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.AreEqual ("file2.cs", info.FileName, "#F6");
Assert.IsNull (info.ReferencedAssembly, "#F7");
Assert.AreEqual ((ResourceLocation) 0, info.ResourceLocation, "#F8");
#endif
}
[Test]

View File

@@ -97,7 +97,6 @@ namespace MonoTests.Microsoft.CSharp
sb.Length = 0;
Assert.AreEqual ("void", Generate (new CodeTypeReferenceExpression (""), sw), "#10");
sb.Length = 0;
#if NET_2_0
Assert.AreEqual ("byte", Generate (new CodeTypeReferenceExpression (typeof (byte)), sw), "#11");
sb.Length = 0;
Assert.AreEqual ("decimal", Generate (new CodeTypeReferenceExpression (typeof (decimal)), sw), "#12");
@@ -114,24 +113,6 @@ namespace MonoTests.Microsoft.CSharp
sb.Length = 0;
Assert.AreEqual ("float", Generate (new CodeTypeReferenceExpression (typeof (float)), sw), "#18");
sb.Length = 0;
#else
Assert.AreEqual (typeof (byte).FullName, Generate (new CodeTypeReferenceExpression (typeof (byte)), sw), "#19");
sb.Length = 0;
Assert.AreEqual (typeof (decimal).FullName, Generate (new CodeTypeReferenceExpression (typeof (decimal)), sw), "#20");
sb.Length = 0;
Assert.AreEqual (typeof (double).FullName, Generate (new CodeTypeReferenceExpression (typeof (double)), sw), "#21");
sb.Length = 0;
Assert.AreEqual (typeof (sbyte).FullName, Generate (new CodeTypeReferenceExpression (typeof (sbyte)), sw), "#22");
sb.Length = 0;
Assert.AreEqual (typeof (ushort).FullName, Generate (new CodeTypeReferenceExpression (typeof (ushort)), sw), "#23");
sb.Length = 0;
Assert.AreEqual (typeof (uint).FullName, Generate (new CodeTypeReferenceExpression (typeof (uint)), sw), "#24");
sb.Length = 0;
Assert.AreEqual (typeof (ulong).FullName, Generate (new CodeTypeReferenceExpression (typeof (ulong)), sw), "#25");
sb.Length = 0;
Assert.AreEqual (typeof (float).FullName, Generate (new CodeTypeReferenceExpression (typeof (float)), sw), "#26");
sb.Length = 0;
#endif
sw.Close ();
}
}
@@ -253,17 +234,9 @@ namespace MonoTests.Microsoft.CSharp
sb.Length = 0;
Assert.AreEqual ("'\\''", Generate (new CodePrimitiveExpression ('\''), sw), "#39");
sb.Length = 0;
#if NET_2_0
Assert.AreEqual ("'\\u2028'", Generate (new CodePrimitiveExpression ('\u2028'), sw), "#40");
#else
Assert.AreEqual ("'\\u8232'", Generate (new CodePrimitiveExpression ('\u2028'), sw), "#40");
#endif
sb.Length = 0;
#if NET_2_0
Assert.AreEqual ("'\\u2029'", Generate (new CodePrimitiveExpression ('\u2029'), sw), "#41");
#else
Assert.AreEqual ("'\\u8233'", Generate (new CodePrimitiveExpression ('\u2029'), sw), "#41");
#endif
sb.Length = 0;
Assert.AreEqual ("'\u2030'", Generate (new CodePrimitiveExpression ('\u2030'), sw), "#42");
sw.Close ();
@@ -271,9 +244,6 @@ namespace MonoTests.Microsoft.CSharp
}
[Test]
#if ONLY_1_1
[ExpectedException (typeof (ArgumentException))]
#endif
public void PrimitiveExpressionTest_SByte ()
{
StringBuilder sb = new StringBuilder ();
@@ -285,9 +255,6 @@ namespace MonoTests.Microsoft.CSharp
}
[Test]
#if ONLY_1_1
[ExpectedException (typeof (ArgumentException))]
#endif
public void PrimitiveExpressionTest_UInt16 ()
{
StringBuilder sb = new StringBuilder ();
@@ -299,9 +266,6 @@ namespace MonoTests.Microsoft.CSharp
}
[Test]
#if ONLY_1_1
[ExpectedException (typeof (ArgumentException))]
#endif
public void PrimitiveExpressionTest_UInt32 ()
{
StringBuilder sb = new StringBuilder ();
@@ -313,9 +277,6 @@ namespace MonoTests.Microsoft.CSharp
}
[Test]
#if ONLY_1_1
[ExpectedException (typeof (ArgumentException))]
#endif
public void PrimitiveExpressionTest_UInt64 ()
{
StringBuilder sb = new StringBuilder ();
@@ -506,7 +467,6 @@ namespace MonoTests.Microsoft.CSharp
}
}
#if NET_2_0
[Test]
public void DefaultValueExpressionTest ()
{
@@ -518,7 +478,6 @@ namespace MonoTests.Microsoft.CSharp
sw.Close ();
}
}
#endif
[Test]
public void DelegateInvokeTest ()

View File

@@ -169,7 +169,6 @@ namespace MonoTests.Microsoft.CSharp
"}}{0}", NewLine), Generate (options), "#B2");
}
#if NET_2_0
[Test]
public void Type_TypeParameters ()
{
@@ -531,6 +530,5 @@ namespace MonoTests.Microsoft.CSharp
" }}{0}" +
"}}{0}", NewLine), Generate ());
}
#endif
}
}

View File

@@ -202,11 +202,7 @@ namespace MonoTests.Microsoft.CSharp
" ;;{0}" +
" DoB();{0}" +
" ;{0}" +
#if NET_2_0
"A{0}" +
#else
" A{0}" +
#endif
" DoC();{0}" +
"}}{0}", NewLine), Generate (), "#3");
@@ -217,20 +213,12 @@ namespace MonoTests.Microsoft.CSharp
" ;;{0}" +
" DoB();{0}" +
" ;{0}" +
#if NET_2_0
"A{0}" +
#else
" A{0}" +
#endif
" DoC();{0}" +
"}}{0}" +
"else {{{0}" +
" DoD();{0}" +
#if NET_2_0
"B{0}" +
#else
" B{0}" +
#endif
" ;;{0}" +
" DoE();{0}" +
" ;{0}" +
@@ -245,19 +233,11 @@ namespace MonoTests.Microsoft.CSharp
" ;;{0}" +
" DoB();{0}" +
" ;{0}" +
#if NET_2_0
"A{0}" +
#else
" A{0}" +
#endif
" DoC();{0}" +
"}} else {{{0}" +
" DoD();{0}" +
#if NET_2_0
"B{0}" +
#else
" B{0}" +
#endif
" ;;{0}" +
" DoE();{0}" +
" ;{0}" +
@@ -273,11 +253,7 @@ namespace MonoTests.Microsoft.CSharp
"}}{0}" +
"else {{{0}" +
" DoD();{0}" +
#if NET_2_0
"B{0}" +
#else
" B{0}" +
#endif
" ;;{0}" +
" DoE();{0}" +
" ;{0}" +
@@ -292,11 +268,7 @@ namespace MonoTests.Microsoft.CSharp
" ;;{0}" +
" DoB();{0}" +
" ;{0}" +
#if NET_2_0
"A{0}" +
#else
" A{0}" +
#endif
" DoC();{0}" +
"}}{0}", NewLine), Generate (), "#7");
}
@@ -380,17 +352,9 @@ namespace MonoTests.Microsoft.CSharp
" ;;{0}" +
" DoB();{0}" +
"test:{0}" +
#if NET_2_0
"C{0}" +
#else
" C{0}" +
#endif
" ;{0}" +
#if NET_2_0
"A{0}" +
#else
" A{0}" +
#endif
" DoC();{0}" +
"}}{0}", NewLine), Generate (), "#5");
}
@@ -411,11 +375,7 @@ namespace MonoTests.Microsoft.CSharp
cls.Statement = new CodeSnippetStatement ("A");
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"class:{0}" +
#if NET_2_0
"A{0}",
#else
" A{0}",
#endif
NewLine), Generate (), "#3");
}
@@ -538,13 +498,8 @@ namespace MonoTests.Microsoft.CSharp
"catch (System.ApplicationException ) {{{0}" +
"}}{0}" +
"finally {{{0}" +
#if NET_2_0
"A{0}" +
"B{0}" +
#else
" A{0}" +
" B{0}" +
#endif
"}}{0}", NewLine), Generate (), "#1");
options.ElseOnClosing = true;
@@ -555,13 +510,8 @@ namespace MonoTests.Microsoft.CSharp
"}} catch (System.ArgumentException ex1) {{{0}" +
"}} catch (System.ApplicationException ) {{{0}" +
"}} finally {{{0}" +
#if NET_2_0
"A{0}" +
"B{0}" +
#else
" A{0}" +
" B{0}" +
#endif
"}}{0}", NewLine), Generate (), "#2");
statement = new CodeTryCatchFinallyStatement ();

View File

@@ -1 +1 @@
3fcc1d6d3b7c329eaaf86b7566cb5d50a7b77b74
42a42146a3e47507d1320ecd1a3e4d159db4df51

View File

@@ -9,9 +9,7 @@
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
#if NET_2_0
using System.Collections.Generic;
#endif
using NUnit.Framework;
@@ -30,7 +28,6 @@ namespace MonoTests.Microsoft.CSharp
gen = new CSharpCodeProvider ().CreateGenerator ();
}
#if NET_2_0
// This test fails on 2.0 profile, because our CodeTypeReference does not
// parse basetype from right to left.
[Test]
@@ -40,7 +37,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.AreEqual ("A[,,][,]", gen.GetTypeOutput (new CodeTypeReference ("A[,,][,]")), "#5");
Assert.AreEqual ("A<B, D>[,]", gen.GetTypeOutput (new CodeTypeReference ("A[B,,D][,]")), "#6");
}
#endif
[Test]
public void GetTypeOutput ()
@@ -49,19 +45,8 @@ namespace MonoTests.Microsoft.CSharp
Assert.AreEqual ("A[]", gen.GetTypeOutput (new CodeTypeReference ("A[]")), "#2");
Assert.AreEqual ("int[]", gen.GetTypeOutput (new CodeTypeReference (typeof (int).FullName, 1)), "#3");
Assert.AreEqual ("int[,]", gen.GetTypeOutput (new CodeTypeReference (typeof (int).FullName, 2)), "#4");
#if NET_2_0
Assert.AreEqual ("System.Nullable<int>", gen.GetTypeOutput (new CodeTypeReference (typeof (int?))), "#7");
Assert.AreEqual ("System.Collections.Generic.Dictionary<int, string>", gen.GetTypeOutput (new CodeTypeReference (typeof (Dictionary<int, string>))), "#8");
#else
Assert.AreEqual ("A[,,][,]", gen.GetTypeOutput (new CodeTypeReference ("A[,,][,]")), "#5");
Assert.AreEqual ("A[B,,D][,]", gen.GetTypeOutput (new CodeTypeReference ("A[B,,D][,]")), "#6");
Assert.AreEqual ("System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]",
gen.GetTypeOutput (new CodeTypeReference ("System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")),
"#9");
Assert.AreEqual ("System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]",
gen.GetTypeOutput (new CodeTypeReference ("System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")),
"#10");
#endif
}
[Test]
@@ -82,7 +67,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.AreEqual ("object", gen.GetTypeOutput (new CodeTypeReference ("systeM.oBject")), "#14");
Assert.AreEqual ("void", gen.GetTypeOutput (new CodeTypeReference (typeof(void))), "#15");
Assert.AreEqual ("void", gen.GetTypeOutput (new CodeTypeReference ("systeM.vOid")), "#16");
#if NET_2_0
Assert.AreEqual ("byte", gen.GetTypeOutput (new CodeTypeReference (typeof(byte))), "#17");
Assert.AreEqual ("byte", gen.GetTypeOutput (new CodeTypeReference ("systeM.bYte")), "#18");
Assert.AreEqual ("sbyte", gen.GetTypeOutput (new CodeTypeReference (typeof(sbyte))), "#19");
@@ -99,24 +83,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.AreEqual ("ulong", gen.GetTypeOutput (new CodeTypeReference ("systeM.uinT64")), "#30");
Assert.AreEqual ("ushort", gen.GetTypeOutput (new CodeTypeReference (typeof (ushort))), "#31");
Assert.AreEqual ("ushort", gen.GetTypeOutput (new CodeTypeReference ("systeM.uinT16")), "#32");
#else
Assert.AreEqual (typeof (byte).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (byte))), "#17");
Assert.AreEqual ("systeM.bYte", gen.GetTypeOutput (new CodeTypeReference ("systeM.bYte")), "#18");
Assert.AreEqual (typeof (sbyte).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (sbyte))), "#19");
Assert.AreEqual ("systeM.sBYte", gen.GetTypeOutput (new CodeTypeReference ("systeM.sBYte")), "#20");
Assert.AreEqual (typeof (decimal).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (decimal))), "#21");
Assert.AreEqual ("systeM.dEcimal", gen.GetTypeOutput (new CodeTypeReference ("systeM.dEcimal")), "#22");
Assert.AreEqual (typeof (double).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (double))), "#23");
Assert.AreEqual ("systeM.dOuble", gen.GetTypeOutput (new CodeTypeReference ("systeM.dOuble")), "#24");
Assert.AreEqual (typeof (float).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (float))), "#25");
Assert.AreEqual ("systeM.SiNgle", gen.GetTypeOutput (new CodeTypeReference ("systeM.SiNgle")), "#26");
Assert.AreEqual (typeof (uint).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (uint))), "#27");
Assert.AreEqual ("systeM.UinT32", gen.GetTypeOutput (new CodeTypeReference ("systeM.UinT32")), "#28");
Assert.AreEqual (typeof (ulong).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (ulong))), "#29");
Assert.AreEqual ("systeM.uinT64", gen.GetTypeOutput (new CodeTypeReference ("systeM.uinT64")), "#30");
Assert.AreEqual (typeof (ushort).FullName, gen.GetTypeOutput (new CodeTypeReference (typeof (ushort))), "#31");
Assert.AreEqual ("systeM.uinT16", gen.GetTypeOutput (new CodeTypeReference ("systeM.uinT16")), "#32");
#endif
}
}
}