提交 bae7eab0 编写于 作者: J Jared Parsons

CreateCompilation refactored

上级 2888462d
......@@ -388,7 +388,7 @@ public void Win32ResourceArguments()
};
var parsedArgs = DefaultParse(args, _baseDirectory);
var compilation = CreateStandardCompilation(new SyntaxTree[0]);
var compilation = CreateCompilation(new SyntaxTree[0]);
IEnumerable<DiagnosticInfo> errors;
CSharpCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, out errors);
Assert.Equal(1, errors.Count());
......@@ -512,7 +512,7 @@ public void Win32IconContainsGarbage()
string tmpFileName = Temp.CreateFile().WriteAllBytes(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }).Path;
var parsedArgs = DefaultParse(new[] { "/win32icon:" + tmpFileName, "a.cs" }, _baseDirectory);
var compilation = CreateStandardCompilation(new SyntaxTree[0]);
var compilation = CreateCompilation(new SyntaxTree[0]);
IEnumerable<DiagnosticInfo> errors;
CSharpCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, out errors);
......@@ -9016,7 +9016,7 @@ public void WarnAsError_LastOneWins1()
var arguments = DefaultParse(new[] { "/warnaserror-:3001", "/warnaserror" }, null);
var options = arguments.CompilationOptions;
var comp = CreateStandardCompilation(@"[assembly: System.CLSCompliant(true)]
var comp = CreateCompilation(@"[assembly: System.CLSCompliant(true)]
public class C
{
public void M(ushort i)
......@@ -9041,7 +9041,7 @@ public void WarnAsError_LastOneWins2()
var arguments = DefaultParse(new[] { "/warnaserror", "/warnaserror-:3001" }, null);
var options = arguments.CompilationOptions;
var comp = CreateStandardCompilation(@"[assembly: System.CLSCompliant(true)]
var comp = CreateCompilation(@"[assembly: System.CLSCompliant(true)]
public class C
{
public void M(ushort i)
......
......@@ -248,7 +248,7 @@ private void TestConditionAttributeType_SameSource(string condDefs)
// Scenario to test Conditional directive stack creation during SyntaxTree.Create, see Devdiv Bug #13846 for details.
CompilationUnitSyntax root = SyntaxFactory.ParseCompilationUnit(testSource);
var syntaxTree = SyntaxFactory.SyntaxTree(root);
var compilation = CreateStandardCompilation(syntaxTree, options: TestOptions.ReleaseExe);
var compilation = CreateCompilation(syntaxTree, options: TestOptions.ReleaseExe);
CompileAndVerify(compilation, sourceSymbolValidator: CommonSourceValidatorForCondAttrType, symbolValidator: CommonMetadataValidatorForCondAttrType, expectedOutput: "");
}
......@@ -264,7 +264,7 @@ private void TestConditionAttributeType_DifferentSource(string condDefsSrcFile1,
CompileAndVerify(testSources, sourceSymbolValidator: CommonSourceValidatorForCondAttrType, symbolValidator: CommonMetadataValidatorForCondAttrType, expectedOutput: "");
// Different source files, different compilation
var comp1 = CreateStandardCompilation(source1);
var comp1 = CreateCompilation(source1);
CompileAndVerify(source2, references: new[] { comp1.ToMetadataReference() }, sourceSymbolValidator: CommonSourceValidatorForCondAttrType, symbolValidator: CommonMetadataValidatorForCondAttrType, expectedOutput: "");
}
......@@ -459,7 +459,7 @@ private void TestConditionMethods_SameSource(string condDefs)
// Scenario to test Conditional directive stack creation during SyntaxTree.Create, see Devdiv Bug #13846 for details.
CompilationUnitSyntax root = SyntaxFactory.ParseCompilationUnit(testSource);
var syntaxTree = SyntaxFactory.SyntaxTree(root);
var compilation = CreateStandardCompilation(syntaxTree, options: TestOptions.ReleaseExe);
var compilation = CreateCompilation(syntaxTree, options: TestOptions.ReleaseExe);
CompileAndVerify(compilation, expectedOutput: s_commonExpectedOutput_ConditionalMethodsTest);
}
......@@ -475,7 +475,7 @@ private void TestConditionMethods_DifferentSource(string condDefsSrcFile1, strin
CompileAndVerify(testSources, expectedOutput: s_commonExpectedOutput_ConditionalMethodsTest);
// Different source files, different compilation
var comp1 = CreateStandardCompilation(source1, assemblyName: Guid.NewGuid().ToString());
var comp1 = CreateCompilation(source1, assemblyName: Guid.NewGuid().ToString());
CompileAndVerify(source2, references: new[] { comp1.ToMetadataReference() }, expectedOutput: s_commonExpectedOutput_ConditionalMethodsTest);
}
......@@ -554,7 +554,7 @@ public void TestConditionMethods_03()
[Fact, WorkItem(529683, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529683")]
public void CondMethodInDelegateCreationExpr()
{
var compilation = CreateStandardCompilation(@"
var compilation = CreateCompilation(@"
using System.Diagnostics;
class Test
......@@ -668,7 +668,7 @@ class Bar
public static string M() { return ""str""; }
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (12,33): error CS0428: Cannot convert method group 'M' to non-delegate type 'string'. Did you intend to invoke the method?
// public const string M = Bar.M;
Diagnostic(ErrorCode.ERR_MethGrpToNonDel, "M").WithArguments("M", "string"),
......
......@@ -37,13 +37,13 @@ public static void Main()
}
}";
CreateStandardCompilation(code).VerifyEmitDiagnostics();
CreateCompilation(code).VerifyEmitDiagnostics();
}
[Fact]
public void ReferencingEmbeddedAttributesFromADifferentAssemblyFails_Internal()
{
var reference = CreateStandardCompilation(@"
var reference = CreateCompilation(@"
[assembly:System.Runtime.CompilerServices.InternalsVisibleToAttribute(""Source"")]
namespace Microsoft.CodeAnalysis
{
......@@ -71,7 +71,7 @@ public static void Main()
}
}";
CreateStandardCompilation(code, references: new[] { reference.ToMetadataReference() }, assemblyName: "Source").VerifyDiagnostics(
CreateCompilation(code, references: new[] { reference.ToMetadataReference() }, assemblyName: "Source").VerifyDiagnostics(
// (6,38): error CS0234: The type or namespace name 'TestType1' does not exist in the namespace 'TestReference' (are you missing an assembly reference?)
// var obj1 = new TestReference.TestType1();
Diagnostic(ErrorCode.ERR_DottedTypeNameNotFoundInNS, "TestType1").WithArguments("TestType1", "TestReference").WithLocation(6, 38),
......@@ -83,7 +83,7 @@ public static void Main()
[Fact]
public void ReferencingEmbeddedAttributesFromADifferentAssemblyFails_Module()
{
var module = CreateStandardCompilation(@"
var module = CreateCompilation(@"
namespace Microsoft.CodeAnalysis
{
internal class EmbeddedAttribute : System.Attribute { }
......@@ -112,7 +112,7 @@ public static void Main()
}
}";
CreateStandardCompilation(code, references: new[] { reference }, assemblyName: "Source").VerifyDiagnostics(
CreateCompilation(code, references: new[] { reference }, assemblyName: "Source").VerifyDiagnostics(
// (6,38): error CS0234: The type or namespace name 'TestType1' does not exist in the namespace 'TestReference' (are you missing an assembly reference?)
// var obj1 = new TestReference.TestType1();
Diagnostic(ErrorCode.ERR_DottedTypeNameNotFoundInNS, "TestType1").WithArguments("TestType1", "TestReference").WithLocation(6, 38),
......@@ -124,7 +124,7 @@ public static void Main()
[Fact]
public void ReferencingEmbeddedAttributesFromADifferentAssemblyFails_Public()
{
var reference = CreateStandardCompilation(@"
var reference = CreateCompilation(@"
namespace Microsoft.CodeAnalysis
{
internal class EmbeddedAttribute : System.Attribute { }
......@@ -151,7 +151,7 @@ public static void Main()
}
}";
CreateStandardCompilation(code, references: new[] { reference.ToMetadataReference() }).VerifyDiagnostics(
CreateCompilation(code, references: new[] { reference.ToMetadataReference() }).VerifyDiagnostics(
// (6,38): error CS0234: The type or namespace name 'TestType1' does not exist in the namespace 'TestReference' (are you missing an assembly reference?)
// var obj1 = new TestReference.TestType1();
Diagnostic(ErrorCode.ERR_DottedTypeNameNotFoundInNS, "TestType1").WithArguments("TestType1", "TestReference").WithLocation(6, 38),
......@@ -204,7 +204,7 @@ public void M(in int p)
}
}";
CreateStandardCompilation(code, assemblyName: "testModule").VerifyEmitDiagnostics(
CreateCompilation(code, assemblyName: "testModule").VerifyEmitDiagnostics(
// (4,18): error CS8336: The type name 'Microsoft.CodeAnalysis.EmbeddedAttribute' is reserved to be used by the compiler.
// public class EmbeddedAttribute : System.Attribute { }
Diagnostic(ErrorCode.ERR_TypeReserved, "EmbeddedAttribute").WithArguments("Microsoft.CodeAnalysis.EmbeddedAttribute").WithLocation(4, 18));
......@@ -213,7 +213,7 @@ public void M(in int p)
[Fact]
public void EmbeddedAttributeInReferencedModuleShouldTriggerAnErrorIfCompilerNeedsToGenerateOne()
{
var module = CreateStandardCompilation(options: TestOptions.ReleaseModule, assemblyName: "testModule", source: @"
var module = CreateCompilation(options: TestOptions.ReleaseModule, assemblyName: "testModule", source: @"
namespace Microsoft.CodeAnalysis
{
public class EmbeddedAttribute : System.Attribute { }
......@@ -230,7 +230,7 @@ public void M(in int p)
}
}";
CreateStandardCompilation(code, references: new[] { moduleRef }).VerifyEmitDiagnostics(
CreateCompilation(code, references: new[] { moduleRef }).VerifyEmitDiagnostics(
// error CS8004: Type 'EmbeddedAttribute' exported from module 'testModule.netmodule' conflicts with type declared in primary module of this assembly.
Diagnostic(ErrorCode.ERR_ExportedTypeConflictsWithDeclaration).WithArguments("Microsoft.CodeAnalysis.EmbeddedAttribute", "testModule.netmodule").WithLocation(1, 1));
}
......@@ -238,7 +238,7 @@ public void M(in int p)
[Fact]
public void EmbeddedAttributeForwardedToAnotherAssemblyShouldTriggerAnError()
{
var reference = CreateStandardCompilation(@"
var reference = CreateCompilation(@"
namespace Microsoft.CodeAnalysis
{
public class EmbeddedAttribute : System.Attribute { }
......@@ -254,7 +254,7 @@ public void M(in int p)
}
}";
CreateStandardCompilation(code, references: new[] { reference }).VerifyEmitDiagnostics(
CreateCompilation(code, references: new[] { reference }).VerifyEmitDiagnostics(
// error CS8006: Forwarded type 'EmbeddedAttribute' conflicts with type declared in primary module of this assembly.
Diagnostic(ErrorCode.ERR_ForwardedTypeConflictsWithDeclaration).WithArguments("Microsoft.CodeAnalysis.EmbeddedAttribute").WithLocation(1, 1));
}
......@@ -262,7 +262,7 @@ public void M(in int p)
[Fact]
public void CompilerShouldIgnorePublicEmbeddedAttributesInReferencedAssemblies()
{
var reference = CreateStandardCompilation(assemblyName: "testRef", source: @"
var reference = CreateCompilation(assemblyName: "testRef", source: @"
namespace Microsoft.CodeAnalysis
{
public class EmbeddedAttribute : System.Attribute { }
......@@ -413,7 +413,7 @@ public class Test
[Fact]
public void EmbeddedTypesInAnAssemblyAreNotExposedExternally()
{
var compilation1 = CreateStandardCompilation(@"
var compilation1 = CreateCompilation(@"
namespace Microsoft.CodeAnalysis
{
public class EmbeddedAttribute : System.Attribute { }
......@@ -426,7 +426,7 @@ public class TestReference2 { }
Assert.NotNull(compilation1.GetTypeByMetadataName("TestReference1"));
Assert.NotNull(compilation1.GetTypeByMetadataName("TestReference2"));
var compilation2 = CreateStandardCompilation("", references: new[] { compilation1.EmitToImageReference() });
var compilation2 = CreateCompilation("", references: new[] { compilation1.EmitToImageReference() });
Assert.Null(compilation2.GetTypeByMetadataName("TestReference1"));
Assert.NotNull(compilation2.GetTypeByMetadataName("TestReference2"));
......
......@@ -59,7 +59,7 @@ static void M()
}
[Experimental] public enum E { A }
}";
var comp1 = CreateStandardCompilation(new[] { Parse(ExperimentalAttributeSource), Parse(source1) });
var comp1 = CreateCompilation(new[] { Parse(ExperimentalAttributeSource), Parse(source1) });
comp1.VerifyDiagnostics(
// (11,17): warning CS8305: 'N.A<T>.B' is for evaluation purposes only and is subject to change or removal in future updates.
// new B();
......@@ -82,7 +82,7 @@ static void F()
e = E.A;
}
}";
var comp2A = CreateStandardCompilation(source2, new[] { comp1.EmitToImageReference() });
var comp2A = CreateCompilation(source2, new[] { comp1.EmitToImageReference() });
comp2A.VerifyDiagnostics(
// (8,24): warning CS8305: 'N.A<int>.B' is for evaluation purposes only and is subject to change or removal in future updates.
// object o = new B();
......@@ -97,7 +97,7 @@ static void F()
// e = E.A;
Diagnostic(ErrorCode.WRN_Experimental, "E").WithArguments("N.E").WithLocation(11, 13));
var comp2B = CreateStandardCompilation(source2, new[] { new CSharpCompilationReference(comp1) });
var comp2B = CreateCompilation(source2, new[] { new CSharpCompilationReference(comp1) });
comp2B.VerifyDiagnostics(
// (8,24): warning CS8305: 'N.A<int>.B' is for evaluation purposes only and is subject to change or removal in future updates.
// object o = new B();
......@@ -157,7 +157,7 @@ static void Main()
((I)o).F(); // warning CS8305: 'I.F()' is for evaluation purposes only
}
}";
var comp1 = CreateStandardCompilation(source1, new[] { ref0 });
var comp1 = CreateCompilation(source1, new[] { ref0 });
comp1.VerifyDiagnostics(
// (7,13): warning CS8305: 'E.A' is for evaluation purposes only and is subject to change or removal in future updates.
// e = E.A; // warning CS8305: 'F.A' is for evaluation purposes only
......
......@@ -124,7 +124,7 @@ namespace System.Runtime.CompilerServices
public class IsByRefLikeAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
class Test
......@@ -151,7 +151,7 @@ namespace System.Runtime.CompilerServices
public class IsByRefLikeAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -160,7 +160,7 @@ public class IsByRefLikeAttribute : System.Attribute { }
public delegate ref readonly int D([IsByRefLike]in int x);
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (4,2): error CS8335: Do not use 'System.Runtime.CompilerServices.IsByRefLikeAttribute'. This is reserved for compiler usage.
// [IsByRefLike]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsByRefLike").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(4, 2),
......@@ -178,7 +178,7 @@ namespace System.Runtime.CompilerServices
public class IsByRefLikeAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -189,7 +189,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (4,2): error CS8335: Do not use 'System.Runtime.CompilerServices.IsByRefLikeAttribute'. This is reserved for compiler usage.
// [IsByRefLike]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsByRefLike").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(4, 2));
......@@ -204,7 +204,7 @@ namespace System.Runtime.CompilerServices
public class IsByRefLikeAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -218,7 +218,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (6,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsByRefLikeAttribute'. This is reserved for compiler usage.
// [IsByRefLike]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsByRefLike").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(6, 6));
......@@ -233,7 +233,7 @@ namespace System.Runtime.CompilerServices
public class IsByRefLikeAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -247,7 +247,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (8,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsByRefLikeAttribute'. This is reserved for compiler usage.
// [IsByRefLike]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsByRefLike").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(8, 6));
......@@ -262,7 +262,7 @@ namespace System.Runtime.CompilerServices
public class IsByRefLikeAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -278,7 +278,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (6,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsByRefLikeAttribute'. This is reserved for compiler usage.
// [IsByRefLike]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsByRefLike").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(6, 6),
......@@ -299,7 +299,7 @@ namespace System.Runtime.CompilerServices
public class IsByRefLikeAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -311,7 +311,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (6,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsByRefLikeAttribute'. This is reserved for compiler usage.
// [IsByRefLike]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsByRefLike").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(6, 6),
......@@ -330,7 +330,7 @@ public class Test
ref struct S1{}
}";
CreateStandardCompilation(code).VerifyDiagnostics(
CreateCompilation(code).VerifyDiagnostics(
// (2,2): error CS0246: The type or namespace name 'IsByRefLikeAttribute' could not be found (are you missing a using directive or an assembly reference?)
// [IsByRefLike]
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "IsByRefLike").WithArguments("IsByRefLikeAttribute").WithLocation(2, 2),
......@@ -345,13 +345,13 @@ public void TypeReferencingAnotherTypeThatUsesAPublicIsByRefLikeAttributeFromATh
{
var options = TestOptions.DebugDll.WithMetadataImportOptions(MetadataImportOptions.All);
var code1 = CreateStandardCompilation(@"
var code1 = CreateCompilation(@"
namespace System.Runtime.CompilerServices
{
public class IsByRefLikeAttribute : System.Attribute { }
}");
var code2 = CreateStandardCompilation(@"
var code2 = CreateCompilation(@"
public class Test1
{
public ref struct S1{}
......@@ -364,7 +364,7 @@ public class Test1
Assert.Null(module.ContainingAssembly.GetTypeByMetadataName(isByRefLikeAttributeName));
});
var code3 = CreateStandardCompilation(@"
var code3 = CreateCompilation(@"
public class Test2
{
public ref struct S1{}
......@@ -385,7 +385,7 @@ public void BuildingAModuleRequiresIsByRefLikeAttributeToBeThere_Missing_SourceM
public ref struct S1{}
";
CreateStandardCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
CreateCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
// (2,19): error CS0518: Predefined type 'System.Runtime.CompilerServices.IsByRefLikeAttribute' is not defined or imported
// public ref struct S1{}
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "S1").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(2, 19)
......@@ -402,7 +402,7 @@ public class Test
public ref struct S2{}
}";
CreateStandardCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
CreateCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
// (5,23): error CS0518: Predefined type 'System.Runtime.CompilerServices.IsByRefLikeAttribute' is not defined or imported
// public ref struct S2{}
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "S2").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute").WithLocation(5, 23),
......@@ -415,7 +415,7 @@ public class Test
[Fact]
public void BuildingAModuleRequiresIsByRefLikeAttributeToBeThere_InAReference()
{
var reference = CreateStandardCompilation(@"
var reference = CreateCompilation(@"
namespace System.Runtime.CompilerServices
{
public class IsByRefLikeAttribute : System.Attribute { }
......@@ -503,7 +503,7 @@ class Test
public ref struct S1{}
}";
CreateStandardCompilation(text, options: TestOptions.ReleaseModule).VerifyDiagnostics(
CreateCompilation(text, options: TestOptions.ReleaseModule).VerifyDiagnostics(
// (11,23): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsByRefLikeAttribute..ctor'
// public ref struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute", ".ctor").WithLocation(11, 23)
......@@ -526,7 +526,7 @@ class Test
public ref struct S1{}
}";
CreateStandardCompilation(text).VerifyEmitDiagnostics(
CreateCompilation(text).VerifyEmitDiagnostics(
// (11,22): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsByRefLikeAttribute..ctor'
// public ref struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute", ".ctor").WithLocation(11, 22)
......@@ -549,7 +549,7 @@ class Test
public ref struct S1{}
}";
CreateStandardCompilation(text).VerifyEmitDiagnostics(
CreateCompilation(text).VerifyEmitDiagnostics(
// (11,23): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsByRefLikeAttribute..ctor'
// public ref struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute", ".ctor").WithLocation(11, 23)
......@@ -559,7 +559,7 @@ class Test
[Fact]
public void IsByRefLikeAttributesInNoPia()
{
var comAssembly = CreateStandardCompilation(@"
var comAssembly = CreateCompilation(@"
using System;
using System.Runtime.InteropServices;
[assembly: ImportedFromTypeLib(""test.dll"")]
......@@ -596,10 +596,10 @@ public void M(Test p)
var options = TestOptions.DebugDll.WithMetadataImportOptions(MetadataImportOptions.All);
var compilation_CompilationReference = CreateStandardCompilation(code, options: options, references: new[] { comAssembly.ToMetadataReference(embedInteropTypes: true) });
var compilation_CompilationReference = CreateCompilation(code, options: options, references: new[] { comAssembly.ToMetadataReference(embedInteropTypes: true) });
CompileAndVerify(compilation_CompilationReference, symbolValidator: symbolValidator);
var compilation_BinaryReference = CreateStandardCompilation(code, options: options, references: new[] { comAssembly.EmitToImageReference(embedInteropTypes: true) });
var compilation_BinaryReference = CreateCompilation(code, options: options, references: new[] { comAssembly.EmitToImageReference(embedInteropTypes: true) });
CompileAndVerify(compilation_BinaryReference, symbolValidator: symbolValidator);
void symbolValidator(ModuleSymbol module)
......@@ -631,7 +631,7 @@ public class Test
public ref struct S1{}
}";
CreateStandardCompilation(text).VerifyEmitDiagnostics(
CreateCompilation(text).VerifyEmitDiagnostics(
// (11,23): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsByRefLikeAttribute..ctor'
// public ref struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsByRefLikeAttribute", ".ctor").WithLocation(11, 23)
......@@ -825,7 +825,7 @@ public struct S1 {}
}
";
CreateStandardCompilation(text).VerifyEmitDiagnostics(
CreateCompilation(text).VerifyEmitDiagnostics(
// (7,9): error CS0619: 'Test.S1' is obsolete: 'Types with embedded references are not supported in this version of your compiler.'
// Test.S1 v1 = default;
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "Test.S1").WithArguments("Test.S1", "Types with embedded references are not supported in this version of your compiler.").WithLocation(7, 9),
......@@ -871,7 +871,7 @@ public struct S2 {}
}
";
var libComp = CreateStandardCompilation(libSrc);
var libComp = CreateCompilation(libSrc);
var text = @"
class C1
......@@ -890,7 +890,7 @@ void Method()
}
";
CreateStandardCompilation(text, new[] { libComp.EmitToImageReference() }).VerifyEmitDiagnostics(
CreateCompilation(text, new[] { libComp.EmitToImageReference() }).VerifyEmitDiagnostics(
// (10,9): error CS0619: 'Test.S2' is obsolete: 'Types with embedded references are not supported in this version of your compiler.'
// Test.S2 v2 = default;
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "Test.S2").WithArguments("Test.S2", "Types with embedded references are not supported in this version of your compiler.").WithLocation(10, 9),
......@@ -905,7 +905,7 @@ void Method()
Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "v2").WithArguments("v2").WithLocation(10, 17)
);
CreateStandardCompilation(text, new[] { libComp.ToMetadataReference() }).VerifyEmitDiagnostics(
CreateCompilation(text, new[] { libComp.ToMetadataReference() }).VerifyEmitDiagnostics(
// (7,9): error CS0619: 'Test.S1' is obsolete: 'Types with embedded references are not supported in this version of your compiler.'
// Test.S1 v1 = default;
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "Test.S1").WithArguments("Test.S1", "Types with embedded references are not supported in this version of your compiler.").WithLocation(7, 9),
......
......@@ -25,7 +25,7 @@ public void Global1()
public class A : Attribute { }
";
CreateStandardCompilation(new[] { source1, source2 }).VerifyDiagnostics();
CreateCompilation(new[] { source1, source2 }).VerifyDiagnostics();
}
[Fact]
......@@ -44,7 +44,7 @@ namespace N
public class A : Attribute { }
";
CreateStandardCompilation(new[] { source1, source2 }).VerifyDiagnostics(
CreateCompilation(new[] { source1, source2 }).VerifyDiagnostics(
// (4,6): error CS1730: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
Diagnostic(ErrorCode.ERR_GlobalAttributesNotFirst, "assembly"));
}
......@@ -65,7 +65,7 @@ class X
public class A : Attribute { }
";
CreateStandardCompilation(new[] { source1, source2 }).VerifyDiagnostics(
CreateCompilation(new[] { source1, source2 }).VerifyDiagnostics(
// (5,1): error CS1519: Unexpected token '}', member declaration expected.
Diagnostic(ErrorCode.ERR_InvalidMemberDecl, "}").WithArguments("}"));
}
......@@ -95,7 +95,7 @@ class C
{
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,2): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "type"),
// (9,2): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
......@@ -143,7 +143,7 @@ struct S
{
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,2): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "type"),
// (9,2): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
......@@ -191,7 +191,7 @@ enum E
{
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,2): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "type"),
// (9,2): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
......@@ -239,7 +239,7 @@ interface I
{
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,2): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "type"),
// (9,2): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
......@@ -285,7 +285,7 @@ public class A : Attribute { }
[delegate: A]
delegate void D(int a);
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,2): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type, return'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "type, return"),
// (9,2): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type, return'. All attributes in this block will be ignored.
......@@ -332,7 +332,7 @@ class C
void M(int a) { }
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, return'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "method, return"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, return'. All attributes in this block will be ignored.
......@@ -379,7 +379,7 @@ class C
int a;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'field'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "field"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'field'. All attributes in this block will be ignored.
......@@ -430,7 +430,7 @@ enum E
x
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'field'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "field"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'field'. All attributes in this block will be ignored.
......@@ -479,7 +479,7 @@ class C
int a { get; set; }
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'property'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "property"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'property'. All attributes in this block will be ignored.
......@@ -533,7 +533,7 @@ int Goo
}
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (12,10): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, return'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "method, return"),
// (13,10): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, return'. All attributes in this block will be ignored.
......@@ -585,7 +585,7 @@ int Goo
}
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (14,10): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, param, return'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "method, param, return"),
// (15,10): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, param, return'. All attributes in this block will be ignored.
......@@ -630,7 +630,7 @@ class C
event System.Action e;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, field, event'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "method, field, event"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, field, event'. All attributes in this block will be ignored.
......@@ -677,7 +677,7 @@ interface I
event System.Action e;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, event'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "method, event"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, event'. All attributes in this block will be ignored.
......@@ -724,7 +724,7 @@ class C
event Action E { add { } remove { } }
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'event'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "event"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'event'. All attributes in this block will be ignored.
......@@ -778,7 +778,7 @@ class C
}
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (12,10): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, param, return'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "method, param, return"),
// (13,10): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, param, return'. All attributes in this block will be ignored.
......@@ -828,7 +828,7 @@ class C
}
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (14,10): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, param, return'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "method, param, return"),
// (15,10): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'method, param, return'. All attributes in this block will be ignored.
......@@ -875,7 +875,7 @@ class C
{
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (10,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'typevar'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "typevar"),
// (11,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'typevar'. All attributes in this block will be ignored.
......@@ -926,7 +926,7 @@ int x
) { }
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (11,10): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'param'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "param"),
// (12,10): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'param'. All attributes in this block will be ignored.
......@@ -974,7 +974,7 @@ public class A : Attribute { }
int x
);
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (9,6): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'param'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "param"),
// (10,6): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'param'. All attributes in this block will be ignored.
......@@ -1028,7 +1028,7 @@ class C
}
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (11,10): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'param'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "param"),
// (12,10): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'param'. All attributes in this block will be ignored.
......@@ -1072,7 +1072,7 @@ public class A : Attribute { }
class C
{
}";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (7,2): warning CS0658: 'class' is not a recognized attribute location. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
Diagnostic(ErrorCode.WRN_InvalidAttributeLocation, "class").WithArguments("class", "type"),
// (8,2): warning CS0658: 'struct' is not a recognized attribute location. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
......@@ -1128,7 +1128,7 @@ public class A : Attribute { }
[Fact]
public void CS0246ERR_SingleTypeNameNotFound_VerbatimIdentifierAttributeTarget()
{
CreateStandardCompilation(@"class A { [@return:X] void B() { } }").VerifyDiagnostics(
CreateCompilation(@"class A { [@return:X] void B() { } }").VerifyDiagnostics(
// (1,20): error CS0246: The type or namespace name 'XAttribute' could not be found (are you missing a using directive or an assembly reference?)
// class A { [@return:X] void B() { } }
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "X").WithArguments("XAttribute").WithLocation(1, 20),
......@@ -1153,7 +1153,7 @@ class C { [return:@X] void M() { } } // Fine, binds to X
class D { [@return:@X] void M() { } } // Fine, binds to X
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (7,19): error CS1614: 'X' is ambiguous between 'X' and 'XAttribute'; use either '@X' or 'XAttribute'
// class A { [return:X] void M() { } } // Ambiguous
Diagnostic(ErrorCode.ERR_AmbiguousAttribute, "X").WithArguments("X", "X", "XAttribute"),
......
......@@ -274,7 +274,7 @@ class X
X MaxValue_1;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (6,16): error CS0591: Invalid value for argument to 'MarshalAs' attribute
Diagnostic(ErrorCode.ERR_InvalidAttributeArgument, "(UnmanagedType)(-1)").WithArguments("MarshalAs"),
// (9,16): error CS0591: Invalid value for argument to 'MarshalAs' attribute
......@@ -353,7 +353,7 @@ class X
int IUnknown_MaxValue_1;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,81): error CS0599: Invalid value for argument to 'MarshalAs' attribute
Diagnostic(ErrorCode.ERR_InvalidNamedArgument, "IidParameterIndex = -1").WithArguments("IidParameterIndex"),
// (11,81): error CS0599: Invalid value for argument to 'MarshalAs' attribute
......@@ -466,7 +466,7 @@ class X
[MarshalAs(UnmanagedType.LPArray, ArraySubType = (UnmanagedType)(-1))] int LPArray_e8;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,79): error CS7045: Parameter not valid for the specified unmanaged type.
// [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.ByValTStr, SafeArraySubType = VarEnum.VT_BSTR, SafeArrayUserDefinedSubType = null, SizeConst = -1, SizeParamIndex = -1)]int LPArray_e0;
Diagnostic(ErrorCode.ERR_ParameterNotValidForType, "SafeArraySubType = VarEnum.VT_BSTR"),
......@@ -590,7 +590,7 @@ public class X
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.ByValTStr, SizeConst = 0x20000000)] int ByValArray_e4;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,82): error CS7045: Parameter not valid for the specified unmanaged type.
// [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.ByValTStr, SafeArraySubType = VarEnum.VT_BSTR, SafeArrayUserDefinedSubType = null, SizeConst = -1, SizeParamIndex = -1)]int ByValArray_e1;
Diagnostic(ErrorCode.ERR_ParameterNotValidForType, "SafeArraySubType = VarEnum.VT_BSTR"),
......@@ -756,7 +756,7 @@ public class X
[MarshalAs(UnmanagedType.SafeArray, SafeArrayUserDefinedSubType = typeof(int), SafeArraySubType = 0)] int SafeArray_e7;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,41): error CS7045: Parameter not valid for the specified unmanaged type.
// [MarshalAs(UnmanagedType.SafeArray, ArraySubType = UnmanagedType.ByValTStr, SafeArraySubType = VarEnum.VT_BSTR, SafeArrayUserDefinedSubType = null, SizeConst = -1, SizeParamIndex = -1)] int SafeArray_e1;
Diagnostic(ErrorCode.ERR_ParameterNotValidForType, "ArraySubType = UnmanagedType.ByValTStr"),
......@@ -838,7 +838,7 @@ public class X
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1, SafeArraySubType = VarEnum.VT_BSTR)] int ByValTStr_e7;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (9,41): error CS7045: Parameter not valid for the specified unmanaged type.
// [MarshalAs(UnmanagedType.ByValTStr, ArraySubType = UnmanagedType.ByValTStr, SafeArraySubType = VarEnum.VT_BSTR, SafeArrayUserDefinedSubType = null, SizeConst = -1, SizeParamIndex = -1)] int ByValTStr_e1;
Diagnostic(ErrorCode.ERR_ParameterNotValidForType, "ArraySubType = UnmanagedType.ByValTStr"),
......@@ -966,7 +966,7 @@ public class X
";
// Dev10 encodes incomplete surrogates, we don't.
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,6): error CS7047: Attribute parameter 'MarshalType' or 'MarshalTypeRef' must be specified.
// [MarshalAs(UnmanagedType.CustomMarshaler)]int CustomMarshaler_e0;
Diagnostic(ErrorCode.ERR_AttributeParameterRequired2, "MarshalAs").WithArguments("MarshalType", "MarshalTypeRef"),
......@@ -1251,7 +1251,7 @@ int ByValTStr
public int field;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (7,20): error CS7055: Unmanaged type 'ByValArray' is only valid for fields.
Diagnostic(ErrorCode.ERR_MarshalUnmanagedTypeOnlyValidForFields, "UnmanagedType.ByValArray").WithArguments("ByValArray"),
// (10,20): error CS7055: Unmanaged type 'ByValTStr' is only valid for fields.
......@@ -1334,8 +1334,8 @@ public static void Main()
}
}
";
var comp1 = CreateStandardCompilation(text1, assemblyName: "OptionalMarshalAsLibrary");
var comp2 = CreateStandardCompilation(text2,
var comp1 = CreateCompilation(text1, assemblyName: "OptionalMarshalAsLibrary");
var comp2 = CreateCompilation(text2,
options: TestOptions.ReleaseExe,
references: new[] { comp1.EmitToImageReference() }, // it has to be real assembly, Comp2comp reference OK
assemblyName: "APP");
......
......@@ -120,7 +120,7 @@ namespace System.Runtime.CompilerServices
public class IsReadOnlyAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
class Test
......@@ -147,7 +147,7 @@ namespace System.Runtime.CompilerServices
public class IsReadOnlyAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -156,7 +156,7 @@ public class IsReadOnlyAttribute : System.Attribute { }
public delegate ref readonly int D([IsReadOnly]in int x);
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (4,2): error CS8335: Do not use 'System.Runtime.CompilerServices.IsReadOnlyAttribute'. This is reserved for compiler usage.
// [IsReadOnly]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsReadOnly").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(4, 2),
......@@ -174,7 +174,7 @@ namespace System.Runtime.CompilerServices
public class IsReadOnlyAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -185,7 +185,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (4,2): error CS8335: Do not use 'System.Runtime.CompilerServices.IsReadOnlyAttribute'. This is reserved for compiler usage.
// [IsReadOnly]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsReadOnly").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(4, 2));
......@@ -200,7 +200,7 @@ namespace System.Runtime.CompilerServices
public class IsReadOnlyAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -214,7 +214,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (6,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsReadOnlyAttribute'. This is reserved for compiler usage.
// [IsReadOnly]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsReadOnly").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(6, 6));
......@@ -229,7 +229,7 @@ namespace System.Runtime.CompilerServices
public class IsReadOnlyAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -243,7 +243,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (8,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsReadOnlyAttribute'. This is reserved for compiler usage.
// [IsReadOnly]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsReadOnly").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(8, 6));
......@@ -258,7 +258,7 @@ namespace System.Runtime.CompilerServices
public class IsReadOnlyAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -274,7 +274,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (6,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsReadOnlyAttribute'. This is reserved for compiler usage.
// [IsReadOnly]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsReadOnly").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(6, 6),
......@@ -295,7 +295,7 @@ namespace System.Runtime.CompilerServices
public class IsReadOnlyAttribute : System.Attribute { }
}";
var referenceA = CreateStandardCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var referenceA = CreateCompilation(codeA).VerifyDiagnostics().ToMetadataReference();
var codeB = @"
using System.Runtime.CompilerServices;
......@@ -307,7 +307,7 @@ public class Test
}
";
CreateStandardCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
CreateCompilation(codeB, references: new[] { referenceA }).VerifyDiagnostics(
// (6,6): error CS8335: Do not use 'System.Runtime.CompilerServices.IsReadOnlyAttribute'. This is reserved for compiler usage.
// [IsReadOnly]
Diagnostic(ErrorCode.ERR_ExplicitReservedAttr, "IsReadOnly").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(6, 6),
......@@ -326,7 +326,7 @@ public class Test
ref struct S1{}
}";
CreateStandardCompilation(code).VerifyDiagnostics(
CreateCompilation(code).VerifyDiagnostics(
// (2,2): error CS0246: The type or namespace name 'IsReadOnlyAttribute' could not be found (are you missing a using directive or an assembly reference?)
// [IsReadOnly]
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "IsReadOnly").WithArguments("IsReadOnlyAttribute").WithLocation(2, 2),
......@@ -341,13 +341,13 @@ public void TypeReferencingAnotherTypeThatUsesAPublicIsReadOnlyAttributeFromAThi
{
var options = TestOptions.DebugDll.WithMetadataImportOptions(MetadataImportOptions.All);
var code1 = CreateStandardCompilation(@"
var code1 = CreateCompilation(@"
namespace System.Runtime.CompilerServices
{
public class IsReadOnlyAttribute : System.Attribute { }
}");
var code2 = CreateStandardCompilation(@"
var code2 = CreateCompilation(@"
public class Test1
{
public readonly struct S1{}
......@@ -360,7 +360,7 @@ public class Test1
Assert.Null(module.ContainingAssembly.GetTypeByMetadataName(isReadOnlyAttributeName));
});
var code3 = CreateStandardCompilation(@"
var code3 = CreateCompilation(@"
public class Test2
{
public readonly struct S1{}
......@@ -381,7 +381,7 @@ public void BuildingAModuleRequiresIsReadOnlyAttributeToBeThere_Missing_SourceMe
public readonly struct S1{}
";
CreateStandardCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
CreateCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
// (2,19): error CS0518: Predefined type 'System.Runtime.CompilerServices.IsReadOnlyAttribute' is not defined or imported
// public readonly struct S1{}
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "S1").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(2, 24)
......@@ -398,7 +398,7 @@ public class Test
public readonly struct S2{}
}";
CreateStandardCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
CreateCompilation(code, options: TestOptions.ReleaseModule).VerifyDiagnostics(
// (5,23): error CS0518: Predefined type 'System.Runtime.CompilerServices.IsReadOnlyAttribute' is not defined or imported
// public readonly struct S2{}
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "S2").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute").WithLocation(5, 28),
......@@ -411,7 +411,7 @@ public class Test
[Fact]
public void BuildingAModuleRequiresIsReadOnlyAttributeToBeThere_InAReference()
{
var reference = CreateStandardCompilation(@"
var reference = CreateCompilation(@"
namespace System.Runtime.CompilerServices
{
public class IsReadOnlyAttribute : System.Attribute { }
......@@ -499,7 +499,7 @@ class Test
public readonly struct S1{}
}";
CreateStandardCompilation(text, options: TestOptions.ReleaseModule).VerifyDiagnostics(
CreateCompilation(text, options: TestOptions.ReleaseModule).VerifyDiagnostics(
// (11,23): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsReadOnlyAttribute..ctor'
// public readonly struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute", ".ctor").WithLocation(11, 28)
......@@ -522,7 +522,7 @@ class Test
public readonly struct S1{}
}";
CreateStandardCompilation(text).VerifyEmitDiagnostics(
CreateCompilation(text).VerifyEmitDiagnostics(
// (11,22): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsReadOnlyAttribute..ctor'
// public readonly struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute", ".ctor").WithLocation(11, 27)
......@@ -545,7 +545,7 @@ class Test
public readonly struct S1{}
}";
CreateStandardCompilation(text).VerifyEmitDiagnostics(
CreateCompilation(text).VerifyEmitDiagnostics(
// (11,23): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsReadOnlyAttribute..ctor'
// public readonly struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute", ".ctor").WithLocation(11, 28)
......@@ -555,7 +555,7 @@ class Test
[Fact]
public void IsReadOnlyAttributesInNoPia()
{
var comAssembly = CreateStandardCompilation(@"
var comAssembly = CreateCompilation(@"
using System;
using System.Runtime.InteropServices;
[assembly: ImportedFromTypeLib(""test.dll"")]
......@@ -592,10 +592,10 @@ public void M(Test p)
var options = TestOptions.DebugDll.WithMetadataImportOptions(MetadataImportOptions.All);
var compilation_CompilationReference = CreateStandardCompilation(code, options: options, references: new[] { comAssembly.ToMetadataReference(embedInteropTypes: true) });
var compilation_CompilationReference = CreateCompilation(code, options: options, references: new[] { comAssembly.ToMetadataReference(embedInteropTypes: true) });
CompileAndVerify(compilation_CompilationReference, symbolValidator: symbolValidator);
var compilation_BinaryReference = CreateStandardCompilation(code, options: options, references: new[] { comAssembly.EmitToImageReference(embedInteropTypes: true) });
var compilation_BinaryReference = CreateCompilation(code, options: options, references: new[] { comAssembly.EmitToImageReference(embedInteropTypes: true) });
CompileAndVerify(compilation_BinaryReference, symbolValidator: symbolValidator);
void symbolValidator(ModuleSymbol module)
......@@ -627,7 +627,7 @@ public class Test
public readonly struct S1{}
}";
CreateStandardCompilation(text).VerifyEmitDiagnostics(
CreateCompilation(text).VerifyEmitDiagnostics(
// (11,23): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsReadOnlyAttribute..ctor'
// public readonly struct S1{}
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "S1").WithArguments("System.Runtime.CompilerServices.IsReadOnlyAttribute", ".ctor").WithLocation(11, 28)
......
......@@ -96,7 +96,7 @@ static void Main(string[] args)
{
}
}";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (9,26): warning CS0618: 'System.Security.Permissions.SecurityAction.Deny' is obsolete: 'Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'
// [PrincipalPermission(SecurityAction.Deny)]
Diagnostic(ErrorCode.WRN_DeprecatedSymbolStr, "SecurityAction.Deny").WithArguments("System.Security.Permissions.SecurityAction.Deny", "Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information."),
......@@ -135,7 +135,7 @@ class MySecurityAttribute : CodeAccessSecurityAttribute
[MySecurityAttribute(a1: SecurityAction.Assert, x: 0)]
public class C {}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (15,2): error CS7048: First argument to a security attribute must be a valid SecurityAction
// [MySecurityAttribute()]
Diagnostic(ErrorCode.ERR_SecurityAttributeMissingAction, "MySecurityAttribute"),
......@@ -178,7 +178,7 @@ public class C
public int x;
}
}";
var compilation = CreateStandardCompilation(source);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(
// (9,6): error CS7036: There is no argument given that corresponds to the required formal parameter 'action' of 'System.Security.Permissions.PrincipalPermissionAttribute.PrincipalPermissionAttribute(System.Security.Permissions.SecurityAction)'
// [PrincipalPermission()] // Invalid attribute constructor
......@@ -222,7 +222,7 @@ public class C
public int x;
}
}";
var compilation = CreateStandardCompilation(source);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(
// (12,26): error CS7049: Security attribute 'MySecurityAttribute' has an invalid SecurityAction value '(SecurityAction)0'
// [MySecurityAttribute((SecurityAction)0)] // Invalid attribute argument
......@@ -312,7 +312,7 @@ class MyCodeAccessSecurityAttribute : CodeAccessSecurityAttribute
public override IPermission CreatePermission() { return null; }
public static void Main() {}
}";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,32): warning CS0618: 'System.Security.Permissions.SecurityAction.Deny' is obsolete: 'Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'
// [assembly: MySecurityAttribute(SecurityAction.Deny)]
Diagnostic(ErrorCode.WRN_DeprecatedSymbolStr, "SecurityAction.Deny").WithArguments("System.Security.Permissions.SecurityAction.Deny", "Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information."),
......@@ -456,7 +456,7 @@ class Test
[MyCodeAccessSecurityAttribute(SecurityAction.RequestRefuse)]
public static void Main() {}
}";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (17,22): warning CS0618: 'System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'
// [MySecurityAttribute(SecurityAction.RequestMinimum)]
Diagnostic(ErrorCode.WRN_DeprecatedSymbolStr, "SecurityAction.RequestMinimum").WithArguments("System.Security.Permissions.SecurityAction.RequestMinimum", "Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information."),
......@@ -558,7 +558,7 @@ public override IPermission CreatePermission()
return null;
}
}";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (8,6): error CS7070: Security attribute 'MyPermission' is not valid on this declaration type. Security attributes are only valid on assembly, type and method declarations.
// [MyPermission(SecurityAction.Demand)]
Diagnostic(ErrorCode.ERR_SecurityAttributeInvalidTarget, "MyPermission").WithArguments("MyPermission"));
......@@ -661,7 +661,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll, assemblyName: "Test");
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll, assemblyName: "Test");
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -714,7 +714,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -754,7 +754,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -807,7 +807,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -859,7 +859,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -919,7 +919,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -985,7 +985,7 @@ public class C2
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -1047,7 +1047,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
CompileAndVerify(compilation, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -1110,7 +1110,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.ReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.ReleaseDll);
compilation.VerifyDiagnostics(
// (4,31): warning CS0618: 'System.Security.Permissions.SecurityAction.RequestOptional' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'
......@@ -1213,7 +1213,7 @@ public class C
}
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.UnsafeReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.UnsafeReleaseDll);
CompileAndVerify(compilation, verify: Verification.Passes,symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -1293,7 +1293,7 @@ public class C
}
";
var compilation = CreateStandardCompilation(source, options: TestOptions.UnsafeReleaseDll);
var compilation = CreateCompilation(source, options: TestOptions.UnsafeReleaseDll);
CompileAndVerify(compilation, verify: Verification.Passes, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
......@@ -1460,7 +1460,7 @@ public void CS7056ERR_PermissionSetAttributeInvalidFile()
public class MyClass
{
}";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (4,25): warning CS0618: 'System.Security.Permissions.SecurityAction.Deny' is obsolete: 'Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'
// [PermissionSetAttribute(SecurityAction.Deny, File = @"NonExistentFile.xml")]
Diagnostic(ErrorCode.WRN_DeprecatedSymbolStr, "SecurityAction.Deny").WithArguments("System.Security.Permissions.SecurityAction.Deny", "Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information."),
......@@ -1553,7 +1553,7 @@ public A(params SecurityAction a)
{
}
}";
CreateStandardCompilation(source).GetDiagnostics();
CreateCompilation(source).GetDiagnostics();
}
[Fact]
......@@ -1571,7 +1571,7 @@ public A(SecurityAction a = 0) : base(a)
{
}
}";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (4,2): error CS7049: Security attribute 'A' has an invalid SecurityAction value '0'
// [A]
Diagnostic(ErrorCode.ERR_SecurityAttributeInvalidAction, "A").WithArguments("A", "0").WithLocation(4, 2),
......
......@@ -232,7 +232,7 @@ public void Pack_Errors()
[StructLayout(LayoutKind.Sequential, Size = 1, Pack = 512 )] class P512 {}
[StructLayout(LayoutKind.Sequential, Size = 1, Pack = Int32.MaxValue )] class PMax {}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (5,48): error CS0599: Invalid value for named attribute argument 'Pack'
Diagnostic(ErrorCode.ERR_InvalidNamedArgument, "Pack = -1").WithArguments("Pack"),
// (6,48): error CS0599: Invalid value for named attribute argument 'Pack'
......@@ -257,7 +257,7 @@ public void Size_Errors()
[StructLayout(LayoutKind.Sequential, Size = -1)] class S {}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (4,38): error CS0599: Invalid value for named attribute argument 'Size'
Diagnostic(ErrorCode.ERR_InvalidNamedArgument, "Size = -1").WithArguments("Size"));
}
......@@ -284,7 +284,7 @@ public class C4 { }
[StructLayout(LayoutKind.Sequential, CharSet = (CharSet)Int32.MaxValue)]
public class C5 { }
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (5,15): error CS0591: Invalid value for argument to 'StructLayout' attribute
Diagnostic(ErrorCode.ERR_InvalidAttributeArgument, "(LayoutKind)(-1)").WithArguments("StructLayout"),
// (8,15): error CS0591: Invalid value for argument to 'StructLayout' attribute
......@@ -443,7 +443,7 @@ enum En
A = 1
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (7,6): error CS0636: The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)
Diagnostic(ErrorCode.ERR_StructOffsetOnBadStruct, "FieldOffset"),
// (14,6): error CS0636: The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)
......@@ -517,7 +517,7 @@ partial struct S
public int x;
}
";
CreateStandardCompilation(source).VerifyDiagnostics(
CreateCompilation(source).VerifyDiagnostics(
// (5,15): warning CS0282: There is no defined ordering between fields in multiple declarations of partial struct 'C'. To specify an ordering, all instance fields must be in the same declaration.
Diagnostic(ErrorCode.WRN_SequentialOnPartialClass, "C").WithArguments("C"));
}
......@@ -538,7 +538,7 @@ partial struct C
{
public int y;
}";
CreateStandardCompilation(source).VerifyDiagnostics();
CreateCompilation(source).VerifyDiagnostics();
}
[Fact]
......
......@@ -116,7 +116,7 @@ class C
int[] a = new[] { 1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9, };
}
";
var reference = CreateStandardCompilation(source).EmitToImageReference();
var reference = CreateCompilation(source).EmitToImageReference();
var comp = CreateCompilationRaw("", new[] { reference }, options: TestOptions.ReleaseDll.WithMetadataImportOptions(MetadataImportOptions.Internal));
......@@ -138,7 +138,7 @@ unsafe struct S
public fixed char C[5];
}
";
var reference = CreateStandardCompilation(source, options: TestOptions.UnsafeReleaseDll).EmitToImageReference();
var reference = CreateCompilation(source, options: TestOptions.UnsafeReleaseDll).EmitToImageReference();
var comp = CreateCompilationRaw("", new[] { reference }, options: TestOptions.UnsafeReleaseDll.WithMetadataImportOptions(MetadataImportOptions.Internal));
var s = (NamedTypeSymbol)comp.GlobalNamespace.GetMembers("S").Single();
......@@ -258,7 +258,7 @@ void Goo()
.WithOptimizationLevel(optimizationLevel)
.WithMetadataImportOptions(MetadataImportOptions.All);
CompileAndVerify(CreateStandardCompilation(source, options: options), symbolValidator: m =>
CompileAndVerify(CreateCompilation(source, options: options), symbolValidator: m =>
{
var displayClass = m.GlobalNamespace.GetMember<NamedTypeSymbol>("C.<>c__DisplayClass0_0");
AssertEx.SetEqual(new[] { "CompilerGeneratedAttribute" }, GetAttributeNames(displayClass.GetAttributes()));
......@@ -287,7 +287,7 @@ void Goo()
.WithOptimizationLevel(optimizationLevel)
.WithMetadataImportOptions(MetadataImportOptions.All);
CompileAndVerify(CreateStandardCompilation(source, options: options), symbolValidator: m =>
CompileAndVerify(CreateCompilation(source, options: options), symbolValidator: m =>
{
var anon = m.ContainingAssembly.GetTypeByMetadataName("<>f__AnonymousType0`2");
......@@ -368,7 +368,7 @@ public void Goo()
}
}
";
var comp = CreateStandardCompilation(source, options: TestOptions.DebugDll);
var comp = CreateCompilation(source, options: TestOptions.DebugDll);
CompileAndVerify(comp, symbolValidator: m =>
{
......@@ -426,7 +426,7 @@ public IEnumerable<int> Iterator()
.WithOptimizationLevel(optimizationLevel)
.WithMetadataImportOptions(MetadataImportOptions.All);
CompileAndVerify(CreateStandardCompilation(source, options: options), symbolValidator: module =>
CompileAndVerify(CreateCompilation(source, options: options), symbolValidator: module =>
{
var iter = module.ContainingAssembly.GetTypeByMetadataName("C+<Iterator>d__0");
AssertEx.SetEqual(new[] { "CompilerGeneratedAttribute" }, GetAttributeNames(iter.GetAttributes()));
......@@ -878,7 +878,7 @@ public static void Main()
}";
var options = new CSharpCompilationOptions(outputKind, optimizationLevel: optimizationLevel);
var compilation = CreateStandardCompilation(code, options: options);
var compilation = CreateCompilation(code, options: options);
CompileAndVerify(compilation, verify: outputKind.IsNetModule() ? Verification.Skipped : Verification.Passes, symbolValidator: module =>
{
......@@ -927,7 +927,7 @@ public static void Main()
}";
var options = new CSharpCompilationOptions(outputKind, optimizationLevel: optimizationLevel);
var compilation = CreateStandardCompilation(code, options: options);
var compilation = CreateCompilation(code, options: options);
CompileAndVerify(compilation, verify: outputKind.IsNetModule() ? Verification.Skipped : Verification.Passes, symbolValidator: module =>
{
......@@ -974,7 +974,7 @@ public static void Main()
}";
var options = new CSharpCompilationOptions(outputKind, optimizationLevel: optimizationLevel);
var compilation = CreateStandardCompilation(code, options: options);
var compilation = CreateCompilation(code, options: options);
CompileAndVerify(compilation, verify: outputKind.IsNetModule() ? Verification.Skipped : Verification.Passes, symbolValidator: module =>
{
......@@ -1018,7 +1018,7 @@ public static void Main()
}";
var options = new CSharpCompilationOptions(outputKind, optimizationLevel: optimizationLevel);
var compilation = CreateStandardCompilation(code, options: options);
var compilation = CreateCompilation(code, options: options);
CompileAndVerify(compilation, verify: outputKind.IsNetModule() ? Verification.Skipped : Verification.Passes, symbolValidator: module =>
{
......@@ -1061,7 +1061,7 @@ public static void Main()
}
}";
var options = new CSharpCompilationOptions(outputKind, optimizationLevel: optimizationLevel);
var compilation = CreateStandardCompilation(source, options: options);
var compilation = CreateCompilation(source, options: options);
if (outputKind.IsNetModule())
{
......@@ -1087,7 +1087,7 @@ public static void Main()
[MemberData(nameof(FullMatrixTheoryData))]
public void AppliedCompilationRelaxationsOnModuleSupressesAssemblyAttributes(OutputKind outputKind, OptimizationLevel optimizationLevel)
{
var referenceComp = CreateStandardCompilation(@"
var referenceComp = CreateCompilation(@"
using System.Runtime.CompilerServices;
[assembly: CompilationRelaxationsAttribute(0)]
......@@ -1128,7 +1128,7 @@ public static void Main()
[MemberData(nameof(FullMatrixTheoryData))]
public void AppliedRuntimeCompatibilityOnModuleSupressesAssemblyAttributes(OutputKind outputKind, OptimizationLevel optimizationLevel)
{
var referenceComp = CreateStandardCompilation(@"
var referenceComp = CreateCompilation(@"
using System.Runtime.CompilerServices;
[assembly: RuntimeCompatibilityAttribute()]
......@@ -1180,7 +1180,7 @@ public static void Main()
}
}";
var compilation = CreateStandardCompilation(source, options: new CSharpCompilationOptions(
var compilation = CreateCompilation(source, options: new CSharpCompilationOptions(
outputKind: outputKind,
optimizationLevel: OptimizationLevel.Release,
allowUnsafe: true));
......
......@@ -113,7 +113,7 @@ public void ExceptionInReadAllBytes()
.WithStrongNameProvider(provider)
.WithCryptoKeyFile(keyFile);
var comp = CreateStandardCompilation(src, options: options);
var comp = CreateCompilation(src, options: options);
comp.VerifyEmitDiagnostics(
// error CS7027: Error signing output with public key from file '{0}' -- '{1}'
Diagnostic(ErrorCode.ERR_PublicKeyFileFailure).WithArguments(keyFile, ex.Message).WithLocation(1, 1));
......@@ -134,7 +134,7 @@ public void ExceptionInReadKeysFromContainer()
.WithStrongNameProvider(provider)
.WithCryptoKeyContainer("RoslynTestContainer");
var comp = CreateStandardCompilation(src, options: options);
var comp = CreateCompilation(src, options: options);
comp.VerifyEmitDiagnostics(
// error CS7028: Error signing output with public key from container 'RoslynTestContainer' -- Crazy exception you could never have predicted!
Diagnostic(ErrorCode.ERR_PublicKeyContainerFailure).WithArguments("RoslynTestContainer", ex.Message).WithLocation(1, 1));
......@@ -153,7 +153,7 @@ class C
.WithStrongNameProvider(testProvider)
.WithCryptoKeyContainer("RoslynTestContainer");
var comp = CreateStandardCompilation(src, options: options);
var comp = CreateCompilation(src, options: options);
comp.Emit(new MemoryStream()).Diagnostics.Verify(
// error CS8104: An error occurred while writing the Portable Executable file.
......
......@@ -456,7 +456,7 @@ StringBuilder GetClassStart()
}
methodsText.AppendLine("\r\n}");
CreateStandardCompilation(methodsText.ToString()).VerifyEmitDiagnostics();
CreateCompilation(methodsText.ToString()).VerifyEmitDiagnostics();
});
}
}
......
......@@ -1982,7 +1982,7 @@ static void Main()
}
}
";
var comp = CreateStandardCompilation(source);
var comp = CreateCompilation(source);
comp.VerifyDiagnostics(
// (7,13): error CS0220: The operation overflows at compile time in checked mode
// r = int.MaxValue + 1;
......@@ -2114,7 +2114,7 @@ static void Main()
}
}
";
var comp = CreateStandardCompilation(source);
var comp = CreateCompilation(source);
comp.VerifyDiagnostics(
// (9,81): error CS0220: The operation overflows at compile time in checked mode
// d1 = unchecked(delegate (int i) { r1 = int.MaxValue + 1; return checked(int.MaxValue + 1); });
......@@ -2152,7 +2152,7 @@ void F()
var r1 = decimal.MaxValue + 1;
}
}";
var comp = CreateStandardCompilation(source);
var comp = CreateCompilation(source);
comp.VerifyDiagnostics(
// (6,25): error CS0463: Evaluation of the decimal constant expression failed
// var r = checked(decimal.MaxValue + 1);
......
......@@ -4160,7 +4160,7 @@ public static void Main()
}
";
CreateStandardCompilation(source).VerifyEmitDiagnostics(
CreateCompilation(source).VerifyEmitDiagnostics(
// error CS7013: Name '<Lambda.Bugs.I<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass>.NestedClass>.NestedClass>.Goo>b__0' exceeds the maximum length allowed in metadata.
Diagnostic(ErrorCode.ERR_MetadataNameTooLong).WithArguments("<Lambda.Bugs.I<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass>.NestedClass>.NestedClass>.Goo>b__0").WithLocation(1, 1),
// (17,81): error CS7013: Name 'Lambda.Bugs.I<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass,Lambda.Bugs.OuterGenericClass<Lambda.Bugs.OuterGenericClass<T,S>.NestedClass,Lambda.Bugs.OuterGenericClass<T,S>.NestedClass>.NestedClass>.NestedClass>.NestedClass>.NestedClass>.Goo' exceeds the maximum length allowed in metadata.
......
......@@ -124,7 +124,7 @@ string Method(int x)
}
}
";
var comp = CreateStandardCompilation(source);
var comp = CreateCompilation(source);
comp.VerifyDiagnostics();
CompileAndVerify(comp);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册