Skip to content

Commit 432e55b

Browse files
committed
fix and suppress warnings
1 parent 6e2153b commit 432e55b

File tree

11 files changed

+64
-55
lines changed

11 files changed

+64
-55
lines changed

src/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/ApiListWriterOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ namespace Smdn.Reflection.ReverseGenerating.ListApi;
55
public class ApiListWriterOptions : GeneratorOptions {
66
public WriterOptions Writer { get; } = new();
77

8+
#pragma warning disable CA1034
89
public class WriterOptions {
10+
#pragma warning restore CA1034
911
public bool OrderStaticMembersFirst { get; set; } = false;
1012
public bool OmitCompilerGeneratedRecordEqualityMethods { get; set; } = false;
1113
public bool ThrowIfForwardedTypesCouldNotLoaded { get; set; } = false;

src/Smdn.Reflection.ReverseGenerating.ListApi/Smdn.Reflection.ReverseGenerating.ListApi.Build/ProjectBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
namespace Smdn.Reflection.ReverseGenerating.ListApi.Build;
1919

2020
public static class ProjectBuilder {
21-
#pragma warning disable CA1724
21+
#pragma warning disable CA1034, CA1724
2222
public class Options {
23-
#pragma warning restore CA1724
23+
#pragma warning restore CA1034, CA1724
2424
public const string DefaultConfiguration = "Debug";
2525

2626
public string? Configuration { get; init; } = DefaultConfiguration;

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/GeneratorOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public virtual GeneratorOptions Clone()
2929

3030
public TypeDeclarationOptions TypeDeclaration { get; init; } = new();
3131

32+
#pragma warning disable CA1034
3233
public class TypeDeclarationOptions {
34+
#pragma warning restore CA1034
3335
public bool WithNamespace { get; set; } = false;
3436
public bool WithDeclaringTypeName { get; set; } = false;
3537
public bool WithAccessibility { get; set; } = true;
@@ -48,7 +50,9 @@ internal TypeDeclarationOptions Clone()
4850

4951
public MemberDeclarationOptions MemberDeclaration { get; init; } = new();
5052

53+
#pragma warning disable CA1034
5154
public class MemberDeclarationOptions {
55+
#pragma warning restore CA1034
5256
public bool WithNamespace { get; set; } = false;
5357
public bool WithDeclaringTypeName { get; set; } = false;
5458
public bool WithEnumTypeName { get; set; } = false;
@@ -67,7 +71,9 @@ internal MemberDeclarationOptions Clone()
6771

6872
public AttributeDeclarationOptions AttributeDeclaration { get; init; } = new();
6973

74+
#pragma warning disable CA1034
7075
public class AttributeDeclarationOptions {
76+
#pragma warning restore CA1034
7177
public bool WithNamespace { get; set; } = false;
7278
public bool WithDeclaringTypeName { get; set; } = false;
7379
public bool WithNamedArguments { get; set; } = false;
@@ -87,7 +93,9 @@ internal AttributeDeclarationOptions Clone()
8793

8894
public ValueDeclarationOptions ValueDeclaration { get; init; } = new();
8995

96+
#pragma warning disable CA1034
9097
public class ValueDeclarationOptions {
98+
#pragma warning restore CA1034
9199
public bool UseDefaultLiteral { get; set; } = false;
92100
public bool WithNamespace { get; set; } = false;
93101
public bool WithDeclaringTypeName { get; set; } = true;
@@ -98,7 +106,9 @@ internal ValueDeclarationOptions Clone()
98106

99107
public ParameterDeclarationOptions ParameterDeclaration { get; init; } = new();
100108

109+
#pragma warning disable CA1034
101110
public class ParameterDeclarationOptions {
111+
#pragma warning restore CA1034
102112
public bool WithNamespace { get; set; } = false;
103113
public bool WithDeclaringTypeName { get; set; } = false;
104114

tests/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/ApiListWriter.Records.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3-
#nullable enable
4-
53
using System;
64
using System.IO;
75
using System.Runtime.CompilerServices;

tests/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/ApiListWriter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// SPDX-FileCopyrightText: 2023 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3-
#nullable enable
4-
53
using System;
64
using System.Collections.Generic;
75
using System.IO;

tests/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/AssemblyLoader.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// SPDX-FileCopyrightText: 2021 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3-
#nullable enable
4-
53
using System;
64
using System.Linq;
75
using System.IO;

tests/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/AttributeFilter.TestCases.NullableAttributes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: MIT
33
#pragma warning disable CS8597, CS8618
44

5+
#nullable disable warnings
56
#nullable enable annotations
67

78
using System;

tests/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/AttributeFilter.TestCases.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-FileCopyrightText: 2022 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
33
// cSpell:ignore browsable
4+
#nullable disable
5+
46
#pragma warning disable CS8597
57

68
using System;

tests/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/AttributeFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ GeneratorTestCaseAttribute testCase
9898
=> TestAttributeFilter(
9999
actual: () => string.Join(", ", Generator.GenerateAttributeList(t, null, testCase.CreateGeneratorOptions())),
100100
testCase: testCase,
101-
testTarget: t.FullName
101+
testTarget: t.FullName!
102102
);
103103

104104
[TestCaseSource(nameof(YieldTestCases_Members))]

tests/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/MemberInfoComparer.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ namespace Smdn.Reflection.ReverseGenerating.ListApi;
1111
class MemberInfoComparerTests {
1212
class C {
1313
#pragma warning disable CS0067
14-
static C() {}
14+
static C() { }
1515
public static int SF = default;
1616
public static int SP { get; } = default;
17-
public static event EventHandler SE;
17+
public static event EventHandler? SE;
1818
public static void SM() => throw new NotImplementedException();
1919

20-
public C() {}
20+
public C() { }
2121
public int F = default;
2222
public int P { get; } = default;
23-
public event EventHandler E;
23+
public event EventHandler? E;
2424
public void M() => throw new NotImplementedException();
2525
#pragma warning restore CS0067
2626
}
@@ -30,31 +30,31 @@ public void Compare_Default()
3030
{
3131
var t = typeof(C);
3232
var members = new MemberInfo[] {
33-
t.TypeInitializer,
34-
t.GetField("SF"),
35-
t.GetProperty("SP"),
36-
t.GetEvent("SE"),
37-
t.GetMethod("SM"),
38-
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null),
39-
t.GetField("F"),
40-
t.GetProperty("P"),
41-
t.GetEvent("E"),
42-
t.GetMethod("M"),
33+
t.TypeInitializer!,
34+
t.GetField("SF")!,
35+
t.GetProperty("SP")!,
36+
t.GetEvent("SE")!,
37+
t.GetMethod("SM")!,
38+
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null)!,
39+
t.GetField("F")!,
40+
t.GetProperty("P")!,
41+
t.GetEvent("E")!,
42+
t.GetMethod("M")!,
4343
};
4444

4545
Assert.That(
4646
members.OrderBy(m => m, MemberInfoComparer.Default),
4747
Is.EqualTo(new MemberInfo[] {
48-
t.GetEvent("SE"),
49-
t.GetEvent("E"),
50-
t.GetField("SF"),
51-
t.GetField("F"),
52-
t.TypeInitializer,
53-
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null),
54-
t.GetProperty("SP"),
55-
t.GetProperty("P"),
56-
t.GetMethod("SM"),
57-
t.GetMethod("M"),
48+
t.GetEvent("SE")!,
49+
t.GetEvent("E")!,
50+
t.GetField("SF")!,
51+
t.GetField("F")!,
52+
t.TypeInitializer!,
53+
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null)!,
54+
t.GetProperty("SP")!,
55+
t.GetProperty("P")!,
56+
t.GetMethod("SM")!,
57+
t.GetMethod("M")!,
5858
}).AsCollection
5959
);
6060
}
@@ -64,31 +64,31 @@ public void Compare_StaticMembersFirst()
6464
{
6565
var t = typeof(C);
6666
var members = new MemberInfo[] {
67-
t.TypeInitializer,
68-
t.GetField("SF"),
69-
t.GetProperty("SP"),
70-
t.GetEvent("SE"),
71-
t.GetMethod("SM"),
72-
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null),
73-
t.GetField("F"),
74-
t.GetProperty("P"),
75-
t.GetEvent("E"),
76-
t.GetMethod("M"),
67+
t.TypeInitializer!,
68+
t.GetField("SF")!,
69+
t.GetProperty("SP")!,
70+
t.GetEvent("SE")!,
71+
t.GetMethod("SM")!,
72+
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null)!,
73+
t.GetField("F")!,
74+
t.GetProperty("P")!,
75+
t.GetEvent("E")!,
76+
t.GetMethod("M")!,
7777
};
7878

7979
Assert.That(
8080
members.OrderBy(m => m, MemberInfoComparer.StaticMembersFirst),
8181
Is.EqualTo(new MemberInfo[] {
82-
t.GetEvent("SE"),
83-
t.GetField("SF"),
84-
t.TypeInitializer,
85-
t.GetProperty("SP"),
86-
t.GetMethod("SM"),
87-
t.GetEvent("E"),
88-
t.GetField("F"),
89-
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null),
90-
t.GetProperty("P"),
91-
t.GetMethod("M"),
82+
t.GetEvent("SE")!,
83+
t.GetField("SF")!,
84+
t.TypeInitializer!,
85+
t.GetProperty("SP")!,
86+
t.GetMethod("SM")!,
87+
t.GetEvent("E")!,
88+
t.GetField("F")!,
89+
t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null)!,
90+
t.GetProperty("P")!,
91+
t.GetMethod("M")!,
9292
}).AsCollection
9393
);
9494
}

0 commit comments

Comments
 (0)