Smdn.Reflection.ReverseGenerating version 1.1.1
·
416 commits
to main
since this release
Released package
Release notes
The full release notes are available at gist.
Change log
Change log in this release:
- 2022-07-12 add fallback implementation
- 2022-07-12 update assembly version
- 2022-07-12 fix not to set nullability annotation to generic parameters which have no constraints
- 2022-07-12 split implementations relevant to nullable metadata into extension class TypeGenericParameterExtensions
- 2022-07-12 remove redundant typename modification
- 2022-07-12 fix estimating the
notnull
constraints with optimized nullable metadata of nested types - 2022-07-11 fix formatting type name of Nullable<GenericValueType<...>>
API changes
API changes in this release:
diff --git a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net45.apilist.cs b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net45.apilist.cs
index f0f5273..f993af6 100644
--- a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net45.apilist.cs
+++ b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net45.apilist.cs
@@ -1,122 +1,136 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.1)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.0.0
-// InformationalVersion: 1.1.0+074a83ab64ee9e829c2f3835cf0c03af8af0f59d
+// AssemblyVersion: 1.1.1.0
+// InformationalVersion: 1.1.1+9c1ed7379f1b7fe2562a51f0283b02332d84584f
// TargetFramework: .NETFramework,Version=v4.5
// Configuration: Release
-#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Runtime.CompilerServices;
using Smdn.Reflection;
using Smdn.Reflection.ReverseGenerating;
namespace Smdn.Reflection.ReverseGenerating {
public delegate bool AttributeTypeFilter(Type type, ICustomAttributeProvider attributeProvider);
public enum AttributeSectionFormat : int {
Discrete = 1,
List = 0,
}
public enum MethodBodyOption : int {
EmptyImplementation = 1,
None = 0,
ThrowNotImplementedException = 2,
ThrowNull = 3,
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class CSharpFormatter {
public static string EscapeString(string s, bool escapeSingleQuote = false, bool escapeDoubleQuote = false) {}
public static string FormatAccessibility(Accessibility accessibility) {}
public static string FormatParameter(ParameterInfo p, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(MethodBase m, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(ParameterInfo[] parameterList, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatSpecialNameMethod(MethodBase methodOrConstructor, out MethodSpecialName nameType) {}
public static string FormatTypeName(this EventInfo ev, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this FieldInfo f, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this ParameterInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this PropertyInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this Type t, ICustomAttributeProvider? attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatValueDeclaration(object? val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
+ public static string FormatTypeName(this Type t, [Nullable(2)] ICustomAttributeProvider attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatValueDeclaration([Nullable(2)] object val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
public static bool IsLanguagePrimitiveType(Type t, out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class Generator {
- public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string? GenerateMemberDeclaration(MemberInfo member, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateTypeDeclaration(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ [return: Nullable(2)] public static string GenerateMemberDeclaration(MemberInfo member, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateTypeDeclaration(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public class GeneratorOptions : ICloneable {
+ [Nullable(byte.MinValue)]
+ [NullableContext(2)]
public class AttributeDeclarationOptions {
public AttributeDeclarationOptions() {}
public AttributeSectionFormat AccessorFormat { get; set; }
public AttributeSectionFormat AccessorParameterFormat { get; set; }
public AttributeSectionFormat BackingFieldFormat { get; set; }
public AttributeSectionFormat DelegateParameterFormat { get; set; }
public AttributeSectionFormat GenericParameterFormat { get; set; }
public AttributeSectionFormat MethodParameterFormat { get; set; }
public bool OmitAttributeSuffix { get; set; }
- public AttributeTypeFilter? TypeFilter { get; set; }
+ public AttributeTypeFilter TypeFilter { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class MemberDeclarationOptions {
public MemberDeclarationOptions() {}
public MethodBodyOption AccessorBody { get; set; }
public MethodBodyOption MethodBody { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class TypeDeclarationOptions {
public TypeDeclarationOptions() {}
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ValueDeclarationOptions {
public ValueDeclarationOptions() {}
public bool UseDefaultLiteral { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public GeneratorOptions() {}
public GeneratorOptions.AttributeDeclarationOptions AttributeDeclaration { get; init; }
public bool IgnorePrivateOrAssembly { get; set; }
- public string? Indent { get; set; }
+ [Nullable(2)]
+ public string Indent { get; set; }
public GeneratorOptions.MemberDeclarationOptions MemberDeclaration { get; init; }
public GeneratorOptions.ParameterDeclarationOptions ParameterDeclaration { get; init; }
public bool TranslateLanguagePrimitiveTypeDeclaration { get; set; }
public GeneratorOptions.TypeDeclarationOptions TypeDeclaration { get; init; }
public GeneratorOptions.ValueDeclarationOptions ValueDeclaration { get; init; }
public virtual GeneratorOptions Clone() {}
object ICloneable.Clone() {}
}
}
+
diff --git a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net47.apilist.cs b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net47.apilist.cs
index 97309f4..09b275b 100644
--- a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net47.apilist.cs
+++ b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net47.apilist.cs
@@ -1,122 +1,136 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.1)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.0.0
-// InformationalVersion: 1.1.0+074a83ab64ee9e829c2f3835cf0c03af8af0f59d
+// AssemblyVersion: 1.1.1.0
+// InformationalVersion: 1.1.1+9c1ed7379f1b7fe2562a51f0283b02332d84584f
// TargetFramework: .NETFramework,Version=v4.7
// Configuration: Release
-#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Runtime.CompilerServices;
using Smdn.Reflection;
using Smdn.Reflection.ReverseGenerating;
namespace Smdn.Reflection.ReverseGenerating {
public delegate bool AttributeTypeFilter(Type type, ICustomAttributeProvider attributeProvider);
public enum AttributeSectionFormat : int {
Discrete = 1,
List = 0,
}
public enum MethodBodyOption : int {
EmptyImplementation = 1,
None = 0,
ThrowNotImplementedException = 2,
ThrowNull = 3,
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class CSharpFormatter {
public static string EscapeString(string s, bool escapeSingleQuote = false, bool escapeDoubleQuote = false) {}
public static string FormatAccessibility(Accessibility accessibility) {}
public static string FormatParameter(ParameterInfo p, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(MethodBase m, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(ParameterInfo[] parameterList, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatSpecialNameMethod(MethodBase methodOrConstructor, out MethodSpecialName nameType) {}
public static string FormatTypeName(this EventInfo ev, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this FieldInfo f, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this ParameterInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this PropertyInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this Type t, ICustomAttributeProvider? attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatValueDeclaration(object? val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
+ public static string FormatTypeName(this Type t, [Nullable(2)] ICustomAttributeProvider attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatValueDeclaration([Nullable(2)] object val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
public static bool IsLanguagePrimitiveType(Type t, out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class Generator {
- public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string? GenerateMemberDeclaration(MemberInfo member, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateTypeDeclaration(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ [return: Nullable(2)] public static string GenerateMemberDeclaration(MemberInfo member, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateTypeDeclaration(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public class GeneratorOptions : ICloneable {
+ [Nullable(byte.MinValue)]
+ [NullableContext(2)]
public class AttributeDeclarationOptions {
public AttributeDeclarationOptions() {}
public AttributeSectionFormat AccessorFormat { get; set; }
public AttributeSectionFormat AccessorParameterFormat { get; set; }
public AttributeSectionFormat BackingFieldFormat { get; set; }
public AttributeSectionFormat DelegateParameterFormat { get; set; }
public AttributeSectionFormat GenericParameterFormat { get; set; }
public AttributeSectionFormat MethodParameterFormat { get; set; }
public bool OmitAttributeSuffix { get; set; }
- public AttributeTypeFilter? TypeFilter { get; set; }
+ public AttributeTypeFilter TypeFilter { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class MemberDeclarationOptions {
public MemberDeclarationOptions() {}
public MethodBodyOption AccessorBody { get; set; }
public MethodBodyOption MethodBody { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class TypeDeclarationOptions {
public TypeDeclarationOptions() {}
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ValueDeclarationOptions {
public ValueDeclarationOptions() {}
public bool UseDefaultLiteral { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public GeneratorOptions() {}
public GeneratorOptions.AttributeDeclarationOptions AttributeDeclaration { get; init; }
public bool IgnorePrivateOrAssembly { get; set; }
- public string? Indent { get; set; }
+ [Nullable(2)]
+ public string Indent { get; set; }
public GeneratorOptions.MemberDeclarationOptions MemberDeclaration { get; init; }
public GeneratorOptions.ParameterDeclarationOptions ParameterDeclaration { get; init; }
public bool TranslateLanguagePrimitiveTypeDeclaration { get; set; }
public GeneratorOptions.TypeDeclarationOptions TypeDeclaration { get; init; }
public GeneratorOptions.ValueDeclarationOptions ValueDeclaration { get; init; }
public virtual GeneratorOptions Clone() {}
object ICloneable.Clone() {}
}
}
+
diff --git a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net5.0.apilist.cs b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net5.0.apilist.cs
index e740461..a0b680c 100644
--- a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net5.0.apilist.cs
+++ b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net5.0.apilist.cs
@@ -1,123 +1,137 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.1)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.0.0
-// InformationalVersion: 1.1.0+074a83ab64ee9e829c2f3835cf0c03af8af0f59d
+// AssemblyVersion: 1.1.1.0
+// InformationalVersion: 1.1.1+9c1ed7379f1b7fe2562a51f0283b02332d84584f
// TargetFramework: .NETCoreApp,Version=v5.0
// Configuration: Release
-#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
+using System.Runtime.CompilerServices;
using Smdn.Reflection;
using Smdn.Reflection.ReverseGenerating;
namespace Smdn.Reflection.ReverseGenerating {
public delegate bool AttributeTypeFilter(Type type, ICustomAttributeProvider attributeProvider);
public enum AttributeSectionFormat : int {
Discrete = 1,
List = 0,
}
public enum MethodBodyOption : int {
EmptyImplementation = 1,
None = 0,
ThrowNotImplementedException = 2,
ThrowNull = 3,
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class CSharpFormatter {
public static string EscapeString(string s, bool escapeSingleQuote = false, bool escapeDoubleQuote = false) {}
public static string FormatAccessibility(Accessibility accessibility) {}
public static string FormatParameter(ParameterInfo p, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(MethodBase m, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(ParameterInfo[] parameterList, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatSpecialNameMethod(MethodBase methodOrConstructor, out MethodSpecialName nameType) {}
public static string FormatTypeName(this EventInfo ev, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this FieldInfo f, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this ParameterInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this PropertyInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this Type t, ICustomAttributeProvider? attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatValueDeclaration(object? val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
- public static bool IsLanguagePrimitiveType(Type t, [MaybeNullWhen(false)] out string? primitiveTypeName) {}
+ public static string FormatTypeName(this Type t, [Nullable(2)] ICustomAttributeProvider attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatValueDeclaration([Nullable(2)] object val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
+ public static bool IsLanguagePrimitiveType(Type t, [MaybeNullWhen(false)] out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class Generator {
- public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string? GenerateMemberDeclaration(MemberInfo member, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateTypeDeclaration(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ [return: Nullable(2)] public static string GenerateMemberDeclaration(MemberInfo member, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateTypeDeclaration(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public class GeneratorOptions : ICloneable {
+ [Nullable(byte.MinValue)]
+ [NullableContext(2)]
public class AttributeDeclarationOptions {
public AttributeDeclarationOptions() {}
public AttributeSectionFormat AccessorFormat { get; set; }
public AttributeSectionFormat AccessorParameterFormat { get; set; }
public AttributeSectionFormat BackingFieldFormat { get; set; }
public AttributeSectionFormat DelegateParameterFormat { get; set; }
public AttributeSectionFormat GenericParameterFormat { get; set; }
public AttributeSectionFormat MethodParameterFormat { get; set; }
public bool OmitAttributeSuffix { get; set; }
- public AttributeTypeFilter? TypeFilter { get; set; }
+ public AttributeTypeFilter TypeFilter { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class MemberDeclarationOptions {
public MemberDeclarationOptions() {}
public MethodBodyOption AccessorBody { get; set; }
public MethodBodyOption MethodBody { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class TypeDeclarationOptions {
public TypeDeclarationOptions() {}
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ValueDeclarationOptions {
public ValueDeclarationOptions() {}
public bool UseDefaultLiteral { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public GeneratorOptions() {}
public GeneratorOptions.AttributeDeclarationOptions AttributeDeclaration { get; init; }
public bool IgnorePrivateOrAssembly { get; set; }
- public string? Indent { get; set; }
+ [Nullable(2)]
+ public string Indent { get; set; }
public GeneratorOptions.MemberDeclarationOptions MemberDeclaration { get; init; }
public GeneratorOptions.ParameterDeclarationOptions ParameterDeclaration { get; init; }
public bool TranslateLanguagePrimitiveTypeDeclaration { get; set; }
public GeneratorOptions.TypeDeclarationOptions TypeDeclaration { get; init; }
public GeneratorOptions.ValueDeclarationOptions ValueDeclaration { get; init; }
public virtual GeneratorOptions Clone() {}
object ICloneable.Clone() {}
}
}
+
diff --git a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net6.0.apilist.cs b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net6.0.apilist.cs
index a480b04..db79b15 100644
--- a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net6.0.apilist.cs
+++ b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net6.0.apilist.cs
@@ -1,132 +1,148 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.1)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.0.0
-// InformationalVersion: 1.1.0+074a83ab64ee9e829c2f3835cf0c03af8af0f59d
+// AssemblyVersion: 1.1.1.0
+// InformationalVersion: 1.1.1+9c1ed7379f1b7fe2562a51f0283b02332d84584f
// TargetFramework: .NETCoreApp,Version=v6.0
// Configuration: Release
-#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
+using System.Runtime.CompilerServices;
using Smdn.Reflection;
using Smdn.Reflection.ReverseGenerating;
namespace Smdn.Reflection.ReverseGenerating {
public delegate bool AttributeTypeFilter(Type type, ICustomAttributeProvider attributeProvider);
public enum AttributeSectionFormat : int {
Discrete = 1,
List = 0,
}
public enum MethodBodyOption : int {
EmptyImplementation = 1,
None = 0,
ThrowNotImplementedException = 2,
ThrowNull = 3,
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class CSharpFormatter {
public static string EscapeString(string s, bool escapeSingleQuote = false, bool escapeDoubleQuote = false) {}
public static string FormatAccessibility(Accessibility accessibility) {}
- public static string FormatParameter(ParameterInfo p, NullabilityInfoContext? nullabilityInfoContext, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
+ public static string FormatParameter(ParameterInfo p, [Nullable(2)] NullabilityInfoContext nullabilityInfoContext, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameter(ParameterInfo p, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
- public static string FormatParameterList(MethodBase m, NullabilityInfoContext? nullabilityInfoContext, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
+ public static string FormatParameterList(MethodBase m, [Nullable(2)] NullabilityInfoContext nullabilityInfoContext, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(MethodBase m, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
- public static string FormatParameterList(ParameterInfo[] parameterList, NullabilityInfoContext? nullabilityInfoContext, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
+ public static string FormatParameterList(ParameterInfo[] parameterList, [Nullable(2)] NullabilityInfoContext nullabilityInfoContext, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(ParameterInfo[] parameterList, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatSpecialNameMethod(MethodBase methodOrConstructor, out MethodSpecialName nameType) {}
- public static string FormatTypeName(this EventInfo ev, NullabilityInfoContext? nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatTypeName(this EventInfo ev, [Nullable(2)] NullabilityInfoContext nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this EventInfo ev, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this FieldInfo f, NullabilityInfoContext? nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatTypeName(this FieldInfo f, [Nullable(2)] NullabilityInfoContext nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this FieldInfo f, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this ParameterInfo p, NullabilityInfoContext? nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatTypeName(this ParameterInfo p, [Nullable(2)] NullabilityInfoContext nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this ParameterInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this PropertyInfo p, NullabilityInfoContext? nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatTypeName(this PropertyInfo p, [Nullable(2)] NullabilityInfoContext nullabilityInfoContext, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this PropertyInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this Type t, ICustomAttributeProvider? attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatValueDeclaration(object? val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
- public static bool IsLanguagePrimitiveType(Type t, [MaybeNullWhen(false)] out string? primitiveTypeName) {}
+ public static string FormatTypeName(this Type t, [Nullable(2)] ICustomAttributeProvider attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatValueDeclaration([Nullable(2)] object val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
+ public static bool IsLanguagePrimitiveType(Type t, [MaybeNullWhen(false)] out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class Generator {
- public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string? GenerateMemberDeclaration(MemberInfo member, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateTypeDeclaration(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ [return: Nullable(2)] public static string GenerateMemberDeclaration(MemberInfo member, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateTypeDeclaration(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public class GeneratorOptions : ICloneable {
+ [Nullable(byte.MinValue)]
+ [NullableContext(2)]
public class AttributeDeclarationOptions {
public AttributeDeclarationOptions() {}
public AttributeSectionFormat AccessorFormat { get; set; }
public AttributeSectionFormat AccessorParameterFormat { get; set; }
public AttributeSectionFormat BackingFieldFormat { get; set; }
public AttributeSectionFormat DelegateParameterFormat { get; set; }
public AttributeSectionFormat GenericParameterFormat { get; set; }
public AttributeSectionFormat MethodParameterFormat { get; set; }
public bool OmitAttributeSuffix { get; set; }
- public AttributeTypeFilter? TypeFilter { get; set; }
+ public AttributeTypeFilter TypeFilter { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(2)]
public class MemberDeclarationOptions {
public MemberDeclarationOptions() {}
public MethodBodyOption AccessorBody { get; set; }
public MethodBodyOption MethodBody { get; set; }
- public NullabilityInfoContext? NullabilityInfoContext { get; set; }
+ public NullabilityInfoContext NullabilityInfoContext { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(2)]
public class TypeDeclarationOptions {
public TypeDeclarationOptions() {}
- public NullabilityInfoContext? NullabilityInfoContext { get; set; }
+ public NullabilityInfoContext NullabilityInfoContext { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ValueDeclarationOptions {
public ValueDeclarationOptions() {}
public bool UseDefaultLiteral { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public GeneratorOptions() {}
public GeneratorOptions.AttributeDeclarationOptions AttributeDeclaration { get; init; }
public bool IgnorePrivateOrAssembly { get; set; }
- public string? Indent { get; set; }
+ [Nullable(2)]
+ public string Indent { get; set; }
public GeneratorOptions.MemberDeclarationOptions MemberDeclaration { get; init; }
public GeneratorOptions.ParameterDeclarationOptions ParameterDeclaration { get; init; }
public bool TranslateLanguagePrimitiveTypeDeclaration { get; set; }
public GeneratorOptions.TypeDeclarationOptions TypeDeclaration { get; init; }
public GeneratorOptions.ValueDeclarationOptions ValueDeclaration { get; init; }
public virtual GeneratorOptions Clone() {}
object ICloneable.Clone() {}
}
}
+
diff --git a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-netstandard2.0.apilist.cs b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-netstandard2.0.apilist.cs
index 66facf6..e1e0d99 100644
--- a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-netstandard2.0.apilist.cs
+++ b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-netstandard2.0.apilist.cs
@@ -1,122 +1,136 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.1)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.0.0
-// InformationalVersion: 1.1.0+074a83ab64ee9e829c2f3835cf0c03af8af0f59d
+// AssemblyVersion: 1.1.1.0
+// InformationalVersion: 1.1.1+9c1ed7379f1b7fe2562a51f0283b02332d84584f
// TargetFramework: .NETStandard,Version=v2.0
// Configuration: Release
-#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Runtime.CompilerServices;
using Smdn.Reflection;
using Smdn.Reflection.ReverseGenerating;
namespace Smdn.Reflection.ReverseGenerating {
public delegate bool AttributeTypeFilter(Type type, ICustomAttributeProvider attributeProvider);
public enum AttributeSectionFormat : int {
Discrete = 1,
List = 0,
}
public enum MethodBodyOption : int {
EmptyImplementation = 1,
None = 0,
ThrowNotImplementedException = 2,
ThrowNull = 3,
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class CSharpFormatter {
public static string EscapeString(string s, bool escapeSingleQuote = false, bool escapeDoubleQuote = false) {}
public static string FormatAccessibility(Accessibility accessibility) {}
public static string FormatParameter(ParameterInfo p, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(MethodBase m, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatParameterList(ParameterInfo[] parameterList, bool typeWithNamespace = true, bool useDefaultLiteral = false) {}
public static string FormatSpecialNameMethod(MethodBase methodOrConstructor, out MethodSpecialName nameType) {}
public static string FormatTypeName(this EventInfo ev, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this FieldInfo f, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this ParameterInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
public static string FormatTypeName(this PropertyInfo p, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatTypeName(this Type t, ICustomAttributeProvider? attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
- public static string FormatValueDeclaration(object? val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
+ public static string FormatTypeName(this Type t, [Nullable(2)] ICustomAttributeProvider attributeProvider = null, bool typeWithNamespace = true, bool withDeclaringTypeName = true, bool translateLanguagePrimitiveType = true) {}
+ public static string FormatValueDeclaration([Nullable(2)] object val, Type typeOfValue, bool typeWithNamespace = true, bool findConstantField = false, bool useDefaultLiteral = false) {}
public static bool IsLanguagePrimitiveType(Type t, out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public static class Generator {
- public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string? GenerateMemberDeclaration(MemberInfo member, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static string GenerateTypeDeclaration(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
- public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateAttributeList(ICustomAttributeProvider attributeProvider, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ [return: Nullable(2)] public static string GenerateMemberDeclaration(MemberInfo member, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateTypeDeclaration(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
+ public static IEnumerable<string> GenerateTypeDeclarationWithExplicitBaseTypeAndInterfaces(Type t, [Nullable] ISet<string> referencingNamespaces, GeneratorOptions options) {}
}
+ [Nullable(byte.MinValue)]
+ [NullableContext(1)]
public class GeneratorOptions : ICloneable {
+ [Nullable(byte.MinValue)]
+ [NullableContext(2)]
public class AttributeDeclarationOptions {
public AttributeDeclarationOptions() {}
public AttributeSectionFormat AccessorFormat { get; set; }
public AttributeSectionFormat AccessorParameterFormat { get; set; }
public AttributeSectionFormat BackingFieldFormat { get; set; }
public AttributeSectionFormat DelegateParameterFormat { get; set; }
public AttributeSectionFormat GenericParameterFormat { get; set; }
public AttributeSectionFormat MethodParameterFormat { get; set; }
public bool OmitAttributeSuffix { get; set; }
- public AttributeTypeFilter? TypeFilter { get; set; }
+ public AttributeTypeFilter TypeFilter { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class MemberDeclarationOptions {
public MemberDeclarationOptions() {}
public MethodBodyOption AccessorBody { get; set; }
public MethodBodyOption MethodBody { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class TypeDeclarationOptions {
public TypeDeclarationOptions() {}
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
+ [NullableContext(byte.MinValue)]
public class ValueDeclarationOptions {
public ValueDeclarationOptions() {}
public bool UseDefaultLiteral { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public GeneratorOptions() {}
public GeneratorOptions.AttributeDeclarationOptions AttributeDeclaration { get; init; }
public bool IgnorePrivateOrAssembly { get; set; }
- public string? Indent { get; set; }
+ [Nullable(2)]
+ public string Indent { get; set; }
public GeneratorOptions.MemberDeclarationOptions MemberDeclaration { get; init; }
public GeneratorOptions.ParameterDeclarationOptions ParameterDeclaration { get; init; }
public bool TranslateLanguagePrimitiveTypeDeclaration { get; set; }
public GeneratorOptions.TypeDeclarationOptions TypeDeclaration { get; init; }
public GeneratorOptions.ValueDeclarationOptions ValueDeclaration { get; init; }
public virtual GeneratorOptions Clone() {}
object ICloneable.Clone() {}
}
}
+
Full changes
Full changes in this release:
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating.csproj b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating.csproj
index c6b1298..b144e12 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating.csproj
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating.csproj
@@ -6,7 +6,7 @@ SPDX-License-Identifier: MIT
<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;net47;net45;netstandard2.0</TargetFrameworks>
<RootNamespace>Smdn.Reflection.ReverseGenerating</RootNamespace>
- <VersionPrefix>1.1.0</VersionPrefix>
+ <VersionPrefix>1.1.1</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
<Nullable>enable</Nullable>
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameWithNullabilityAnnotation.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameWithNullabilityAnnotation.cs
index ba8ffcd..cba8871 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameWithNullabilityAnnotation.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameWithNullabilityAnnotation.cs
@@ -80,6 +80,10 @@ static partial class CSharpFormatter {
if (IsValueTupleType(nullableUnderlyingType))
// special case for nullable value tuples (Nullable<ValueTuple<>>)
return FormatValueTuple(target, builder, options).Append(nullabilityAnnotationForByRefParameter);
+ else if (isGenericTypeClosedOrDefinition)
+ // case for nullable generic value types (Nullable<GenericValueType<>>)
+ // TODO: cannot get NullabilityInfo of generic type argument from Nullable<GenericValueType<>> (ex: KeyValuePair<int?, string?>?)
+ return builder.Append(FormatTypeNameCore(targetType, options));
targetType = nullableUnderlyingType;
}
@@ -100,6 +104,10 @@ static partial class CSharpFormatter {
.Append(nullabilityAnnotationForByRefParameter);
}
+ if (targetType.IsGenericParameter && targetType.HasGenericParameterNoConstraints())
+ // generic parameter which has no constraints must not have nullability annotation
+ return builder.Append(GetTypeName(targetType, options));
+
if (!targetType.IsGenericParameter) {
if (targetType.IsNested && options.WithDeclaringTypeName)
builder.Append(FormatTypeNameCore(targetType.GetDeclaringTypeOrThrow(), options)).Append('.');
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
index dddade0..20c1f44 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
@@ -156,30 +156,6 @@ public static partial class Generator {
static attr => attr.AttributeType.FullName.Equals("System.Runtime.CompilerServices.IsUnmanagedAttribute", StringComparison.Ordinal)
);
- static bool IsNullableAttribute(CustomAttributeData attr)
- => attr.AttributeType.FullName.Equals("System.Runtime.CompilerServices.NullableAttribute", StringComparison.Ordinal);
-
- static bool IsNullableContextAttribute(CustomAttributeData attr)
- => attr.AttributeType.FullName.Equals("System.Runtime.CompilerServices.NullableContextAttribute", StringComparison.Ordinal);
-
- // ref: https://github.com/dotnet/roslyn/blob/main/docs/features/nullable-metadata.md#type-parameters
- static bool HasNotNullConstraint(Type genericParameter)
- {
- var attrNullable = genericParameter.CustomAttributes.FirstOrDefault(IsNullableAttribute);
- var attrNullableContext =
- genericParameter.DeclaringMethod?.CustomAttributes?.FirstOrDefault(IsNullableContextAttribute) ??
- genericParameter.DeclaringType.CustomAttributes.FirstOrDefault(IsNullableContextAttribute);
-
- const byte notAnnotated = 1;
-
- if (attrNullableContext is not null && notAnnotated.Equals(attrNullableContext.ConstructorArguments[0].Value))
- // `#nullable enable` context
- return attrNullable is null;
- else
- // `#nullable disable` context
- return attrNullable is not null && notAnnotated.Equals(attrNullable.ConstructorArguments[0].Value);
- }
-
static bool IsValueType(Type t) => string.Equals(t.FullName, typeof(ValueType).FullName, StringComparison.Ordinal);
static bool IsNotValueType(Type t) => !string.Equals(t.FullName, typeof(ValueType).FullName, StringComparison.Ordinal);
@@ -197,7 +173,7 @@ public static partial class Generator {
if (
constraintAttrs == GenericParameterAttributes.None &&
- HasNotNullConstraint(genericParameter)
+ genericParameter.HasGenericParameterNotNullConstraint()
) {
yield return "notnull";
}
@@ -767,7 +743,7 @@ public static partial class Generator {
" ",
genericArguments
.Select(
- arg => Generator.GenerateGenericArgumentConstraintDeclaration(arg, referencingNamespaces, options)
+ arg => GenerateGenericArgumentConstraintDeclaration(arg, referencingNamespaces, options)
)
.Where(static d => !string.IsNullOrEmpty(d))
);
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeGenericParameterExtensions.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeGenericParameterExtensions.cs
new file mode 100644
index 0000000..9a0e57f
--- /dev/null
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeGenericParameterExtensions.cs
@@ -0,0 +1,100 @@
+// SPDX-FileCopyrightText: 2022 smdn <smdn@smdn.jp>
+// SPDX-License-Identifier: MIT
+#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET5_0_OR_GREATER
+#define SYSTEM_TYPE_ISGENERICMETHODPARAMETER
+#endif
+
+using System;
+#if NULL_STATE_STATIC_ANALYSIS_ATTRIBUTES
+using System.Diagnostics.CodeAnalysis;
+#endif
+using System.Linq;
+using System.Reflection;
+
+namespace Smdn.Reflection;
+
+internal static class TypeGenericParameterExtensions {
+ private static void ValidateGenericParameterArgument(Type param, string paramName)
+ {
+ if (param is null)
+ throw new ArgumentNullException(paramName);
+ if (!param.IsGenericParameter)
+ throw new InvalidOperationException($"{paramName} must be a generic parameter or generic argument");
+ }
+
+ // ref: https://github.com/dotnet/roslyn/blob/main/docs/features/nullable-metadata.md#type-parameters
+ public static bool HasGenericParameterNotNullConstraint(this Type genericParameter)
+ {
+ ValidateGenericParameterArgument(genericParameter, nameof(genericParameter));
+
+ var attrNullable = genericParameter.CustomAttributes.FirstOrDefault(IsNullableAttribute);
+ var attrNullableContext = FindNullableContextAttribute(genericParameter);
+
+ const byte notAnnotated = 1;
+
+ if (attrNullableContext is not null && notAnnotated.Equals(attrNullableContext.ConstructorArguments[0].Value))
+ // `#nullable enable` context
+ return attrNullable is null;
+ else
+ // `#nullable disable` context
+ return attrNullable is not null && notAnnotated.Equals(attrNullable.ConstructorArguments[0].Value);
+ }
+
+ private static bool IsNullableAttribute(CustomAttributeData attr)
+ => "System.Runtime.CompilerServices.NullableAttribute".Equals(attr.AttributeType.FullName, StringComparison.Ordinal);
+
+ private static bool IsNullableContextAttribute(CustomAttributeData attr)
+ => "System.Runtime.CompilerServices.NullableContextAttribute".Equals(attr.AttributeType.FullName, StringComparison.Ordinal);
+
+ private static bool TryGetNullableContextAttribute(
+ MemberInfo member,
+#if NULL_STATE_STATIC_ANALYSIS_ATTRIBUTES
+ [NotNullWhen(true)]
+#endif
+ out CustomAttributeData? attrNullableContext
+ )
+ {
+ attrNullableContext = member.CustomAttributes.FirstOrDefault(IsNullableContextAttribute);
+
+ return attrNullableContext is not null;
+ }
+
+ private static CustomAttributeData? FindNullableContextAttribute(Type genericParameter)
+ {
+ if (
+#if SYSTEM_TYPE_ISGENERICMETHODPARAMETER
+ genericParameter.IsGenericMethodParameter &&
+#else
+ genericParameter.DeclaringMethod is not null &&
+ genericParameter.IsGenericParameter &&
+#endif
+ TryGetNullableContextAttribute(genericParameter.DeclaringMethod!, out var methodAttr)
+ ) {
+ return methodAttr;
+ }
+
+ Type? t = genericParameter;
+
+ for (; ; ) {
+ if ((t = t!.DeclaringType) is null)
+ return null;
+ if (TryGetNullableContextAttribute(t, out var typeAttr))
+ return typeAttr;
+
+ // retry against to the outer type
+ continue;
+ }
+ }
+
+ public static bool HasGenericParameterNoConstraints(this Type genericParameter)
+ {
+ ValidateGenericParameterArgument(genericParameter, nameof(genericParameter));
+
+ var genericParameterConstraintAttrs = genericParameter.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask;
+
+ if (genericParameterConstraintAttrs != GenericParameterAttributes.None)
+ return false;
+
+ return !HasGenericParameterNotNullConstraint(genericParameter);
+ }
+}
Full Changelog: releases/Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks-1.1.0...releases/Smdn.Reflection.ReverseGenerating-1.1.1