This instance will be upgraded to Heptapod 0.19.0rc2 on 2021-01-18 at 11:00 UTC+1 (a few minutes of downtime)

Commit d02eca48 authored by Jesse McGrew's avatar Jesse McGrew

Update to .NET Core 3.0 and add nullability annotations.

parent e98c978791f1
...@@ -183,7 +183,7 @@ class Program { ...@@ -183,7 +183,7 @@ class Program {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
[NotNull] [JetBrains.Annotations.NotNull]
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer() protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{ {
return new ErrorExceptionUsageAnalyzer(); return new ErrorExceptionUsageAnalyzer();
......
...@@ -24,7 +24,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -24,7 +24,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="document">The Document to apply the fix on</param> /// <param name="document">The Document to apply the fix on</param>
/// <param name="codeAction">A CodeAction that will be applied to the Document.</param> /// <param name="codeAction">A CodeAction that will be applied to the Document.</param>
/// <returns>A Document with the changes from the CodeAction</returns> /// <returns>A Document with the changes from the CodeAction</returns>
static Document ApplyFix([NotNull] Document document, [NotNull] CodeAction codeAction) static Document ApplyFix([JetBrains.Annotations.NotNull] Document document, [JetBrains.Annotations.NotNull] CodeAction codeAction)
{ {
var operations = codeAction.GetOperationsAsync(CancellationToken.None).Result; var operations = codeAction.GetOperationsAsync(CancellationToken.None).Result;
var solution = operations.OfType<ApplyChangesOperation>().Single().ChangedSolution; var solution = operations.OfType<ApplyChangesOperation>().Single().ChangedSolution;
...@@ -39,7 +39,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -39,7 +39,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="diagnostics">The Diagnostics that existed in the code before the CodeFix was applied</param> /// <param name="diagnostics">The Diagnostics that existed in the code before the CodeFix was applied</param>
/// <param name="newDiagnostics">The Diagnostics that exist in the code after the CodeFix was applied</param> /// <param name="newDiagnostics">The Diagnostics that exist in the code after the CodeFix was applied</param>
/// <returns>A list of Diagnostics that only surfaced in the code after the CodeFix was applied</returns> /// <returns>A list of Diagnostics that only surfaced in the code after the CodeFix was applied</returns>
static IEnumerable<Diagnostic> GetNewDiagnostics([NotNull] [InstantHandle] IEnumerable<Diagnostic> diagnostics, [NotNull] [InstantHandle] IEnumerable<Diagnostic> newDiagnostics) static IEnumerable<Diagnostic> GetNewDiagnostics([JetBrains.Annotations.NotNull] [InstantHandle] IEnumerable<Diagnostic> diagnostics, [JetBrains.Annotations.NotNull] [InstantHandle] IEnumerable<Diagnostic> newDiagnostics)
{ {
var oldArray = diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray(); var oldArray = diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
var newArray = newDiagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray(); var newArray = newDiagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
...@@ -66,7 +66,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -66,7 +66,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary> /// </summary>
/// <param name="document">The Document to run the compiler diagnostic analyzers on</param> /// <param name="document">The Document to run the compiler diagnostic analyzers on</param>
/// <returns>The compiler diagnostics that were found in the code</returns> /// <returns>The compiler diagnostics that were found in the code</returns>
static ImmutableArray<Diagnostic> GetCompilerDiagnostics([NotNull] Document document) static ImmutableArray<Diagnostic> GetCompilerDiagnostics([JetBrains.Annotations.NotNull] Document document)
{ {
return document.GetSemanticModelAsync().Result.GetDiagnostics(); return document.GetSemanticModelAsync().Result.GetDiagnostics();
} }
...@@ -76,7 +76,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -76,7 +76,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary> /// </summary>
/// <param name="document">The Document to be converted to a string</param> /// <param name="document">The Document to be converted to a string</param>
/// <returns>A string containing the syntax of the Document after formatting</returns> /// <returns>A string containing the syntax of the Document after formatting</returns>
[NotNull] [JetBrains.Annotations.NotNull]
static string GetStringFromDocument(Document document) static string GetStringFromDocument(Document document)
{ {
var simplifiedDoc = Simplifier.ReduceAsync(document, Simplifier.Annotation).Result; var simplifiedDoc = Simplifier.ReduceAsync(document, Simplifier.Annotation).Result;
......
...@@ -40,7 +40,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -40,7 +40,7 @@ namespace ZilfAnalyzers.Test.Helpers
{ {
DiagnosticResultLocation[] locations; DiagnosticResultLocation[] locations;
[NotNull] [JetBrains.Annotations.NotNull]
public DiagnosticResultLocation[] Locations public DiagnosticResultLocation[] Locations
{ {
get => locations ?? (locations = new DiagnosticResultLocation[] { }); get => locations ?? (locations = new DiagnosticResultLocation[] { });
......
...@@ -24,7 +24,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -24,7 +24,7 @@ namespace ZilfAnalyzers.Test.Helpers
static readonly IReadOnlyCollection<MetadataReference> ProjectMetadataReferences = static readonly IReadOnlyCollection<MetadataReference> ProjectMetadataReferences =
GetProjectMetadataReferences(); GetProjectMetadataReferences();
[NotNull, ItemNotNull] [JetBrains.Annotations.NotNull, ItemNotNull]
private static IReadOnlyCollection<MetadataReference> GetProjectMetadataReferences() private static IReadOnlyCollection<MetadataReference> GetProjectMetadataReferences()
{ {
var result = new List<MetadataReference> var result = new List<MetadataReference>
...@@ -72,7 +72,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -72,7 +72,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="analyzer">The analyzer to be run on the sources</param> /// <param name="analyzer">The analyzer to be run on the sources</param>
/// <returns>An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location</returns> /// <returns>An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location</returns>
[ItemNotNull] [ItemNotNull]
private static async Task<Diagnostic[]> GetSortedDiagnosticsAsync([NotNull] string[] sources, [NotNull] string language, DiagnosticAnalyzer analyzer) private static async Task<Diagnostic[]> GetSortedDiagnosticsAsync([JetBrains.Annotations.NotNull] string[] sources, [JetBrains.Annotations.NotNull] string language, DiagnosticAnalyzer analyzer)
{ {
return await GetSortedDiagnosticsFromDocumentsAsync(analyzer, GetDocuments(sources, language)).ConfigureAwait(false); return await GetSortedDiagnosticsFromDocumentsAsync(analyzer, GetDocuments(sources, language)).ConfigureAwait(false);
} }
...@@ -85,7 +85,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -85,7 +85,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="documents">The Documents that the analyzer will be run on</param> /// <param name="documents">The Documents that the analyzer will be run on</param>
/// <returns>An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location</returns> /// <returns>An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location</returns>
[ItemNotNull] [ItemNotNull]
protected static async Task<Diagnostic[]> GetSortedDiagnosticsFromDocumentsAsync(DiagnosticAnalyzer analyzer, [NotNull] Document[] documents) protected static async Task<Diagnostic[]> GetSortedDiagnosticsFromDocumentsAsync(DiagnosticAnalyzer analyzer, [JetBrains.Annotations.NotNull] Document[] documents)
{ {
var projects = new HashSet<Project>(); var projects = new HashSet<Project>();
foreach (var document in documents) foreach (var document in documents)
...@@ -137,8 +137,8 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -137,8 +137,8 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary> /// </summary>
/// <param name="diagnostics">The list of Diagnostics to be sorted</param> /// <param name="diagnostics">The list of Diagnostics to be sorted</param>
/// <returns>An IEnumerable containing the Diagnostics in order of Location</returns> /// <returns>An IEnumerable containing the Diagnostics in order of Location</returns>
[NotNull] [JetBrains.Annotations.NotNull]
static Diagnostic[] SortDiagnostics([NotNull] IEnumerable<Diagnostic> diagnostics) static Diagnostic[] SortDiagnostics([JetBrains.Annotations.NotNull] IEnumerable<Diagnostic> diagnostics)
{ {
return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray(); return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
} }
...@@ -152,8 +152,8 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -152,8 +152,8 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="sources">Classes in the form of strings</param> /// <param name="sources">Classes in the form of strings</param>
/// <param name="language">The language the source code is in</param> /// <param name="language">The language the source code is in</param>
/// <returns>A Tuple containing the Documents produced from the sources and their TextSpans if relevant</returns> /// <returns>A Tuple containing the Documents produced from the sources and their TextSpans if relevant</returns>
[NotNull] [JetBrains.Annotations.NotNull]
static Document[] GetDocuments([NotNull] string[] sources, [NotNull] string language) static Document[] GetDocuments([JetBrains.Annotations.NotNull] string[] sources, [JetBrains.Annotations.NotNull] string language)
{ {
if (language != LanguageNames.CSharp && language != LanguageNames.VisualBasic) if (language != LanguageNames.CSharp && language != LanguageNames.VisualBasic)
{ {
...@@ -188,7 +188,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -188,7 +188,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="sources">Classes in the form of strings</param> /// <param name="sources">Classes in the form of strings</param>
/// <param name="language">The language the source code is in</param> /// <param name="language">The language the source code is in</param>
/// <returns>A Project created out of the Documents created from the source strings</returns> /// <returns>A Project created out of the Documents created from the source strings</returns>
static Project CreateProject([NotNull] string[] sources, string language = LanguageNames.CSharp) static Project CreateProject([JetBrains.Annotations.NotNull] string[] sources, string language = LanguageNames.CSharp)
{ {
string fileNamePrefix = DefaultFilePathPrefix; string fileNamePrefix = DefaultFilePathPrefix;
string fileExt = language == LanguageNames.CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt; string fileExt = language == LanguageNames.CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt;
......
...@@ -53,7 +53,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -53,7 +53,7 @@ namespace ZilfAnalyzers.Test.Helpers
Assert.AreEqual(expectedValue, actualValue); Assert.AreEqual(expectedValue, actualValue);
} }
[NotNull] [JetBrains.Annotations.NotNull]
static string ToSafeString(this char c) static string ToSafeString(this char c)
{ {
switch (c) switch (c)
......
...@@ -155,7 +155,7 @@ namespace Zilf.Diagnostics { ...@@ -155,7 +155,7 @@ namespace Zilf.Diagnostics {
await VerifyCSharpFixAsync(test, fixtest); await VerifyCSharpFixAsync(test, fixtest);
} }
[NotNull] [JetBrains.Annotations.NotNull]
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer() protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{ {
return new MessageConstantAnalyzer(); return new MessageConstantAnalyzer();
......
...@@ -23,14 +23,14 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -23,14 +23,14 @@ namespace ZilfAnalyzers.Test.Helpers
/// Returns the codefix being tested (C#) - to be implemented in non-abstract class /// Returns the codefix being tested (C#) - to be implemented in non-abstract class
/// </summary> /// </summary>
/// <returns>The CodeFixProvider to be used for CSharp code</returns> /// <returns>The CodeFixProvider to be used for CSharp code</returns>
[NotNull] [JetBrains.Annotations.NotNull]
protected abstract CodeFixProvider GetCSharpCodeFixProvider(); protected abstract CodeFixProvider GetCSharpCodeFixProvider();
/// <summary> /// <summary>
/// Returns the codefix being tested (VB) - to be implemented in non-abstract class /// Returns the codefix being tested (VB) - to be implemented in non-abstract class
/// </summary> /// </summary>
/// <returns>The CodeFixProvider to be used for VisualBasic code</returns> /// <returns>The CodeFixProvider to be used for VisualBasic code</returns>
[NotNull] [JetBrains.Annotations.NotNull]
protected abstract CodeFixProvider GetBasicCodeFixProvider(); protected abstract CodeFixProvider GetBasicCodeFixProvider();
/// <summary> /// <summary>
...@@ -70,7 +70,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -70,7 +70,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param> /// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param> /// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param> /// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
static async Task VerifyFixAsync(string language, DiagnosticAnalyzer analyzer, [NotNull] CodeFixProvider codeFixProvider, string oldSource, string newSource, int? codeFixIndex, bool allowNewCompilerDiagnostics) static async Task VerifyFixAsync(string language, DiagnosticAnalyzer analyzer, [JetBrains.Annotations.NotNull] CodeFixProvider codeFixProvider, string oldSource, string newSource, int? codeFixIndex, bool allowNewCompilerDiagnostics)
{ {
var document = CreateDocument(oldSource, language); var document = CreateDocument(oldSource, language);
var analyzerDiagnostics = await GetSortedDiagnosticsFromDocumentsAsync(analyzer, new[] { document }).ConfigureAwait(false); var analyzerDiagnostics = await GetSortedDiagnosticsFromDocumentsAsync(analyzer, new[] { document }).ConfigureAwait(false);
......
...@@ -38,7 +38,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -38,7 +38,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary> /// </summary>
/// <param name="source">A class in the form of a string to run the analyzer on</param> /// <param name="source">A class in the form of a string to run the analyzer on</param>
/// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source</param> /// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source</param>
protected async Task VerifyCSharpDiagnosticAsync(string source, [NotNull] params DiagnosticResult[] expected) protected async Task VerifyCSharpDiagnosticAsync(string source, [JetBrains.Annotations.NotNull] params DiagnosticResult[] expected)
{ {
await VerifyDiagnosticsAsync(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected); await VerifyDiagnosticsAsync(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
} }
...@@ -49,7 +49,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -49,7 +49,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary> /// </summary>
/// <param name="source">A class in the form of a string to run the analyzer on</param> /// <param name="source">A class in the form of a string to run the analyzer on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the source</param> /// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the source</param>
protected async Task VerifyBasicDiagnosticAsync(string source, [NotNull] params DiagnosticResult[] expected) protected async Task VerifyBasicDiagnosticAsync(string source, [JetBrains.Annotations.NotNull] params DiagnosticResult[] expected)
{ {
await VerifyDiagnosticsAsync(new[] { source }, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected); await VerifyDiagnosticsAsync(new[] { source }, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
} }
...@@ -60,7 +60,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -60,7 +60,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary> /// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on</param> /// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param> /// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
protected async Task VerifyCSharpDiagnosticAsync([NotNull] string[] sources, [NotNull] params DiagnosticResult[] expected) protected async Task VerifyCSharpDiagnosticAsync([JetBrains.Annotations.NotNull] string[] sources, [JetBrains.Annotations.NotNull] params DiagnosticResult[] expected)
{ {
await VerifyDiagnosticsAsync(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected); await VerifyDiagnosticsAsync(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
} }
...@@ -71,7 +71,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -71,7 +71,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary> /// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on</param> /// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param> /// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
protected async Task VerifyBasicDiagnosticAsync([NotNull] string[] sources, [NotNull] params DiagnosticResult[] expected) protected async Task VerifyBasicDiagnosticAsync([JetBrains.Annotations.NotNull] string[] sources, [JetBrains.Annotations.NotNull] params DiagnosticResult[] expected)
{ {
await VerifyDiagnosticsAsync(sources, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected); await VerifyDiagnosticsAsync(sources, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
} }
...@@ -84,7 +84,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -84,7 +84,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="language">The language of the classes represented by the source strings</param> /// <param name="language">The language of the classes represented by the source strings</param>
/// <param name="analyzer">The analyzer to be run on the source code</param> /// <param name="analyzer">The analyzer to be run on the source code</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param> /// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
static async Task VerifyDiagnosticsAsync([NotNull] string[] sources, [NotNull] string language, DiagnosticAnalyzer analyzer, [NotNull] params DiagnosticResult[] expected) static async Task VerifyDiagnosticsAsync([JetBrains.Annotations.NotNull] string[] sources, [JetBrains.Annotations.NotNull] string language, DiagnosticAnalyzer analyzer, [JetBrains.Annotations.NotNull] params DiagnosticResult[] expected)
{ {
var diagnostics = await GetSortedDiagnosticsAsync(sources, language, analyzer).ConfigureAwait(false); var diagnostics = await GetSortedDiagnosticsAsync(sources, language, analyzer).ConfigureAwait(false);
VerifyDiagnosticResults(diagnostics, analyzer, expected); VerifyDiagnosticResults(diagnostics, analyzer, expected);
...@@ -100,7 +100,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -100,7 +100,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="actualResults">The Diagnostics found by the compiler after running the analyzer on the source code</param> /// <param name="actualResults">The Diagnostics found by the compiler after running the analyzer on the source code</param>
/// <param name="analyzer">The analyzer that was being run on the sources</param> /// <param name="analyzer">The analyzer that was being run on the sources</param>
/// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param> /// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param>
static void VerifyDiagnosticResults([NotNull] IEnumerable<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, [NotNull] params DiagnosticResult[] expectedResults) static void VerifyDiagnosticResults([JetBrains.Annotations.NotNull] IEnumerable<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, [JetBrains.Annotations.NotNull] params DiagnosticResult[] expectedResults)
{ {
var expectedCount = expectedResults.Length; var expectedCount = expectedResults.Length;
var actualResultsArray = actualResults as Diagnostic[] ?? actualResults.ToArray(); var actualResultsArray = actualResults as Diagnostic[] ?? actualResults.ToArray();
...@@ -172,7 +172,7 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -172,7 +172,7 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="diagnostic">The diagnostic that was found in the code</param> /// <param name="diagnostic">The diagnostic that was found in the code</param>
/// <param name="actual">The Location of the Diagnostic found in the code</param> /// <param name="actual">The Location of the Diagnostic found in the code</param>
/// <param name="expected">The DiagnosticResultLocation that should have been found</param> /// <param name="expected">The DiagnosticResultLocation that should have been found</param>
static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, [NotNull] Location actual, DiagnosticResultLocation expected) static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, [JetBrains.Annotations.NotNull] Location actual, DiagnosticResultLocation expected)
{ {
var actualSpan = actual.GetLineSpan(); var actualSpan = actual.GetLineSpan();
...@@ -213,8 +213,8 @@ namespace ZilfAnalyzers.Test.Helpers ...@@ -213,8 +213,8 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="analyzer">The analyzer that this verifier tests</param> /// <param name="analyzer">The analyzer that this verifier tests</param>
/// <param name="diagnostics">The Diagnostics to be formatted</param> /// <param name="diagnostics">The Diagnostics to be formatted</param>
/// <returns>The Diagnostics formatted as a string</returns> /// <returns>The Diagnostics formatted as a string</returns>
[NotNull] [JetBrains.Annotations.NotNull]
static string FormatDiagnostics(DiagnosticAnalyzer analyzer, [NotNull] params Diagnostic[] diagnostics) static string FormatDiagnostics(DiagnosticAnalyzer analyzer, [JetBrains.Annotations.NotNull] params Diagnostic[] diagnostics)
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
for (int i = 0; i < diagnostics.Length; ++i) for (int i = 0; i < diagnostics.Length; ++i)
......
...@@ -208,7 +208,7 @@ namespace Zilf.Diagnostics { ...@@ -208,7 +208,7 @@ namespace Zilf.Diagnostics {
#endif #endif
} }
[NotNull] [JetBrains.Annotations.NotNull]
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer() protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{ {
return new ZilObjectAnalyzer(); return new ZilObjectAnalyzer();
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" /> <PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.1.0" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.7.3069"> <PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.7.3069">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
[*.cs]
# RNUL: Parameter is missing nullability annotation.
dotnet_diagnostic.RNUL.severity = silent
# RINUL: Parameter is missing item nullability annotation.
dotnet_diagnostic.RINUL.severity = silent
...@@ -27,6 +27,8 @@ namespace ZilfAnalyzers ...@@ -27,6 +27,8 @@ namespace ZilfAnalyzers
public override void Initialize([NotNull] AnalysisContext context) public override void Initialize([NotNull] AnalysisContext context)
{ {
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.ObjectCreationExpression); context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.ObjectCreationExpression);
} }
......
...@@ -51,6 +51,8 @@ namespace ZilfAnalyzers ...@@ -51,6 +51,8 @@ namespace ZilfAnalyzers
public override void Initialize([NotNull] AnalysisContext context) public override void Initialize([NotNull] AnalysisContext context)
{ {
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.ClassDeclaration); context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.ClassDeclaration);
} }
......
...@@ -28,7 +28,6 @@ namespace ZilfAnalyzers ...@@ -28,7 +28,6 @@ namespace ZilfAnalyzers
DiagnosticSeverity.Warning, DiagnosticSeverity.Warning,
isEnabledByDefault: true); isEnabledByDefault: true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create( ImmutableArray.Create(
Rule_ComparingZilObjectsWithEquals, Rule_ComparingZilObjectsWithEquals,
...@@ -36,6 +35,8 @@ namespace ZilfAnalyzers ...@@ -36,6 +35,8 @@ namespace ZilfAnalyzers
public override void Initialize([NotNull] AnalysisContext context) public override void Initialize([NotNull] AnalysisContext context)
{ {
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.RegisterSyntaxNodeAction(AnalyzeMemberAccessishNode, SyntaxKind.SimpleMemberAccessExpression, SyntaxKind.ConditionalAccessExpression); context.RegisterSyntaxNodeAction(AnalyzeMemberAccessishNode, SyntaxKind.SimpleMemberAccessExpression, SyntaxKind.ConditionalAccessExpression);
context.RegisterSyntaxNodeAction(AnalyzeInvocationNode, SyntaxKind.InvocationExpression); context.RegisterSyntaxNodeAction(AnalyzeInvocationNode, SyntaxKind.InvocationExpression);
context.RegisterSymbolAction(AnalyzeClassSymbol, SymbolKind.NamedType); context.RegisterSymbolAction(AnalyzeClassSymbol, SymbolKind.NamedType);
...@@ -63,7 +64,7 @@ namespace ZilfAnalyzers ...@@ -63,7 +64,7 @@ namespace ZilfAnalyzers
{ {
var diagnostic = Diagnostic.Create( var diagnostic = Diagnostic.Create(
Rule_PartiallyOverriddenZilObjectComparison, Rule_PartiallyOverriddenZilObjectComparison,
overridingMethod.Locations.First(), overridingMethod.Locations[0],
type.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat), type.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat),
baseEqualsMethod.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat), baseEqualsMethod.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat),
baseExactlyEqualsMethod?.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat));