This instance will be upgraded to Heptapod 0.17.2 on 2020-12-03 at 14:00 UTC+1 (a few minutes of down time)

Commit d1d669bd authored by Jesse McGrew's avatar Jesse McGrew

Update to .NET Core 3.1.

Fix more ZilfAnalyzers issues.
More cleanup related to .NET/C# version updates.
parent ba0c4e4658ee
......@@ -10,6 +10,7 @@ using CodeFixVerifier = ZilfAnalyzers.Test.Helpers.CodeFixVerifier;
namespace ZilfAnalyzers.Test
{
[TestClass, TestCategory("Analyzers")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test cases")]
public class ErrorExceptionUsageTests : CodeFixVerifier
{
//No diagnostics expected to show up
......
......@@ -7,6 +7,7 @@ using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using JetBrains.Annotations;
using System.Threading.Tasks;
// ReSharper disable once CheckNamespace
namespace ZilfAnalyzers.Test.Helpers
......@@ -24,9 +25,9 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="document">The Document to apply the fix on</param>
/// <param name="codeAction">A CodeAction that will be applied to the Document.</param>
/// <returns>A Document with the changes from the CodeAction</returns>
static Document ApplyFix([JetBrains.Annotations.NotNull] Document document, [JetBrains.Annotations.NotNull] CodeAction codeAction)
static async Task<Document> ApplyFixAsync([JetBrains.Annotations.NotNull] Document document, [JetBrains.Annotations.NotNull] CodeAction codeAction)
{
var operations = codeAction.GetOperationsAsync(CancellationToken.None).Result;
var operations = await codeAction.GetOperationsAsync(CancellationToken.None).ConfigureAwait(false);
var solution = operations.OfType<ApplyChangesOperation>().Single().ChangedSolution;
return solution.GetDocument(document.Id);
}
......@@ -66,9 +67,9 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary>
/// <param name="document">The Document to run the compiler diagnostic analyzers on</param>
/// <returns>The compiler diagnostics that were found in the code</returns>
static ImmutableArray<Diagnostic> GetCompilerDiagnostics([JetBrains.Annotations.NotNull] Document document)
static async Task<ImmutableArray<Diagnostic>> GetCompilerDiagnosticsAsync([JetBrains.Annotations.NotNull] Document document)
{
return document.GetSemanticModelAsync().Result.GetDiagnostics();
return (await document.GetSemanticModelAsync().ConfigureAwait(false)).GetDiagnostics();
}
/// <summary>
......@@ -77,10 +78,10 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="document">The Document to be converted to a string</param>
/// <returns>A string containing the syntax of the Document after formatting</returns>
[JetBrains.Annotations.NotNull]
static string GetStringFromDocument(Document document)
static async Task<string> GetStringFromDocumentAsync(Document document)
{
var simplifiedDoc = Simplifier.ReduceAsync(document, Simplifier.Annotation).Result;
var root = simplifiedDoc.GetSyntaxRootAsync().Result;
var simplifiedDoc = await Simplifier.ReduceAsync(document, Simplifier.Annotation).ConfigureAwait(false);
var root = await simplifiedDoc.GetSyntaxRootAsync().ConfigureAwait(false);
root = Formatter.Format(root, Formatter.Annotation, simplifiedDoc.Project.Solution.Workspace);
return root.GetText().ToString();
}
......
......@@ -43,7 +43,7 @@ namespace ZilfAnalyzers.Test.Helpers
[JetBrains.Annotations.NotNull]
public DiagnosticResultLocation[] Locations
{
get => locations ?? (locations = new DiagnosticResultLocation[] { });
get => locations ??= new DiagnosticResultLocation[] { };
set => locations = value;
}
......
......@@ -10,6 +10,7 @@ using CodeFixVerifier = ZilfAnalyzers.Test.Helpers.CodeFixVerifier;
namespace ZilfAnalyzers.Test
{
[TestClass, TestCategory("Analyzers")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test cases")]
public class MessageConstantTests : CodeFixVerifier
{
//No diagnostics expected to show up
......
......@@ -95,7 +95,7 @@ namespace ZilfAnalyzers.Test.Helpers
var fixableIds = codeFixProvider.FixableDiagnosticIds;
analyzerDiagnostics = analyzerDiagnostics.Where(d => fixableIds.Contains(d.Id)).ToArray();
var compilerDiagnostics = GetCompilerDiagnostics(document);
var compilerDiagnostics = await GetCompilerDiagnosticsAsync(document).ConfigureAwait(false);
var attempts = analyzerDiagnostics.Length;
for (int i = 0; i < attempts; ++i)
......@@ -111,22 +111,22 @@ namespace ZilfAnalyzers.Test.Helpers
if (codeFixIndex != null)
{
document = ApplyFix(document, actions[(int)codeFixIndex]);
document = await ApplyFixAsync(document, actions[(int)codeFixIndex]).ConfigureAwait(false);
break;
}
document = ApplyFix(document, actions[0]);
document = await ApplyFixAsync(document, actions[0]).ConfigureAwait(false);
analyzerDiagnostics = await GetSortedDiagnosticsFromDocumentsAsync(analyzer, new[] { document }).ConfigureAwait(false);
analyzerDiagnostics = analyzerDiagnostics.Where(d => fixableIds.Contains(d.Id)).ToArray();
var newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, GetCompilerDiagnostics(document));
var newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, await GetCompilerDiagnosticsAsync(document).ConfigureAwait(false));
//check if applying the code fix introduced any new compiler diagnostics
if (!allowNewCompilerDiagnostics && newCompilerDiagnostics.Any())
{
// Format and get the compiler diagnostics again so that the locations make sense in the output
document = document.WithSyntaxRoot(Formatter.Format(await document.GetSyntaxRootAsync().ConfigureAwait(false), Formatter.Annotation, document.Project.Solution.Workspace));
newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, GetCompilerDiagnostics(document));
newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, await GetCompilerDiagnosticsAsync(document).ConfigureAwait(false));
Assert.Fail(
"Fix introduced new compiler diagnostics:\r\n{0}\r\n\r\nNew document:\r\n{1}\r\n",
......@@ -142,7 +142,7 @@ namespace ZilfAnalyzers.Test.Helpers
}
//after applying all of the code fixes, compare the resulting string to the inputted one
var actual = GetStringFromDocument(document);
var actual = await GetStringFromDocumentAsync(document).ConfigureAwait(false);
//Assert.AreEqual(newSource, actual);
actual.ShouldEqualWithDiff(newSource);
}
......
......@@ -9,6 +9,7 @@ using DiagnosticVerifier = ZilfAnalyzers.Test.Helpers.DiagnosticVerifier;
namespace ZilfAnalyzers.Test
{
[TestClass, TestCategory("Analyzers")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test cases")]
public class ZilObjectTests : DiagnosticVerifier
{
//No diagnostics expected to show up
......
......@@ -5,15 +5,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.7.3069">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
</ItemGroup>
<ItemGroup>
......
is_global = true
build_property.TargetFramework =
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids = {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
build_property.PublishSingleFile =
build_property.IncludeAllContentForSelfExtract =
build_property._SupportedPlatformList =
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.props" Condition="Exists('..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.props')" />
<Import Project="..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.props" Condition="Exists('..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
......@@ -52,6 +53,9 @@
<StartArguments>/rootsuffix Roslyn</StartArguments>
</PropertyGroup>
<ItemGroup>
<None Include="..\ZilfAnalyzers\.editorconfig">
<Link>.editorconfig</Link>
</None>
<None Include="packages.config" />
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
......@@ -64,21 +68,32 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\analyzers\cs\Microsoft.VisualStudio.SDK.Analyzers.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\analyzers\cs\Microsoft.VisualStudio.Threading.Analyzers.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.BannedApiAnalyzers.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.BannedApiAnalyzers.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.16.7.9\analyzers\cs\Microsoft.VisualStudio.SDK.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.16.7.9\analyzers\cs\Microsoft.VisualStudio.SDK.Analyzers.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\analyzers\cs\Microsoft.VisualStudio.Threading.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\analyzers\cs\Microsoft.VisualStudio.Threading.Analyzers.CSharp.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\analyzers\cs\Microsoft.VisualStudio.Threading.Analyzers.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\analyzers\vb\Microsoft.VisualStudio.Threading.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\analyzers\vb\Microsoft.VisualStudio.Threading.Analyzers.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\analyzers\vb\Microsoft.VisualStudio.Threading.Analyzers.VisualBasic.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\build\Microsoft.VisualStudio.SDK.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\build\Microsoft.VisualStudio.SDK.Analyzers.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.props'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\build\Microsoft.VisualStudio.Threading.Analyzers.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.16.7.9\build\Microsoft.VisualStudio.SDK.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.16.7.9\build\Microsoft.VisualStudio.SDK.Analyzers.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.props'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.targets'))" />
</Target>
<Import Project="..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\build\Microsoft.VisualStudio.SDK.Analyzers.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\build\Microsoft.VisualStudio.SDK.Analyzers.targets')" />
<Import Project="..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.targets" Condition="Exists('..\..\..\packages\Microsoft.VSSDK.BuildTools.16.7.3069\build\Microsoft.VSSDK.BuildTools.targets')" />
<Import Project="..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\build\Microsoft.VisualStudio.Threading.Analyzers.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.16.7.56\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" />
<Import Project="..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.16.7.9\build\Microsoft.VisualStudio.SDK.Analyzers.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.SDK.Analyzers.16.7.9\build\Microsoft.VisualStudio.SDK.Analyzers.targets')" />
<Import Project="..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.targets" Condition="Exists('..\..\..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.0\build\Microsoft.CodeAnalysis.BannedApiAnalyzers.targets')" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.VisualStudio.SDK.Analyzers" version="15.8.33" targetFramework="net472" />
<package id="Microsoft.VisualStudio.Threading.Analyzers" version="15.8.122" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.BannedApiAnalyzers" version="3.3.0" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.VisualStudio.SDK.Analyzers" version="16.7.9" targetFramework="net472" />
<package id="Microsoft.VisualStudio.Threading.Analyzers" version="16.7.56" targetFramework="net472" />
<package id="Microsoft.VSSDK.BuildTools" version="16.7.3069" targetFramework="net472" developmentDependency="true" />
</packages>
\ No newline at end of file
[*.cs]
# RNUL: Parameter is missing nullability annotation.
dotnet_diagnostic.RNUL.severity = silent
# RINUL: Parameter is missing item nullability annotation.
dotnet_diagnostic.RINUL.severity = silent
# Default severity for analyzer diagnostics with category 'MicrosoftCodeAnalysisReleaseTracking'
dotnet_analyzer_diagnostic.category-MicrosoftCodeAnalysisReleaseTracking.severity = silent
......@@ -23,8 +23,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.3.1" PrivateAssets="all" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.7.0" PrivateAssets="all" />
<!--<PackageReference Update="NETStandard.Library" PrivateAssets="all" />-->
</ItemGroup>
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<OutputType>Exe</OutputType>
<Product>ZILF</Product>
<Version>0.8</Version>
......@@ -13,7 +13,7 @@
<None Include="..\Zilf.licenseheader" Link="Zilf.licenseheader" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3">
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0">
<PrivateAssets>all</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers</IncludeAssets>
......
......@@ -6,11 +6,15 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3">
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0">
<PrivateAssets>all</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="..\Zilf.licenseheader">
......
......@@ -125,7 +125,7 @@ namespace Zapf
}
// found a word
var word = text.Substring(wordStart, wordEnd - wordStart);
var word = text[wordStart..wordEnd];
bool prev = (wordStart > 0), next = (wordEnd < text.Length);
yield return word;
......
......@@ -47,10 +47,7 @@ namespace Zapf
public override int GetHashCode()
{
int result = File;
result = result * 31 + Line;
result = result * 31 + Col;
return result;
return System.HashCode.Combine(File, Line, Col);
}
}
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifiers>win-x86;win-x64;linux-arm;linux-x64;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<OutputType>Exe</OutputType>
......@@ -10,11 +10,15 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3">
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0">
<PrivateAssets>all</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Packaging.Tools.Trimming" Version="1.1.0-preview1-26619-01" />
</ItemGroup>
<ItemGroup>
......
......@@ -201,7 +201,7 @@ namespace Zilf.Common.StringEncoding
}
if (result.Length >= 2)
result[result.Length - 2] |= 0x80;
result[^2] |= 0x80;
return result;
}
......
......@@ -10,6 +10,12 @@
<Link>Zilf.licenseheader</Link>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
......
......@@ -5,11 +5,15 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3">
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0">
<PrivateAssets>all</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="..\Zilf.licenseheader">
......
......@@ -693,13 +693,13 @@ namespace Zilf.Compiler.Builtins
// the initial value, which is returned as-is if there are no args,
// or possibly combined with the single arg if there's only one
initialValue = (short)(op switch
initialValue = op switch
{
BinaryOp.Mul => 1,
BinaryOp.Div => 1,
BinaryOp.And => -1,
_ => 0
});
};
// another delegate describing how to combine the initial value
// with the single arg in that case
......
......@@ -641,8 +641,8 @@ namespace Zilf.Compiler
return new OneVarLoop(blc, atom, container);
// throw an appropriate error
var matched = blc.spec.Matches(out ZilObject? atomObj, out ZilObject? nextAtomObj, out container) ||
blc.spec.Matches(out atomObj, out container);
var matched = blc.spec.Matches(out ZilObject? atomObj, out ZilObject? nextAtomObj, out ZilObject? _) ||
blc.spec.Matches(out atomObj, out ZilObject? _);
if (!matched)
{
......
......@@ -33,7 +33,7 @@ namespace Zilf.Diagnostics
readonly HashSet<string> suppressions = new HashSet<string>();
bool suppressAllTheThings = false;
bool suppressAllTheThings;
public IReadOnlyCollection<Diagnostic> Diagnostics => diagnostics;
public int ErrorCount => Diagnostics.Count(d => d.Severity == Severity.Error || d.Severity == Severity.Fatal);
......
B/* Copyright 2010-2018 Jesse McGrew
......
......@@ -187,35 +187,7 @@ namespace Zilf.Interpreter
{
}
private ArgumentCountError(int code) : base(code)
{
}
private ArgumentCountError(int code, params object[] messageArgs) : base(code, messageArgs)
{
}
private ArgumentCountError(ISourceLine sourceLine, int code) : base(sourceLine, code)
{
}
private ArgumentCountError(ISourceLine sourceLine, int code, params object[] messageArgs) : base(sourceLine, code, messageArgs)
{
}
private ArgumentCountError(IProvideSourceLine sourceLine, int code) : base(sourceLine, code)
{
}
private ArgumentCountError(IProvideSourceLine node, int code, params object[] messageArgs) : base(node, code, messageArgs)
{
}
private ArgumentCountError(string message) : base(message)
{
}
private ArgumentCountError(ISourceLine src, string message) : base(src, message)
public ArgumentCountError(string message) : base(message)
{
}
}
......@@ -240,43 +212,11 @@ namespace Zilf.Interpreter
{
}
private ArgumentTypeError(Diagnostic diagnostic) : base(diagnostic)
{
}
private ArgumentTypeError() : base()
{
}
private ArgumentTypeError(int code) : base(code)
{
}
private ArgumentTypeError(int code, params object[] messageArgs) : base(code, messageArgs)
{
}
private ArgumentTypeError(ISourceLine sourceLine, int code) : base(sourceLine, code)
{
}
private ArgumentTypeError(ISourceLine sourceLine, int code, params object[] messageArgs) : base(sourceLine, code, messageArgs)
{
}
private ArgumentTypeError(IProvideSourceLine sourceLine, int code) : base(sourceLine, code)
{
}
private ArgumentTypeError(IProvideSourceLine node, int code, params object[] messageArgs) : base(node, code, messageArgs)
{
}
private ArgumentTypeError(string message, Exception innerException) : base(message, innerException)
{
}
private ArgumentTypeError(ISourceLine src, string message) : base(src, message)
public ArgumentTypeError(string message, Exception innerException) : base(message, innerException)
{
}
}
......
......@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Zilf.Interpreter.Values;
......@@ -32,7 +33,7 @@ namespace Zilf.Interpreter
{
}
public bool Equals(T x, T y)
public bool Equals([AllowNull] T x, [AllowNull] T y)
{
return ReferenceEquals(x, y);
}
......@@ -51,7 +52,7 @@ namespace Zilf.Interpreter
{
}
public bool Equals(ZilObject x, ZilObject y)
public bool Equals([AllowNull] ZilObject x, [AllowNull] ZilObject y)
{
return x?.StructurallyEquals(y) ?? y == null;
}
......
......@@ -871,15 +871,11 @@ namespace Zilf.Interpreter
break;
case DefStructParams.FixDefaultClause fc:
switch (fc.ClauseType)
defaults.StartOffset = fc.ClauseType switch
{
case StdAtom.START_OFFSET:
defaults.StartOffset = fc.Fix;
break;
default:
throw UnhandledCaseException.FromEnum(fc.ClauseType, "FIX clause type");
}
StdAtom.START_OFFSET => fc.Fix,
_ => throw UnhandledCaseException.FromEnum(fc.ClauseType, "FIX clause type"),
};
break;
case DefStructParams.VarargsDefaultClause vc:
......
......@@ -432,7 +432,7 @@ namespace Zilf.Interpreter
{
var desc = JsonDescriber.Describe(signature);
var array = (JArray)result[name];
var array = (JArray?)result[name];
if (array == null)
{
result[name] = new JArray(desc);
......
......@@ -254,6 +254,7 @@ namespace Zilf.Interpreter
/// <exception cref="InterpreterError">Not supported by this type of channel.</exception>
[Subr("M-HPOS")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "M_ is not a member prefix here")]
public static ZilObject M_HPOS(Context ctx, ZilChannel channel)
{
if (!(channel is IChannelWithHPos hposChannel))
......
......@@ -46,15 +46,11 @@ namespace Zilf.Interpreter
foreach (var atom in flags)
{
switch (atom.StdAtom)
newFlags |= atom.StdAtom switch
{
case StdAtom.CLEAN_STACK_P:
newFlags |= RoutineFlags.CleanStack;
break;
default:
throw new InterpreterError(InterpreterMessages._0_Unrecognized_1_2, "ROUTINE-FLAGS", "flag", atom);
}
StdAtom.CLEAN_STACK_P => RoutineFlags.CleanStack,
_ => throw new InterpreterError(InterpreterMessages._0_Unrecognized_1_2, "ROUTINE-FLAGS", "flag", atom),
};
}
ctx.NextRoutineFlags = newFlags;
......
......@@ -244,7 +244,7 @@ namespace Zilf.Interpreter.Values
[ContractAnnotation("=> true, atom: notnull; => false, atom: null")]
public override bool IsGVAL([NotNullWhen(true)] out ZilAtom? atom) => IsTwoElementFormWithStdAtom(StdAtom.GVAL, out atom);
bool IsTwoElementFormWithStdAtom(StdAtom stdAtom, out ZilAtom? atom)
bool IsTwoElementFormWithStdAtom(StdAtom stdAtom, [NotNullWhen(true)] out ZilAtom? atom)
{
if (First is ZilAtom head &&
head.StdAtom == stdAtom)
......
......@@ -17,6 +17,7 @@
*/
using System;
using System.Diagnostics.CodeAnalysis;
using Zilf.Compiler;
using Zilf.Language;
......@@ -95,7 +96,7 @@ namespace Zilf.Interpreter.Values
public override ZilResult Expand(Context ctx) => this;
public override bool IsTrue => throw new WrappedMacroResultException();
public override bool IsLVAL(out ZilAtom? atom) => throw new WrappedMacroResultException();
public override bool IsGVAL(out ZilAtom? atom) => throw new WrappedMacroResultException();
public override bool IsLVAL([NotNullWhen(true)] out ZilAtom? atom) => throw new WrappedMacroResultException();
public override bool IsGVAL([NotNullWhen(true)] out ZilAtom? atom) => throw new WrappedMacroResultException();
}
}