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

Update .NET SDK 9.0 #768

Merged
merged 8 commits into from
Nov 13, 2024
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
9 changes: 7 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ indent_size = 2
insert_final_newline = true

[*.cs]
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0303.severity = none
dotnet_diagnostic.CA1508.severity = none
dotnet_diagnostic.CA2000.severity = none
dotnet_diagnostic.RS1041.severity = none
dotnet_diagnostic.RS2008.severity = none
dotnet_diagnostic.CA1508.severity = none

[src/ListDotNetTypes/*.cs]
dotnet_diagnostic.CA2007.severity = none
dotnet_diagnostic.MA0004.severity = none
dotnet_diagnostic.MA0004.severity = none


7 changes: 6 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Meziantou.DotNet.CodingStandard" Version="1.0.135">
<PackageReference Include="Meziantou.DotNet.CodingStandard" Version="1.0.143">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand All @@ -43,4 +43,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<NuGetAuditSuppress Include="https://github.com/advisories/GHSA-7jgj-8wvc-jh57" />
<NuGetAuditSuppress Include="https://github.com/advisories/GHSA-cmhx-cq75-c4mj" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@

<Otherwise>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0-beta1.24225.1" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Update="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.10.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0" />
<PackageReference Update="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Update="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
</ItemGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);ROSLYN4_8;ROSLYN_4_2_OR_GREATER;ROSLYN_4_4_OR_GREATER;ROSLYN_4_5_OR_GREATER;ROSLYN_4_6_OR_GREATER;ROSLYN_4_8_OR_GREATER;ROSLYN_4_10_OR_GREATER</DefineConstants>
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.303",
"rollForward": "latestMajor"
"version": "9.0.100",
"rollForward": "latestPatch"
}
}
2 changes: 1 addition & 1 deletion src/DocumentationGenerator/DocumentationGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
6 changes: 3 additions & 3 deletions src/ListDotNetTypes/ListDotNetTypes.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.Protocol" Version="6.10.1" />
<PackageReference Include="NuGet.Protocol" Version="6.12.1" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion src/ListDotNetTypes/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
Console.WriteLine(packageName + "@" + latestVersion);

using var packageStream = new MemoryStream();
await resource.CopyNupkgToStreamAsync(packageName, latestVersion, packageStream, cache, NullLogger.Instance, CancellationToken.None);
if (!await resource.CopyNupkgToStreamAsync(packageName, latestVersion, packageStream, cache, NullLogger.Instance, CancellationToken.None))
throw new InvalidOperationException("Cannot copy NuGet package");

packageStream.Seek(0, SeekOrigin.Begin);

using var zipArchive = new ZipArchive(packageStream, ZipArchiveMode.Read);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma warning disable CS1591
#pragma warning disable IDE0060
#pragma warning disable CA1019
#nullable disable

namespace Meziantou.Analyzer.Annotations;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#pragma warning disable IDE0060
#pragma warning disable IDE0290
#pragma warning disable CA1019
#nullable disable

namespace Meziantou.Analyzer.Annotations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// File initially copied from
#if ROSLYN_3_8
#pragma warning disable IDE0130 // Namespace does not match folder structure
// File initially copied from
// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/4d9b3e3bb785a55f73b3029a843f0c0b73cc9ea7/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/DocumentBasedFixAllProvider.cs
// Original copyright statement:
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
Expand All @@ -7,6 +9,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand All @@ -18,22 +21,22 @@ namespace Meziantou.Analyzer;
/// </summary>
internal abstract class DocumentBasedFixAllProvider : FixAllProvider
{
protected abstract string CodeActionTitle { get; }
protected abstract string GetFixAllTitle(FixAllContext fixAllContext);

public override Task<CodeAction?> GetFixAsync(FixAllContext fixAllContext)
{
return Task.FromResult(fixAllContext.Scope switch
{
FixAllScope.Document => CodeAction.Create(
CodeActionTitle,
GetFixAllTitle(fixAllContext),
cancellationToken => GetDocumentFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)),
nameof(DocumentBasedFixAllProvider)),
FixAllScope.Project => CodeAction.Create(
CodeActionTitle,
GetFixAllTitle(fixAllContext),
cancellationToken => GetProjectFixesAsync(fixAllContext.WithCancellationToken(cancellationToken), fixAllContext.Project),
nameof(DocumentBasedFixAllProvider)),
FixAllScope.Solution => CodeAction.Create(
CodeActionTitle,
GetFixAllTitle(fixAllContext),
cancellationToken => GetSolutionFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)),
nameof(DocumentBasedFixAllProvider)),
_ => null,
Expand All @@ -47,11 +50,11 @@ internal abstract class DocumentBasedFixAllProvider : FixAllProvider
/// <param name="document">The document to fix.</param>
/// <param name="diagnostics">The diagnostics to fix in the document.</param>
/// <returns>
/// <para>The new <see cref="SyntaxNode"/> representing the root of the fixed document.</para>
/// <para>The new <see cref="Document"/> representing the root of the fixed document.</para>
/// <para>-or-</para>
/// <para><see langword="null"/>, if no changes were made to the document.</para>
/// </returns>
protected abstract Task<SyntaxNode?> FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics);
protected abstract Task<Document?> FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics);

private async Task<Document> GetDocumentFixesAsync(FixAllContext fixAllContext)
{
Expand All @@ -62,30 +65,25 @@ private async Task<Document> GetDocumentFixesAsync(FixAllContext fixAllContext)
return document;
}

var newRoot = await FixAllInDocumentAsync(fixAllContext, document, diagnostics).ConfigureAwait(false);
if (newRoot is null)
{
return document;
}

return document.WithSyntaxRoot(newRoot);
var newDocument = await FixAllAsync(fixAllContext, document, diagnostics).ConfigureAwait(false);
return newDocument ?? document;
}

private async Task<Solution> GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray<Document> documents)
{
var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext).ConfigureAwait(false);

var solution = fixAllContext.Solution;
var newDocuments = new List<Task<SyntaxNode?>>(documents.Length);
var newDocuments = new List<Task<Document?>>(documents.Length);
foreach (var document in documents)
{
if (!documentDiagnosticsToFix.TryGetValue(document, out var diagnostics))
{
newDocuments.Add(document.GetSyntaxRootAsync(fixAllContext.CancellationToken));
newDocuments.Add(Task.FromResult<Document?>(document));
continue;
}

newDocuments.Add(FixAllInDocumentAsync(fixAllContext, document, diagnostics));
newDocuments.Add(FixAllAsync(fixAllContext, document, diagnostics));
}

for (var i = 0; i < documents.Length; i++)
Expand All @@ -94,7 +92,7 @@ private async Task<Solution> GetSolutionFixesAsync(FixAllContext fixAllContext,
if (newDocumentRoot is null)
continue;

solution = solution.WithDocumentSyntaxRoot(documents[i].Id, newDocumentRoot);
//solution = solution.WithDocumentSyntaxRoot(documents[i].Id, newDocumentRoot);
}

return solution;
Expand All @@ -111,3 +109,4 @@ private Task<Solution> GetSolutionFixesAsync(FixAllContext fixAllContext)
return GetSolutionFixesAsync(fixAllContext, documents);
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;

namespace Meziantou.Analyzer;
namespace Meziantou.Analyzer.Internals;

internal static class FixAllContextHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net9.0;netstandard2.0</TargetFrameworks>
<IncludeBuildOutput>false</IncludeBuildOutput>
<Version>1.0.1</Version>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ internal sealed class AvoidUsingRedundantElseFixAllProvider : DocumentBasedFixAl
{
public static AvoidUsingRedundantElseFixAllProvider Instance { get; } = new AvoidUsingRedundantElseFixAllProvider();

protected override string CodeActionTitle => "Remove redundant else";
protected override string GetFixAllTitle(FixAllContext fixAllContext) => "Remove redundant else";

/// <inheritdoc/>
protected override async Task<SyntaxNode?> FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
protected override async Task<Document?> FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
{
if (diagnostics.IsEmpty)
return null;

var newDocument = await AvoidUsingRedundantElseFixer.RemoveRedundantElseClausesInDocument(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false);

return await newDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);
return newDocument;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand Down Expand Up @@ -46,5 +47,4 @@ private static async Task<Document> AddSealedModifier(Document document, SyntaxN
editor.ReplaceNode(classNode, classNode.WithModifiers(modifiers).WithAdditionalAnnotations(Formatter.Annotation));
return editor.GetChangedDocument();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand Down Expand Up @@ -40,8 +41,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Thread_Sleep");

context.RegisterCodeFix(codeAction, context.Diagnostics);
break;
}
break;

case DoNotUseBlockingCallInAsyncContextData.Task_Wait:
{
Expand All @@ -51,8 +52,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Task_Wait");

context.RegisterCodeFix(codeAction, context.Diagnostics);
break;
}
break;

case DoNotUseBlockingCallInAsyncContextData.Task_Result:
{
Expand All @@ -62,8 +63,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Task_Result");

context.RegisterCodeFix(codeAction, context.Diagnostics);
break;
}
break;

case DoNotUseBlockingCallInAsyncContextData.Overload:
{
Expand All @@ -76,8 +77,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Overload");

context.RegisterCodeFix(codeAction, context.Diagnostics);
break;
}
break;

case DoNotUseBlockingCallInAsyncContextData.Using:
case DoNotUseBlockingCallInAsyncContextData.UsingDeclarator:
Expand All @@ -88,8 +89,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Overload");

context.RegisterCodeFix(codeAction, context.Diagnostics);
break;
}
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
Expand Down Expand Up @@ -102,16 +103,15 @@ internal sealed class MakeMemberReadOnlyFixAllProvider : DocumentBasedFixAllProv
{
public static MakeMemberReadOnlyFixAllProvider Instance { get; } = new MakeMemberReadOnlyFixAllProvider();

protected override string CodeActionTitle => "Add readonly";
protected override string GetFixAllTitle(FixAllContext fixAllContext) => "Add readonly";

/// <inheritdoc/>
protected override async Task<SyntaxNode?> FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
protected override async Task<Document?> FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
{
if (diagnostics.IsEmpty)
return null;

var newDocument = await MakeReadOnly(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false);
return await newDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);
return newDocument;
}

internal static async Task<Document> MakeReadOnly(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
Expand Down
Loading