Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise the default warning level in tests #47077

Merged
merged 43 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
af25f47
Raise the default warning level in tests
Youssef1313 Aug 23, 2020
7faffae
Update CompilationWithAnalyzersTests.cs
Youssef1313 Aug 23, 2020
d77232d
Update MetadataMemberTests.cs
Youssef1313 Aug 23, 2020
dd454c4
Update CSharpDeterministicBuildCompilationTests.cs
Youssef1313 Aug 23, 2020
a80d03e
Update AssemblyAndNamespaceTests.cs
Youssef1313 Aug 23, 2020
ceed1f8
Update MetadataMemberTests.cs
Youssef1313 Aug 23, 2020
afc64be
Update CompilationWithAnalyzersTests.cs
Youssef1313 Aug 23, 2020
f0950fc
More updates
Youssef1313 Aug 24, 2020
f2114f2
Update MetadataMemberTests.cs
Youssef1313 Aug 24, 2020
54b0c34
Update AssemblyAndNamespaceTests.cs
Youssef1313 Aug 24, 2020
368a08f
Update AssemblyAndNamespaceTests.cs
Youssef1313 Aug 24, 2020
49709b9
Update MetadataMemberTests.cs
Youssef1313 Aug 24, 2020
d773bed
More work
Youssef1313 Aug 24, 2020
bc9d1c0
More
Youssef1313 Aug 24, 2020
39c9106
More
Youssef1313 Aug 24, 2020
f5a4770
Update InterpolationTests.cs
Youssef1313 Aug 24, 2020
2ce9c1e
More fixes
Youssef1313 Aug 26, 2020
ef5af4b
More fixes
Youssef1313 Aug 26, 2020
4a422d8
Remove field
Youssef1313 Aug 26, 2020
248daa8
Fix WarningVersionTests by explicitly using DefaultWarningLevel when …
Youssef1313 Aug 28, 2020
99783b0
Fix Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests + One TODO
Youssef1313 Aug 28, 2020
a94ec22
TODO in NameCollisionTests.TestCollisionInsideFor2
Youssef1313 Aug 28, 2020
d469c4f
Fix a few more tests
Youssef1313 Sep 4, 2020
5ea9ff7
Address feedback
Youssef1313 Sep 5, 2020
55141e6
Fix an unintentional mistake
Youssef1313 Sep 5, 2020
8704b06
Apply suggestions from code review
Youssef1313 Sep 5, 2020
df16740
Fix TestCollisionInsideFor2
Youssef1313 Sep 5, 2020
a56b3e2
Add WRN_SyncAndAsyncEntryPoints to expected diagnostics
Youssef1313 Sep 5, 2020
0b5bac7
Add WRN_SyncAndAsyncEntryPoints to expected diagnostics
Youssef1313 Sep 5, 2020
42af28b
Update src/Compilers/CSharp/Test/Emit/PDB/CSharpDeterministicBuildCom…
Youssef1313 Sep 14, 2020
073cabe
Merge branch 'master' into patch-19
Youssef1313 Sep 14, 2020
90a91ea
Update CodeGenAsyncMainTests.cs
Youssef1313 Sep 14, 2020
2a0d753
Update SymbolErrorTests.cs
Youssef1313 Sep 17, 2020
157b655
Update CodeGenFunctionPointersTests.cs
Youssef1313 Sep 17, 2020
dc816b2
Update TopLevelStatementsTests.cs
Youssef1313 Sep 17, 2020
ff7d2ec
Fix more tests
Youssef1313 Sep 17, 2020
80ada6c
Merge branch 'master' into patch-19
Youssef1313 Sep 17, 2020
133d393
Remove ReleaseDllWithWarningLevel5 field
Youssef1313 Sep 17, 2020
7815651
Update SymbolErrorTests.cs
Youssef1313 Sep 18, 2020
d9f2349
Merge branch 'master' into patch-19
Youssef1313 Oct 3, 2020
b487ff8
Update InterpolationTests.cs
Youssef1313 Oct 5, 2020
79a7027
Update SymbolErrorTests.cs
Youssef1313 Oct 5, 2020
fbbf3c7
Merge branch 'master' of github.com:dotnet/roslyn into patch-19
RikkiGibson Oct 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2481,7 +2481,8 @@ public void Optimize()
{
var parsedArgs = DefaultParse(new[] { "a.cs" }, WorkingDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(new CSharpCompilationOptions(OutputKind.ConsoleApplication).OptimizationLevel, parsedArgs.CompilationOptions.OptimizationLevel);
// TODO: I think the test is more clear with the old approach (explicitly creating CSharpCompilationOptions). What do you think?
Assert.Equal(TestOptions.DebugExe.OptimizationLevel, parsedArgs.CompilationOptions.OptimizationLevel);

parsedArgs = DefaultParse(new[] { "/optimize-", "a.cs" }, WorkingDirectory);
parsedArgs.Errors.Verify();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class Test<T> where T : unmanaged
{
}";

CreateCompilation(text, options: new CSharpCompilationOptions(outputKind)).VerifyDiagnostics(
CreateCompilation(text, options: TestOptions.DebugDll.WithOutputKind(outputKind)).VerifyDiagnostics(
// (9,12): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsUnmanagedAttribute..ctor'
// class Test<T> where T : unmanaged
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "T").WithArguments("System.Runtime.CompilerServices.IsUnmanagedAttribute", ".ctor").WithLocation(9, 12));
Expand All @@ -790,7 +790,7 @@ class Test<T> where T : unmanaged
{
}";

CreateCompilation(text, options: new CSharpCompilationOptions(outputKind)).VerifyDiagnostics(
CreateCompilation(text, options: TestOptions.DebugDll.WithOutputKind(outputKind)).VerifyDiagnostics(
// (9,12): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsUnmanagedAttribute..ctor'
// class Test<T> where T : unmanaged
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "T").WithArguments("System.Runtime.CompilerServices.IsUnmanagedAttribute", ".ctor").WithLocation(9, 12));
Expand All @@ -810,7 +810,7 @@ class Test<T> where T : unmanaged
{
}";

CreateCompilation(text, options: new CSharpCompilationOptions(outputKind)).VerifyDiagnostics(
CreateCompilation(text, options: TestOptions.DebugDll.WithOutputKind(outputKind)).VerifyDiagnostics(
// (6,12): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IsUnmanagedAttribute..ctor'
// class Test<T> where T : unmanaged
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "T").WithArguments("System.Runtime.CompilerServices.IsUnmanagedAttribute", ".ctor").WithLocation(6, 12));
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2623,7 +2623,7 @@ public void Bug1095618(CSharpParseOptions parseOptions)
[MemberData(nameof(AllProviderParseOptions))]
public void ConsistentErrorMessageWhenProvidingNullKeyFile(CSharpParseOptions parseOptions)
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoKeyFile: null);
var options = TestOptions.DebugDll;
var compilation = CreateCompilation(string.Empty, options: options, parseOptions: parseOptions).VerifyDiagnostics();

VerifySignedBitSetAfterEmit(compilation, expectedToBeSigned: false);
Expand All @@ -2634,7 +2634,7 @@ public void ConsistentErrorMessageWhenProvidingNullKeyFile(CSharpParseOptions pa
[MemberData(nameof(AllProviderParseOptions))]
public void ConsistentErrorMessageWhenProvidingEmptyKeyFile(CSharpParseOptions parseOptions)
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoKeyFile: string.Empty);
var options = TestOptions.DebugDll.WithCryptoKeyFile(string.Empty);
var compilation = CreateCompilation(string.Empty, options: options, parseOptions: parseOptions).VerifyDiagnostics();

VerifySignedBitSetAfterEmit(compilation, expectedToBeSigned: false);
Expand All @@ -2645,7 +2645,7 @@ public void ConsistentErrorMessageWhenProvidingEmptyKeyFile(CSharpParseOptions p
[MemberData(nameof(AllProviderParseOptions))]
public void ConsistentErrorMessageWhenProvidingNullKeyFile_PublicSign(CSharpParseOptions parseOptions)
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoKeyFile: null, publicSign: true);
var options = TestOptions.DebugDll.WithPublicSign(true);
CreateCompilation(string.Empty, options: options, parseOptions: parseOptions).VerifyDiagnostics(
// error CS8102: Public signing was specified and requires a public key, but no public key was specified.
Diagnostic(ErrorCode.ERR_PublicSignButNoKey).WithLocation(1, 1));
Expand All @@ -2656,7 +2656,7 @@ public void ConsistentErrorMessageWhenProvidingNullKeyFile_PublicSign(CSharpPars
[MemberData(nameof(AllProviderParseOptions))]
public void ConsistentErrorMessageWhenProvidingEmptyKeyFile_PublicSign(CSharpParseOptions parseOptions)
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoKeyFile: string.Empty, publicSign: true);
var options = TestOptions.DebugDll.WithCryptoKeyFile(string.Empty).WithPublicSign(true);
CreateCompilation(string.Empty, options: options, parseOptions: parseOptions).VerifyDiagnostics(
// error CS8102: Public signing was specified and requires a public key, but no public key was specified.
Diagnostic(ErrorCode.ERR_PublicSignButNoKey).WithLocation(1, 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void Main()
}
}
}";
var compilation = CompileAndVerify(source, expectedOutput: @"3", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel: OptimizationLevel.Release));
var compilation = CompileAndVerify(source, expectedOutput: @"3", options: TestOptions.ReleaseExe);

