Skip to content

Commit 8aab990

Browse files
authored
Package updates and primary constructors fix (#156)
* Update Resharper * Package updates * Run tests against .NET 8, update to latest C# version * Resharper: use file-scoped namespaces * Resharper: use target-typed new * Resharper: use collection expression * Resharper: use raw string * Resharper: use pattern syntax * Resharper: use primary constructor * Resharper: make struct readonly * Resharper: remove redundant discard * Resharper: remove redundant casts * Resharper: reformat solution * Fixed AV1500: Do not report on captured variables from primary constructor initializer
1 parent e84590e commit 8aab990

File tree

171 files changed

+11555
-11817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+11555
-11817
lines changed

src/CSharpGuidelinesAnalyzer.sln.DotSettings

Lines changed: 42 additions & 8 deletions
Large diffs are not rendered by default.

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/CSharpGuidelinesAnalyzer.Test.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net60</TargetFramework>
3+
<TargetFramework>net80</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<DefineConstants>TRACE;RELEASE;JETBRAINS_ANNOTATIONS</DefineConstants>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" />
10+
<PackageReference Include="coverlet.collector" Version="6.0.2" PrivateAssets="all" />
1111
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.4" PrivateAssets="all" />
1212
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1313
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" PrivateAssets="all" />
14-
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" />
14+
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.9.2" />
1515
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
16-
<PackageReference Include="xunit" Version="2.6.6" />
17-
<PackageReference Include="xunit.runner.console" Version="2.6.6" PrivateAssets="all" />
18-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" PrivateAssets="all" />
16+
<PackageReference Include="xunit" Version="2.7.1" />
17+
<PackageReference Include="xunit.runner.console" Version="2.7.1" PrivateAssets="all" />
18+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8" PrivateAssets="all" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/RoslynTestFramework/AnalysisTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private async Task<CompilationWithAnalyzers> GetCompilationWithAnalyzersAsync(Do
7777
ValidateCompileErrors(compilerDiagnostics);
7878
}
7979

80-
ImmutableArray<DiagnosticAnalyzer> analyzers = ImmutableArray.Create(analyzer);
80+
ImmutableArray<DiagnosticAnalyzer> analyzers = [analyzer];
8181
return compilation.WithAnalyzers(analyzers, options);
8282
}
8383

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/RoslynTestFramework/AnalyzerTestContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private static ImmutableHashSet<MetadataReference> ResolveDefaultReferences()
6262
string assemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location)!;
6363

6464
string[] assemblies =
65-
{
65+
[
6666
typeof(object).Assembly.Location, // System.Private.CoreLib.dll
6767
typeof(BitArray).Assembly.Location, // System.Collections.dll
6868
typeof(IImmutableList<>).Assembly.Location, // System.Collections.Immutable.dll
@@ -72,7 +72,7 @@ private static ImmutableHashSet<MetadataReference> ResolveDefaultReferences()
7272
typeof(DynamicAttribute).Assembly.Location, // System.Linq.Expressions.dll
7373
typeof(IPAddress).Assembly.Location, // System.Net.Primitives.dll
7474
Path.Combine(assemblyPath, "System.Runtime.dll")
75-
};
75+
];
7676

7777
return assemblies.Select(assembly => (MetadataReference)MetadataReference.CreateFromFile(assembly)).ToImmutableHashSet();
7878
}

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/RoslynTestFramework/DocumentFactory.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ public static Document ToDocument(string code, AnalyzerTestContext context)
1414
ParseOptions parseOptions = GetParseOptions(context.DocumentationMode);
1515
CompilationOptions compilationOptions = GetCompilationOptions(context);
1616

17-
Document document = new AdhocWorkspace()
17+
// @formatter:wrap_chained_method_calls chop_always
18+
// @formatter:wrap_before_first_method_call true
19+
20+
return new AdhocWorkspace()
1821
.AddProject(context.AssemblyName, LanguageNames.CSharp)
1922
.WithParseOptions(parseOptions)
2023
.WithCompilationOptions(compilationOptions)
2124
.AddMetadataReferences(context.References)
2225
.AddDocument(context.FileName, code);
2326

24-
return document;
27+
// @formatter:wrap_before_first_method_call restore
28+
// @formatter:wrap_chained_method_calls restore
2529
}
2630

2731
private static ParseOptions GetParseOptions(DocumentationMode documentationMode)

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/RoslynTestFramework/FixableDocument.cs

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,19 @@ private sealed class MarkupParser
5050
private const int SpanTextLength = 2;
5151

5252
private static readonly char[] SpanKinds =
53-
{
53+
[
5454
'|',
5555
'+',
5656
'-',
5757
'*'
58-
};
58+
];
5959

60-
private static readonly string[] ReplaceSeparatorArray =
61-
{
62-
ReplaceSeparator
63-
};
60+
private static readonly string[] ReplaceSeparatorArray = [ReplaceSeparator];
6461

6562
private readonly string markupCode;
6663

67-
public IList<TextBlock> TextBlocks { get; } = new List<TextBlock>();
68-
public IList<TextSpan> TextSpans { get; } = new List<TextSpan>();
64+
public IList<TextBlock> TextBlocks { get; } = [];
65+
public IList<TextSpan> TextSpans { get; } = [];
6966

7067
public MarkupParser(string markupCode)
7168
{
@@ -352,65 +349,40 @@ protected TextBlock(string textBefore, string textAfter)
352349
}
353350
}
354351

355-
private sealed class StaticTextBlock : TextBlock
352+
private sealed class StaticTextBlock(string text) : TextBlock(text, text)
356353
{
357-
public StaticTextBlock(string text)
358-
: base(text, text)
359-
{
360-
}
361-
362354
public override string ToString()
363355
{
364356
return TextBefore;
365357
}
366358
}
367359

368-
private sealed class MarkedTextBlock : TextBlock
360+
private sealed class MarkedTextBlock(string textToMark) : TextBlock(textToMark, textToMark)
369361
{
370-
public MarkedTextBlock(string textToMark)
371-
: base(textToMark, textToMark)
372-
{
373-
}
374-
375362
public override string ToString()
376363
{
377364
return "|" + TextAfter;
378365
}
379366
}
380367

381-
private sealed class InsertedTextBlock : TextBlock
368+
private sealed class InsertedTextBlock(string textToInsert) : TextBlock(string.Empty, textToInsert)
382369
{
383-
public InsertedTextBlock(string textToInsert)
384-
: base(string.Empty, textToInsert)
385-
{
386-
}
387-
388370
public override string ToString()
389371
{
390372
return "+" + TextAfter;
391373
}
392374
}
393375

394-
private sealed class DeletedTextBlock : TextBlock
376+
private sealed class DeletedTextBlock(string textToDelete) : TextBlock(textToDelete, string.Empty)
395377
{
396-
public DeletedTextBlock(string textToDelete)
397-
: base(textToDelete, string.Empty)
398-
{
399-
}
400-
401378
public override string ToString()
402379
{
403380
return "-" + TextBefore;
404381
}
405382
}
406383

407-
private sealed class ReplacedTextBlock : TextBlock
384+
private sealed class ReplacedTextBlock(string textBefore, string textAfter) : TextBlock(textBefore, textAfter)
408385
{
409-
public ReplacedTextBlock(string textBefore, string textAfter)
410-
: base(textBefore, textAfter)
411-
{
412-
}
413-
414386
public override string ToString()
415387
{
416388
return TextBefore + "=>" + TextAfter;

0 commit comments

Comments
 (0)