Skip to content

Commit 82f72bc

Browse files
authored
Use Meziantou.DotNet.CodingStandard (#660)
1 parent 0bb7e9d commit 82f72bc

190 files changed

Lines changed: 1585 additions & 2070 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 5 additions & 471 deletions
Large diffs are not rendered by default.

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.1.1">
37+
<PackageReference Include="Meziantou.DotNet.CodingStandard" Version="1.0.96">
3838
<PrivateAssets>all</PrivateAssets>
3939
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4040
</PackageReference>

src/DocumentationGenerator/.editorconfig

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/DocumentationGenerator/Program.cs

Lines changed: 184 additions & 188 deletions
Large diffs are not rendered by default.

src/ListDotNetTypes/Program.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#pragma warning disable CA1812
2-
#pragma warning disable CA1852
3-
using System.IO.Compression;
1+
using System.IO.Compression;
42
using System.Reflection;
53
using System.Reflection.Metadata;
64
using System.Reflection.PortableExecutable;
@@ -15,13 +13,13 @@
1513
"Microsoft.WindowsDesktop.App.Ref", // https://www.nuget.org/packages/Microsoft.WindowsDesktop.App.Ref
1614
};
1715

18-
var cache = new SourceCacheContext();
16+
using var cache = new SourceCacheContext();
1917
var repository = Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json");
2018
var resource = await repository.GetResourceAsync<FindPackageByIdResource>();
2119

2220
foreach (var includePreview in new[] { false, true })
2321
{
24-
var types = new HashSet<string>();
22+
var types = new HashSet<string>(StringComparer.Ordinal);
2523
foreach (var packageName in packages)
2624
{
2725
var versions = await resource.GetAllVersionsAsync(packageName, cache, NullLogger.Instance, CancellationToken.None);
@@ -58,7 +56,7 @@
5856
}
5957
}
6058

61-
await File.WriteAllLinesAsync(Path.Combine(args.Length > 0 ? args[0] : "../../../../Meziantou.Analyzer/Resources/", includePreview ? "bcl-preview.txt" : "bcl.txt"), types.OrderBy(t => t));
59+
await File.WriteAllLinesAsync(Path.Combine(args.Length > 0 ? args[0] : "../../../../Meziantou.Analyzer/Resources/", includePreview ? "bcl-preview.txt" : "bcl.txt"), types.OrderBy(t => t, StringComparer.Ordinal));
6260
}
6361

6462
static MemoryStream CopyToMemoryStream(ZipArchiveEntry entry)

src/Meziantou.Analyzer.Annotations/Annotations.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma warning disable CS1591
2+
#pragma warning disable IDE0060
3+
#pragma warning disable CA1019
4+
#nullable disable
5+
6+
namespace Meziantou.Analyzer.Annotations;
7+
8+
/// <summary>
9+
/// Indicates arguments must be named for this parameter.
10+
/// </summary>
11+
[System.Diagnostics.Conditional("MEZIANTOU_ANALYZER_ANNOTATIONS")]
12+
[System.AttributeUsage(System.AttributeTargets.Parameter)]
13+
public sealed class RequireNamedArgumentAttribute : System.Attribute
14+
{
15+
public RequireNamedArgumentAttribute() { }
16+
17+
public RequireNamedArgumentAttribute(bool isRequired) { }
18+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma warning disable CS1591
2+
#pragma warning disable IDE0060
3+
#pragma warning disable IDE0290
4+
#pragma warning disable CA1019
5+
#nullable disable
6+
7+
namespace Meziantou.Analyzer.Annotations;
8+
9+
[System.Diagnostics.Conditional("MEZIANTOU_ANALYZER_ANNOTATIONS")]
10+
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
11+
public sealed class StructuredLogFieldAttribute : System.Attribute
12+
{
13+
public StructuredLogFieldAttribute(string parameterName, params System.Type[] allowedTypes) { }
14+
}

src/Meziantou.Analyzer.CodeFixers/Internals/DocumentBasedFixAllProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private async Task<Document> GetDocumentFixesAsync(FixAllContext fixAllContext)
6363
}
6464

6565
var newRoot = await FixAllInDocumentAsync(fixAllContext, document, diagnostics).ConfigureAwait(false);
66-
if (newRoot == null)
66+
if (newRoot is null)
6767
{
6868
return document;
6969
}
@@ -91,7 +91,7 @@ private async Task<Solution> GetSolutionFixesAsync(FixAllContext fixAllContext,
9191
for (var i = 0; i < documents.Length; i++)
9292
{
9393
var newDocumentRoot = await newDocuments[i].ConfigureAwait(false);
94-
if (newDocumentRoot == null)
94+
if (newDocumentRoot is null)
9595
continue;
9696

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

src/Meziantou.Analyzer.CodeFixers/Internals/FixAllContextHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic
2626
switch (fixAllContext.Scope)
2727
{
2828
case FixAllScope.Document:
29-
if (document != null)
29+
if (document is not null)
3030
{
3131
var documentDiagnostics = await fixAllContext.GetDocumentDiagnosticsAsync(document).ConfigureAwait(false);
3232
return ImmutableDictionary<Document, ImmutableArray<Diagnostic>>.Empty.SetItem(document, documentDiagnostics);
@@ -96,7 +96,7 @@ private static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnosti
9696
{
9797
cancellationToken.ThrowIfCancellationRequested();
9898
var document = documentAndDiagnostics.Key;
99-
if (document != null)
99+
if (document is not null)
100100
{
101101
var diagnosticsForDocument = documentAndDiagnostics.ToImmutableArray();
102102
builder.Add(document, diagnosticsForDocument);
@@ -116,7 +116,7 @@ private static async Task<ImmutableDictionary<SyntaxTree, Document>> GetTreeToDo
116116
{
117117
cancellationToken.ThrowIfCancellationRequested();
118118
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
119-
if (tree != null)
119+
if (tree is not null)
120120
{
121121
builder.Add(tree, document);
122122
}
@@ -129,7 +129,7 @@ private static async Task<ImmutableDictionary<SyntaxTree, Document>> GetTreeToDo
129129
private static Document? GetReportedDocument(Diagnostic diagnostic, ImmutableDictionary<SyntaxTree, Document> treeToDocumentsMap)
130130
{
131131
var tree = diagnostic.Location.SourceTree;
132-
if (tree != null)
132+
if (tree is not null)
133133
{
134134
if (treeToDocumentsMap.TryGetValue(tree, out var document))
135135
{

0 commit comments

Comments
 (0)