VerifyTypeIL(compilation, "Program", @"
.class public auto ansi abstract sealed beforefieldinit Program
Expand Down Expand Up @@ -124,7 +124,7 @@ public static void Main()
}
}
}";
var compilation = CompileAndVerify(source, expectedOutput: @"3", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel: OptimizationLevel.Debug));
var compilation = CompileAndVerify(source, expectedOutput: @"3", options: TestOptions.DebugExe);

VerifyTypeIL(compilation, "Program", @"
.class public auto ansi abstract sealed beforefieldinit Program
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27053,7 +27053,7 @@ public static string GetFromExternal()
}
}
";
var compilation = CreateCompilationWithMscorlib45(source, null, new CSharpCompilationOptions(OutputKind.ConsoleApplication).WithAllowUnsafe(true));
var compilation = CreateCompilationWithMscorlib45(source, null, TestOptions.UnsafeDebugExe);
CompileAndVerify(compilation, expectedOutput:
"MessageType x MessageType").VerifyDiagnostics();
}
Expand Down
16 changes: 8 additions & 8 deletions src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3211,7 +3211,7 @@ public static void Main()
}
}";
var compilation = CreateCompilation(source,
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithPlatform(Platform.X86));
options: TestOptions.DebugDll.WithPlatform(Platform.X86));

