Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,17 @@ jobs:
parameters:
jobName: Correctness_Rebuild
configuration: Release

- job: Correctness_Analyzers
pool:
name: NetCore1ESPool-Public
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre.Open
timeoutInMinutes: 35
steps:
- template: eng/pipelines/checkout-windows-task.yml

- task: PowerShell@2
displayName: Build with analyzers
inputs:
filePath: eng/build.ps1
arguments: -restore -build -configuration Debug -prepareMachine -ci -binaryLog -runAnalyzers:$true -warnAsError:$true -properties "/p:RoslynEnforceCodeStyle=true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So getting all analyzer diagnostics in the solution on the command line requires emitting, etc.? is that correct? Just wondered if there was an msbuild target or something equivalent to "run code analysis on solution."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

someday when we are allowed to used github actions we could use: https://github.com/dotnet/code-analysis but for now I think this is the simplest approach.

2 changes: 1 addition & 1 deletion dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "6.3.317301",
"version": "6.4.326609",
"commands": [
"dotnet-format"
]
Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Keep the setting conditional. The toolset sets the assembly version to 42.42.42.42 if not set explicitly.
-->
<AssemblyVersion Condition="'$(OfficialBuild)' == 'true' or '$(DotNetUseShippingVersions)' == 'true'">$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
<MicrosoftNetCompilersToolsetVersion>4.2.0-1.final</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCompilersToolsetVersion>4.3.0-1.final</MicrosoftNetCompilersToolsetVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Versions used by several individual references below -->
Expand All @@ -24,7 +24,7 @@
<MicrosoftCodeAnalysisTestingVersion>1.1.2-beta1.22122.4</MicrosoftCodeAnalysisTestingVersion>
<MicrosoftVisualStudioExtensibilityTestingVersion>0.1.132-beta</MicrosoftVisualStudioExtensibilityTestingVersion>
<!-- CodeStyleAnalyzerVersion should we updated together with version of dotnet-format in dotnet-tools.json -->
<CodeStyleAnalyzerVersion>4.2.0-2.final</CodeStyleAnalyzerVersion>
<CodeStyleAnalyzerVersion>4.3.0-1.final</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>17.3.37-preview</VisualStudioEditorPackagesVersion>
<!-- This should generally be set to $(VisualStudioEditorPackagesVersion),
but sometimes EditorFeatures.Cocoa specifically requires a newer editor build. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ private static string GetAmbiguousDefinition(string typeDefinion)
=> $@"
namespace N1
{{
{ typeDefinion }
{typeDefinion}
}}
namespace N2
{{
{ typeDefinion }
{typeDefinion}
}}";

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAliasAmbiguousType)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ public class C
public class Test
{{
public object M(C c)
=> { subStringCode };
=> {subStringCode};
}}";
var fixedSource =
@$"
Expand All @@ -971,7 +971,7 @@ public class C
public class Test
{{
public object M(C c)
=> { rangeCode };
=> {rangeCode};
}}";
await new VerifyCS.Test
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ public void BuilderOnMethod_InternalReturnType()
[AsyncMethodBuilder(null)] internal class MyTaskType {{ }}

// Make the builder factory and the builder internal as well
{AsyncBuilderCode("MyTaskTypeBuilder", "MyTaskType").Replace("public class MyTaskType", "internal class MyTaskType") }
{AsyncBuilderCode("MyTaskTypeBuilder", "MyTaskType").Replace("public class MyTaskType", "internal class MyTaskType")}

class C
{{
Expand Down
14 changes: 7 additions & 7 deletions src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOperators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5173,7 +5173,7 @@ static void Main()

public static long Calculate1(long[] f)
{
" + $" return { BuildSequenceOfBinaryExpressions_01() };" + @"
" + $" return {BuildSequenceOfBinaryExpressions_01()};" + @"
}

public static long Calculate2(long[] f)
Expand Down Expand Up @@ -5233,7 +5233,7 @@ static void Main()

public static double Calculate(long[] f)
{
" + $" return checked({ BuildSequenceOfBinaryExpressions_01() });" + @"
" + $" return checked({BuildSequenceOfBinaryExpressions_01()});" + @"
}
}
";
Expand Down Expand Up @@ -5264,7 +5264,7 @@ static void Main()

public static bool Calculate(bool[] a, bool[] f)
{
" + $" return { BuildSequenceOfBinaryExpressions_03(count) };" + @"
" + $" return {BuildSequenceOfBinaryExpressions_03(count)};" + @"
}
}
";
Expand Down Expand Up @@ -5323,7 +5323,7 @@ static void Main()

