Skip to content

Commit 69192b1

Browse files
committed
update nullability annotations
1 parent 45a32a4 commit 69192b1

7 files changed

+78
-182
lines changed

doc/api-list/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi.Core-net6.0.apilist.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44
// InformationalVersion: 1.1.1+c427f8c147936a9aec90fa59918071264114150c
55
// TargetFramework: .NETCoreApp,Version=v6.0
66
// Configuration: Release
7+
#nullable enable annotations
78

89
using System;
910
using System.Collections.Generic;
1011
using System.Diagnostics.CodeAnalysis;
1112
using System.IO;
1213
using System.Reflection;
13-
using System.Runtime.CompilerServices;
1414
using System.Runtime.Versioning;
1515
using Microsoft.Extensions.Logging;
1616
using Smdn.Reflection.ReverseGenerating;
1717
using Smdn.Reflection.ReverseGenerating.ListApi;
1818

1919
namespace Smdn.Reflection.ReverseGenerating.ListApi {
20-
[Nullable(byte.MinValue)]
21-
[NullableContext(1)]
2220
public class ApiListWriter {
2321
public ApiListWriter(TextWriter baseWriter, Assembly assembly, ApiListWriterOptions options) {}
2422

@@ -28,10 +26,7 @@ public void WriteAssemblyInfoHeader() {}
2826
public void WriteExportedTypes() {}
2927
}
3028

31-
[Nullable(byte.MinValue)]
32-
[NullableContext(1)]
3329
public class ApiListWriterOptions : GeneratorOptions {
34-
[NullableContext(byte.MinValue)]
3530
public class WriterOptions {
3631
public WriterOptions() {}
3732

@@ -45,39 +40,28 @@ public ApiListWriterOptions() {}
4540
}
4641

4742
public static class AssemblyExtensions {
48-
[NullableContext(1)]
49-
[return: MaybeNull] public static TValue GetAssemblyMetadataAttributeValue<TAssemblyMetadataAttribute, TValue>(this Assembly assm) where TAssemblyMetadataAttribute : Attribute {}
43+
[return: MaybeNull] public static TValue? GetAssemblyMetadataAttributeValue<TAssemblyMetadataAttribute, TValue>(this Assembly assm) where TAssemblyMetadataAttribute : Attribute {}
5044
}
5145

52-
[Nullable(byte.MinValue)]
53-
[NullableContext(1)]
5446
public static class AssemblyLoader {
55-
[return: MaybeNull] public static TResult UsingAssembly<TArg, TResult>(FileInfo assemblyFile, bool loadIntoReflectionOnlyContext, TArg arg, Func<Assembly, TArg, TResult> actionWithLoadedAssembly, [Nullable(2)] out WeakReference context, [Nullable(2)] ILogger logger = null) {}
47+
[return: MaybeNull] public static TResult? UsingAssembly<TArg, TResult>(FileInfo assemblyFile, bool loadIntoReflectionOnlyContext, TArg? arg, Func<Assembly, TArg?, TResult?> actionWithLoadedAssembly, out WeakReference? context, ILogger? logger = null) {}
5648
}
5749

58-
[Nullable(byte.MinValue)]
59-
[NullableContext(1)]
6050
public static class AttributeFilter {
6151
public static readonly AttributeTypeFilter Default; // = "Smdn.Reflection.ReverseGenerating.AttributeTypeFilter"
6252
}
6353

6454
public static class FrameworkMonikers {
65-
[NullableContext(2)]
66-
public static bool TryGetMoniker([Nullable(1)] FrameworkName frameworkName, string osSpecifier, [NotNullWhen(true)] out string frameworkMoniker) {}
55+
public static bool TryGetMoniker(FrameworkName frameworkName, string? osSpecifier, [NotNullWhen(true)] out string? frameworkMoniker) {}
6756
}
6857

69-
[Nullable(byte.MinValue)]
70-
[NullableContext(1)]
7158
public class MemberInfoComparer : IComparer<MemberInfo> {
7259
public static readonly MemberInfoComparer Default; // = "Smdn.Reflection.ReverseGenerating.ListApi.MemberInfoComparer"
7360
public static readonly MemberInfoComparer StaticMembersFirst; // = "Smdn.Reflection.ReverseGenerating.ListApi.MemberInfoComparer"
7461

7562
public MemberInfoComparer(int orderOfStaticMember, int orderOfInstanceMember) {}
7663

77-
[NullableContext(2)]
78-
public int Compare(MemberInfo x, MemberInfo y) {}
79-
[NullableContext(2)]
80-
public int GetOrder(MemberInfo member) {}
64+
public int Compare(MemberInfo? x, MemberInfo? y) {}
65+
public int GetOrder(MemberInfo? member) {}
8166
}
8267
}
83-

doc/api-list/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi.Core-netcoreapp3.1.apilist.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44
// InformationalVersion: 1.1.1+c427f8c147936a9aec90fa59918071264114150c
55
// TargetFramework: .NETCoreApp,Version=v3.1
66
// Configuration: Release
7+
#nullable enable annotations
78

89
using System;
910
using System.Collections.Generic;
1011
using System.Diagnostics.CodeAnalysis;
1112
using System.IO;
1213
using System.Reflection;
13-
using System.Runtime.CompilerServices;
1414
using System.Runtime.Versioning;
1515
using Microsoft.Extensions.Logging;
1616
using Smdn.Reflection.ReverseGenerating;
1717
using Smdn.Reflection.ReverseGenerating.ListApi;
1818

1919
namespace Smdn.Reflection.ReverseGenerating.ListApi {
20-
[Nullable(byte.MinValue)]
21-
[NullableContext(1)]
2220
public class ApiListWriter {
2321
public ApiListWriter(TextWriter baseWriter, Assembly assembly, ApiListWriterOptions options) {}
2422

@@ -28,10 +26,7 @@ public void WriteAssemblyInfoHeader() {}
2826
public void WriteExportedTypes() {}
2927
}
3028

31-
[Nullable(byte.MinValue)]
32-
[NullableContext(1)]
3329
public class ApiListWriterOptions : GeneratorOptions {
34-
[NullableContext(byte.MinValue)]
3530
public class WriterOptions {
3631
public WriterOptions() {}
3732

@@ -45,39 +40,28 @@ public ApiListWriterOptions() {}
4540
}
4641

4742
public static class AssemblyExtensions {
48-
[NullableContext(1)]
49-
[return: MaybeNull] public static TValue GetAssemblyMetadataAttributeValue<TAssemblyMetadataAttribute, TValue>(this Assembly assm) where TAssemblyMetadataAttribute : Attribute {}
43+
[return: MaybeNull] public static TValue? GetAssemblyMetadataAttributeValue<TAssemblyMetadataAttribute, TValue>(this Assembly assm) where TAssemblyMetadataAttribute : Attribute {}
5044
}
5145

52-
[Nullable(byte.MinValue)]
53-
[NullableContext(1)]
5446
public static class AssemblyLoader {
55-
[return: MaybeNull] public static TResult UsingAssembly<TArg, TResult>(FileInfo assemblyFile, bool loadIntoReflectionOnlyContext, TArg arg, Func<Assembly, TArg, TResult> actionWithLoadedAssembly, [Nullable(2)] out WeakReference context, [Nullable(2)] ILogger logger = null) {}
47+
[return: MaybeNull] public static TResult? UsingAssembly<TArg, TResult>(FileInfo assemblyFile, bool loadIntoReflectionOnlyContext, TArg? arg, Func<Assembly, TArg?, TResult?> actionWithLoadedAssembly, out WeakReference? context, ILogger? logger = null) {}
5648
}
5749

58-
[Nullable(byte.MinValue)]
59-
[NullableContext(1)]
6050
public static class AttributeFilter {
6151
public static readonly AttributeTypeFilter Default; // = "Smdn.Reflection.ReverseGenerating.AttributeTypeFilter"
6252
}
6353

6454
public static class FrameworkMonikers {
65-
[NullableContext(2)]
66-
public static bool TryGetMoniker([Nullable(1)] FrameworkName frameworkName, string osSpecifier, [NotNullWhen(true)] out string frameworkMoniker) {}
55+
public static bool TryGetMoniker(FrameworkName frameworkName, string? osSpecifier, [NotNullWhen(true)] out string? frameworkMoniker) {}
6756
}
6857

69-
[Nullable(byte.MinValue)]
70-
[NullableContext(1)]
7158
public class MemberInfoComparer : IComparer<MemberInfo> {
7259
public static readonly MemberInfoComparer Default; // = "Smdn.Reflection.ReverseGenerating.ListApi.MemberInfoComparer"
7360
public static readonly MemberInfoComparer StaticMembersFirst; // = "Smdn.Reflection.ReverseGenerating.ListApi.MemberInfoComparer"
7461

7562
public MemberInfoComparer(int orderOfStaticMember, int orderOfInstanceMember) {}
7663

77-
[NullableContext(2)]
78-
public int Compare(MemberInfo x, MemberInfo y) {}
79-
[NullableContext(2)]
80-
public int GetOrder(MemberInfo member) {}
64+
public int Compare(MemberInfo? x, MemberInfo? y) {}
65+
public int GetOrder(MemberInfo? member) {}
8166
}
8267
}
83-

doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net45.apilist.cs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
// InformationalVersion: 1.1.0+074a83ab64ee9e829c2f3835cf0c03af8af0f59d
55
// TargetFramework: .NETFramework,Version=v4.5
66
// Configuration: Release
7+
#nullable enable annotations
78

89
using System;
910
using System.Collections.Generic;
1011
using System.Reflection;
11-
using System.Runtime.CompilerServices;
1212
using Smdn.Reflection;
1313
using Smdn.Reflection.ReverseGenerating;
1414

@@ -27,8 +27,6 @@ public enum MethodBodyOption : int {
2727
ThrowNull = 3,
2828
}
2929

30-
[Nullable(byte.MinValue)]
31-
[NullableContext(1)]
3230
public static class CSharpFormatter {
3331
public static string EscapeString(string s, bool escapeSingleQuote = false, bool escapeDoubleQuote = false) {}
3432
public static string FormatAccessibility(Accessibility accessibility) {}
@@ -40,28 +38,22 @@ public static string FormatTypeName(this EventInfo ev, bool typeWithNamespace =
4038
public static string FormatTypeName(this FieldInfo f, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
4139
public static string FormatTypeName(this ParameterInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
4240
public static string FormatTypeName(this PropertyInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
43-
public static string FormatTypeName(this Type t, [Nullable(2)] ICustomAttributeProvider attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
44-
public static string FormatValueDeclaration([Nullable(2)] object val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
41+
public static string FormatTypeName(this Type t, ICustomAttributeProvider? attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
42+
public static string FormatValueDeclaration(object? val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
4543
public static bool IsLanguagePrimitiveType(Type t, out string primitiveTypeName) {}
4644
public static IEnumerable<string> ToNamespaceList(Type t) {}
4745
}
4846

49-
[Nullable(byte.MinValue)]
50-
[NullableContext(1)]
5147
public static class Generator {
52-
public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
53-
public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
54-
public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
55-
[return: Nullable(2)] public static string GenerateMemberDeclaration(MemberInfo member, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
56-
public static string GenerateTypeDeclaration(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
57-
public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
48+
public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
49+
public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
50+
public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
51+
public static string? GenerateMemberDeclaration(MemberInfo member, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
52+
public static string GenerateTypeDeclaration(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
53+
public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
5854
}
5955

60-
[Nullable(byte.MinValue)]
61-
[NullableContext(1)]
6256
public class GeneratorOptions : ICloneable {
63-
[Nullable(byte.MinValue)]
64-
[NullableContext(2)]
6557
public class AttributeDeclarationOptions {
6658
public AttributeDeclarationOptions() {}
6759

@@ -72,13 +64,12 @@ public AttributeDeclarationOptions() {}
7264
public AttributeSectionFormat GenericParameterFormat { get; set; }
7365
public AttributeSectionFormat MethodParameterFormat { get; set; }
7466
public bool OmitAttributeSuffix { get; set; }
75-
public AttributeTypeFilter TypeFilter { get; set; }
67+
public AttributeTypeFilter? TypeFilter { get; set; }
7668
public bool WithDeclaringTypeName { get; set; }
7769
public bool WithNamedArguments { get; set; }
7870
public bool WithNamespace { get; set; }
7971
}
8072

81-
[NullableContext(byte.MinValue)]
8273
public class MemberDeclarationOptions {
8374
public MemberDeclarationOptions() {}
8475

@@ -90,15 +81,13 @@ public MemberDeclarationOptions() {}
9081
public bool WithNamespace { get; set; }
9182
}
9283

93-
[NullableContext(byte.MinValue)]
9484
public class ParameterDeclarationOptions {
9585
public ParameterDeclarationOptions() {}
9686

9787
public bool WithDeclaringTypeName { get; set; }
9888
public bool WithNamespace { get; set; }
9989
}
10090

101-
[NullableContext(byte.MinValue)]
10291
public class TypeDeclarationOptions {
10392
public TypeDeclarationOptions() {}
10493

@@ -108,7 +97,6 @@ public TypeDeclarationOptions() {}
10897
public bool WithNamespace { get; set; }
10998
}
11099

111-
[NullableContext(byte.MinValue)]
112100
public class ValueDeclarationOptions {
113101
public ValueDeclarationOptions() {}
114102

@@ -121,8 +109,7 @@ public GeneratorOptions() {}
121109

122110
public GeneratorOptions.AttributeDeclarationOptions AttributeDeclaration { get; init; }
123111
public bool IgnorePrivateOrAssembly { get; set; }
124-
[Nullable(2)]
125-
public string Indent { get; set; }
112+
public string? Indent { get; set; }
126113
public GeneratorOptions.MemberDeclarationOptions MemberDeclaration { get; init; }
127114
public GeneratorOptions.ParameterDeclarationOptions ParameterDeclaration { get; init; }
128115
public bool TranslateLanguagePrimitiveTypeDeclaration { get; set; }
@@ -133,4 +120,3 @@ public virtual GeneratorOptions Clone() {}
133120
object ICloneable.Clone() {}
134121
}
135122
}
136-

0 commit comments

Comments
 (0)