var peHeaders = new PEHeaders(compilation.EmitToStream());

Expand Down Expand Up @@ -3245,7 +3245,7 @@ public static void Main()
}
}";
var compilation = CreateCompilation(source,
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithPlatform(Platform.X64));
options: TestOptions.DebugDll.WithPlatform(Platform.X64));

var peHeaders = new PEHeaders(compilation.EmitToStream());

Expand Down Expand Up @@ -3295,7 +3295,7 @@ public static void Main()
}
}";
var compilation = CreateCompilation(source,
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithPlatform(Platform.Arm));
options: TestOptions.DebugDll.WithPlatform(Platform.Arm));

var peHeaders = new PEHeaders(compilation.EmitToStream());

Expand Down Expand Up @@ -3426,7 +3426,7 @@ public static void Main()
{
}
}";
var compilation = CreateCompilation(source, options: new CSharpCompilationOptions(OutputKind.WindowsRuntimeApplication));
var compilation = CreateCompilation(source, options: TestOptions.DebugWindowsRuntimeApp);
var peHeaders = new PEHeaders(compilation.EmitToStream());

//interesting COFF bits
Expand Down Expand Up @@ -5244,15 +5244,15 @@ public void CompileAndVerifyModuleIncludesAllModules()
[WorkItem(37779, "https://github.com/dotnet/roslyn/issues/37779")]
public void WarnAsErrorDoesNotEmit_GeneralDiagnosticOption()
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, generalDiagnosticOption: ReportDiagnostic.Error);
var options = TestOptions.DebugDll.WithGeneralDiagnosticOption(ReportDiagnostic.Error);
TestWarnAsErrorDoesNotEmitCore(options);
}

[Fact]
[WorkItem(37779, "https://github.com/dotnet/roslyn/issues/37779")]
public void WarnAsErrorDoesNotEmit_SpecificDiagnosticOption()
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithSpecificDiagnosticOptions("CS0169", ReportDiagnostic.Error);
var options = TestOptions.DebugDll.WithSpecificDiagnosticOptions("CS0169", ReportDiagnostic.Error);
TestWarnAsErrorDoesNotEmitCore(options);
}

Expand Down Expand Up @@ -5289,15 +5289,15 @@ class X
[WorkItem(37779, "https://github.com/dotnet/roslyn/issues/37779")]
public void WarnAsErrorWithMetadataOnlyImageDoesEmit_GeneralDiagnosticOption()
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, generalDiagnosticOption: ReportDiagnostic.Error);
var options = TestOptions.DebugDll.WithGeneralDiagnosticOption(ReportDiagnostic.Error);
TestWarnAsErrorWithMetadataOnlyImageDoesEmitCore(options);
}