public static double? Calculate(float?[] f)
{
" + $" return { BuildSequenceOfBinaryExpressions_01() };" + @"
" + $" return {BuildSequenceOfBinaryExpressions_01()};" + @"
}
}
";
Expand Down Expand Up @@ -5364,7 +5364,7 @@ static void Test1()

public static double? Calculate(double?[] f)
{
" + $" return { BuildSequenceOfBinaryExpressions_01(count) };" + @"
" + $" return {BuildSequenceOfBinaryExpressions_01(count)};" + @"
}

static void Test2()
Expand All @@ -5380,7 +5380,7 @@ static void Test2()

public static double Calculate(double[] f)
{
" + $" return { BuildSequenceOfBinaryExpressions_01(count) };" + @"
" + $" return {BuildSequenceOfBinaryExpressions_01(count)};" + @"
}
}
";
Expand All @@ -5403,7 +5403,7 @@ static void Main()

public static bool Calculate(S1[] a, S1[] f)
{
" + $" return { BuildSequenceOfBinaryExpressions_03() };" + @"
" + $" return {BuildSequenceOfBinaryExpressions_03()};" + @"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1328,16 +1328,16 @@ class Test
public static long Calculate1(long[] f)
{
long x;
" + $" x = { buildSequenceOfBinaryExpressions(8192) };" + @"
" + $" x = {buildSequenceOfBinaryExpressions(8192)};" + @"
return x;
}
}";

CreateCompilationWithMscorlib45(source)
.VerifyDiagnostics()
.VerifyAnalyzerDiagnostics(new DiagnosticAnalyzer[] { new AssignmentOperationSyntaxTestAnalyzer() }, null, null,
Diagnostic(AssignmentOperationSyntaxTestAnalyzer.AssignmentOperationDescriptor.Id, $"x = { buildSequenceOfBinaryExpressions(8192) }").WithLocation(7, 9),
Diagnostic(AssignmentOperationSyntaxTestAnalyzer.AssignmentSyntaxDescriptor.Id, $"x = { buildSequenceOfBinaryExpressions(8192) }").WithLocation(7, 9));
Diagnostic(AssignmentOperationSyntaxTestAnalyzer.AssignmentOperationDescriptor.Id, $"x = {buildSequenceOfBinaryExpressions(8192)}").WithLocation(7, 9),
Diagnostic(AssignmentOperationSyntaxTestAnalyzer.AssignmentSyntaxDescriptor.Id, $"x = {buildSequenceOfBinaryExpressions(8192)}").WithLocation(7, 9));
}

[WorkItem(9020, "https://github.com/dotnet/roslyn/issues/9020")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,7 @@ public void Deconstruct_UserDefined_Accessibility_07(string accessibility)
$@"
record struct A(int X)
{{
{ accessibility } void Deconstruct(out int a)
{accessibility} void Deconstruct(out int a)
=> throw null;
}}
";
Expand Down Expand Up @@ -4241,7 +4241,7 @@ public void RecordEquals_10(string accessibility)
$@"
record struct A
{{
{ accessibility } bool Equals(A x)
{accessibility} bool Equals(A x)
=> throw null;

bool System.IEquatable<A>.Equals(A x) => throw null;
Expand Down Expand Up @@ -4271,7 +4271,7 @@ public void RecordEquals_11(string accessibility)
$@"
record struct A
{{
{ accessibility } bool Equals(A x)
{accessibility} bool Equals(A x)
=> throw null;

bool System.IEquatable<A>.Equals(A x) => throw null;
Expand Down
18 changes: 9 additions & 9 deletions src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14006,7 +14006,7 @@ public void CopyCtor_Accessibility_01(string accessibility)
$@"
record A(int X)
{{
{ accessibility } A(A a)
{accessibility} A(A a)
=> throw null;
}}
";
Expand All @@ -14027,7 +14027,7 @@ public void CopyCtor_Accessibility_02(string accessibility)
$@"
record A(int X)
{{
{ accessibility } A(A a)
{accessibility} A(A a)
=> System.Console.Write(""RAN"");

public static void Main()
Expand All @@ -14053,7 +14053,7 @@ public void CopyCtor_Accessibility_03(string accessibility)
$@"
sealed record A(int X)
{{
{ accessibility } A(A a)
{accessibility} A(A a)
=> System.Console.Write(""RAN"");

public static void Main()
Expand Down Expand Up @@ -14086,7 +14086,7 @@ public void CopyCtor_Accessibility_04(string accessibility)
$@"
sealed record A(int X)
{{
{ accessibility } A(A a)
{accessibility} A(A a)
=> System.Console.Write(""RAN"");

public static void Main()
Expand Down Expand Up @@ -15551,7 +15551,7 @@ public void Deconstruct_UserDefined_Accessibility_07(string accessibility)
$@"
record A(int X)
{{
{ accessibility } void Deconstruct(out int a)
{accessibility} void Deconstruct(out int a)
=> throw null;
}}
";
Expand Down Expand Up @@ -18440,7 +18440,7 @@ public void RecordEquals_10(string accessibility)
$@"
record A
{{
{ accessibility } virtual bool Equals(A x)
{accessibility} virtual bool Equals(A x)
=> throw null;

bool System.IEquatable<A>.Equals(A x) => throw null;
Expand All @@ -18466,7 +18466,7 @@ public void RecordEquals_11(string accessibility)
$@"
record A
{{
{ accessibility } virtual bool Equals(A x)
{accessibility} virtual bool Equals(A x)
=> throw null;

bool System.IEquatable<A>.Equals(A x) => throw null;
Expand Down Expand Up @@ -19001,7 +19001,7 @@ public void EqualityContract_05(string accessibility)
$@"
record A
{{
{ accessibility } virtual System.Type EqualityContract
{accessibility} virtual System.Type EqualityContract
=> throw null;
}}
";
Expand All @@ -19022,7 +19022,7 @@ public void EqualityContract_06(string accessibility)
$@"
record A
{{
{ accessibility } virtual System.Type EqualityContract
{accessibility} virtual System.Type EqualityContract
=> throw null;

bool System.IEquatable<A>.Equals(A x) => throw null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7610,9 +7610,9 @@ public void Return_01()
<files>
<file id=""1"" name="""" language=""C#"" />
</files>
<entryPoint declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" methodName=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }"" parameterNames=""args"" />
<entryPoint declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" methodName=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}"" parameterNames=""args"" />
<methods>
<method containingType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" name=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }"" parameterNames=""args"">
<method containingType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" name=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}"" parameterNames=""args"">
<customDebugInfo>
<using>
<namespace usingCount=""0"" />
Expand Down Expand Up @@ -7657,9 +7657,9 @@ public void Return_02()
<files>
<file id=""1"" name="""" language=""C#"" />
</files>
<entryPoint declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" methodName=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }"" parameterNames=""args"" />
<entryPoint declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" methodName=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}"" parameterNames=""args"" />
<methods>
<method containingType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" name=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }"" parameterNames=""args"">
<method containingType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" name=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}"" parameterNames=""args"">
<customDebugInfo>
<using>
<namespace usingCount=""0"" />
Expand Down Expand Up @@ -7704,9 +7704,9 @@ public void Return_03()
<files>
<file id=""1"" name="""" language=""C#"" />
</files>
<entryPoint declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" methodName=""&lt;Main&gt;"" parameterNames=""args"" />
<entryPoint declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" methodName=""&lt;Main&gt;"" parameterNames=""args"" />
<methods>
<method containingType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }+&lt;{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }&gt;d__0"" name=""MoveNext"">
<method containingType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}+&lt;{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}&gt;d__0"" name=""MoveNext"">
<customDebugInfo>
<using>
<namespace usingCount=""2"" />
Expand Down Expand Up @@ -7735,8 +7735,8 @@ public void Return_03()
</scope>
<asyncInfo>
<catchHandler offset=""0xa9"" />
<kickoffMethod declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" methodName=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }"" parameterNames=""args"" />
<await yield=""0x5a"" resume=""0x75"" declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }+&lt;{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }&gt;d__0"" methodName=""MoveNext"" />
<kickoffMethod declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" methodName=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}"" parameterNames=""args"" />
<await yield=""0x5a"" resume=""0x75"" declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}+&lt;{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}&gt;d__0"" methodName=""MoveNext"" />
</asyncInfo>
</method>
</methods>
Expand Down Expand Up @@ -7773,9 +7773,9 @@ public void Return_04()
<files>
<file id=""1"" name="""" language=""C#"" />
</files>
<entryPoint declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" methodName=""&lt;Main&gt;"" parameterNames=""args"" />
<entryPoint declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" methodName=""&lt;Main&gt;"" parameterNames=""args"" />
<methods>
<method containingType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }+&lt;{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }&gt;d__0"" name=""MoveNext"">
<method containingType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}+&lt;{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}&gt;d__0"" name=""MoveNext"">
<customDebugInfo>
<using>
<namespace usingCount=""2"" />
Expand Down Expand Up @@ -7805,8 +7805,8 @@ public void Return_04()
</scope>
<asyncInfo>
<catchHandler offset=""0xac"" />
<kickoffMethod declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }"" methodName=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }"" parameterNames=""args"" />
<await yield=""0x5a"" resume=""0x75"" declaringType=""{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName) }+&lt;{ EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName) }&gt;d__0"" methodName=""MoveNext"" />
<kickoffMethod declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}"" methodName=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}"" parameterNames=""args"" />
<await yield=""0x5a"" resume=""0x75"" declaringType=""{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)}+&lt;{EscapeForXML(WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)}&gt;d__0"" methodName=""MoveNext"" />
</asyncInfo>
</method>
</methods>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static (T Result, string Output) UseTextWriter<T>(Encoding encoding, Fun
currentDirectory: tempDir);
if (result.ExitCode != 0)
{
AssertEx.Fail($"Deterministic compile failed \n stdout: { result.Output }");
AssertEx.Fail($"Deterministic compile failed \n stdout: {result.Output}");
}
var listener = await serverData.Complete();
Assert.Equal(CompletionData.RequestCompleted, listener.CompletionDataList.Single());
Expand Down Expand Up @@ -1503,7 +1503,7 @@ private async Task RunDeterministicTest(string source)
{
if (first[i] != second[i])
{
AssertEx.Fail($"Bytes were different at position { i } ({ first[i] } vs { second[i] }). Flags used were (\"{ finalFlags1 }\" vs \"{ finalFlags2 }\")");
AssertEx.Fail($"Bytes were different at position {i} ({first[i]} vs {second[i]}). Flags used were (\"{finalFlags1}\" vs \"{finalFlags2}\")");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class C
{{
void M()
{{
var data = (n$$) { (hasNewline ? Environment.NewLine : string.Empty) } M();
var data = (n$$) {(hasNewline ? Environment.NewLine : string.Empty)} M();
}}
}}";

Expand Down Expand Up @@ -588,7 +588,7 @@ public async Task TestInCastExpressionThatMightBeParenthesizedExpression2(bool h
var markup =
$@"class C
{{
bool Prop => (t$$) { (hasExpression ? "n" : string.Empty) }
bool Prop => (t$$) {(hasExpression ? "n" : string.Empty)}
private int n;
}}";
if (hasExpression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ public static void Main()
s.$$
}}
}}";
await VerifyItemExistsAsync(string.Format(template, $"public static bool operator {operatorSign}(S a, S b)"), operatorSign, inlineDescription: $"x { operatorSign } y");
await VerifyItemExistsAsync(string.Format(template, $"public static bool operator {operatorSign}(S a, S b)"), operatorSign, inlineDescription: $"x {operatorSign} y");
await VerifyNoItemsExistAsync(string.Format(template, $"public static int operator {operatorSign}(S a, S b)"));
await VerifyNoItemsExistAsync(string.Format(template, $"public static bool operator {operatorSign}(S a, S b, S c)"));
await VerifyNoItemsExistAsync(string.Format(template, $"public static bool operator {operatorSign}(S a, object b)"));
Expand Down
Loading