[Fact]
[WorkItem(37779, "https://github.com/dotnet/roslyn/issues/37779")]
public void WarnAsErrorWithMetadataOnlyImageDoesEmit_SpecificDiagnosticOptions()
{
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithSpecificDiagnosticOptions("CS0612", ReportDiagnostic.Error);
var options = TestOptions.DebugDll.WithSpecificDiagnosticOptions("CS0612", ReportDiagnostic.Error);
TestWarnAsErrorWithMetadataOnlyImageDoesEmitCore(options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Test/Emit/Emit/DeterministicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public void TestWriteOnlyStream()
var compilation = CSharpCompilation.Create("Program",
new[] { tree },
new[] { MetadataReference.CreateFromAssemblyInternal(typeof(object).Assembly) },
new CSharpCompilationOptions(OutputKind.ConsoleApplication).WithDeterministic(true));
TestOptions.DebugExe.WithDeterministic(true));
var output = new WriteOnlyStream();
compilation.Emit(output);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void M2() {
var source = builder.ToString();
RunInThread(() =>
{
var options = new CSharpCompilationOptions(outputKind: OutputKind.DynamicallyLinkedLibrary, concurrentBuild: false);
var options = TestOptions.DebugDll.WithConcurrentBuild(false);
var compilation = CreateCompilation(source, options: options);
compilation.VerifyDiagnostics();
compilation.EmitToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static IEnumerable<CSharpCompilationOptions> GetCompilationOptions()
delaySign: null,
platform: Platform.AnyCpu,
generalDiagnosticOption: ReportDiagnostic.Default,
warningLevel: 4,
warningLevel: 5,
specificDiagnosticOptions: null,
concurrentBuild: true,
deterministic: true,
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Test/Semantic/Semantics/ArglistTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ static void Main()
Console.WriteLine(a);
}
}",
options: new CSharpCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel: OptimizationLevel.Debug),
options: TestOptions.DebugExe,
expectedOutput: "5");
}

Expand All @@ -1655,7 +1655,7 @@ static void Main()
Test(__arglist(a));
}
}",
options: new CSharpCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel: OptimizationLevel.Debug),
options: TestOptions.DebugExe,
expectedOutput: "5");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ public static void Main()
}
}
}";
CreateEmptyCompilation(text, options: new CSharpCompilationOptions(OutputKind.ConsoleApplication))
CreateEmptyCompilation(text, options: TestOptions.DebugExe)
.VerifyEmitDiagnostics(new CodeAnalysis.Emit.EmitOptions(runtimeMetadataVersion: "x.y"),
// (15,21): error CS0117: 'string' does not contain a definition for 'Format'
// var s = $"X = { 1 } ";
Expand Down Expand Up @@ -957,7 +957,7 @@ public static void Main()
}
}
}";
CreateEmptyCompilation(text, options: new CSharpCompilationOptions(OutputKind.ConsoleApplication))
CreateEmptyCompilation(text, options: TestOptions.DebugExe)
.VerifyEmitDiagnostics(new CodeAnalysis.Emit.EmitOptions(runtimeMetadataVersion: "x.y"),
// (17,21): error CS0029: Cannot implicitly convert type 'bool' to 'string'
// var s = $"X = { 1 } ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ struct S {}
}
}
";
var comp1 = CSharpCompilation.Create(assemblyName: "Test", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication),
var comp1 = CSharpCompilation.Create(assemblyName: "Test", options: TestOptions.ReleaseExe,
syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text) }, references: new MetadataReference[] { });
var compRef = new CSharpCompilationReference(comp1);

var comp = CSharpCompilation.Create(assemblyName: "Test1", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication),
var comp = CSharpCompilation.Create(assemblyName: "Test1", options: TestOptions.ReleaseExe,
syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text1), SyntaxFactory.ParseSyntaxTree(text2) },
references: new MetadataReference[] { compRef });

Expand Down Expand Up @@ -159,7 +159,7 @@ class C : NN.B { }
var comp1 = CreateCompilation(text);
var compRef = new CSharpCompilationReference(comp1);

var comp = CSharpCompilation.Create(assemblyName: "Test1", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication),
var comp = CSharpCompilation.Create(assemblyName: "Test1", options: TestOptions.ReleaseExe,
syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text1), SyntaxFactory.ParseSyntaxTree(text2) },
references: new MetadataReference[] { compRef });

Expand Down Expand Up @@ -246,13 +246,13 @@ struct SGoo {}
}
";

var comp1 = CSharpCompilation.Create(assemblyName: "Test1", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication), syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text1) }, references: new MetadataReference[] { });
var comp2 = CSharpCompilation.Create(assemblyName: "Test2", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication), syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text2) }, references: new MetadataReference[] { });
var comp1 = CSharpCompilation.Create(assemblyName: "Test1", options: TestOptions.ReleaseExe, syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text1) }, references: new MetadataReference[] { });
var comp2 = CSharpCompilation.Create(assemblyName: "Test2", options: TestOptions.ReleaseExe, syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text2) }, references: new MetadataReference[] { });

var compRef1 = new CSharpCompilationReference(comp1);
var compRef2 = new CSharpCompilationReference(comp2);

var comp = CSharpCompilation.Create(assemblyName: "Test3", options: new CSharpCompilationOptions(OutputKind.ConsoleApplication),
var comp = CSharpCompilation.Create(assemblyName: "Test3", options: TestOptions.ReleaseExe,
syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(text3) },
references: new MetadataReference[] { compRef1, compRef2 });

Expand Down
Loading