Smdn.Reflection.ReverseGenerating version 1.1.3
·
355 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-22 update assembly version
- 2022-07-22 fix to validate option argument
- 2022-07-22 rename file according to declaring type name
- 2022-07-22 fix to validate arguments
- 2022-07-21 rename
GenerateGenericArgumentConstraintDeclarationtoGenerateGenericParameterConstraintDeclarationand mark as obsolete - 2022-07-21 fix to use the term of 'generic parameter' instead of 'generic argument'
- 2022-07-20 reformat
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 7044626..bc58591 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,123 +1,125 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.2)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.3)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.2.0
-// InformationalVersion: 1.1.2+775287448dc58ab1c9fb7f0618d8c8bb6de9e775
+// AssemblyVersion: 1.1.3.0
+// InformationalVersion: 1.1.3+f6167551bdfd2449c464509449137c454604db0f
// TargetFramework: .NETFramework,Version=v4.5
// Configuration: Release
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Reflection;
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,
}
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, out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
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) {}
+ [Obsolete("Use GenerateGenericParameterConstraintDeclaration instead.")]
public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericParameterConstraintDeclaration(Type genericParameter, 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 class GeneratorOptions : ICloneable {
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 bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
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 WithEnumTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
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; }
}
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; }
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 c5584e3..84062b4 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,123 +1,125 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.2)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.3)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.2.0
-// InformationalVersion: 1.1.2+775287448dc58ab1c9fb7f0618d8c8bb6de9e775
+// AssemblyVersion: 1.1.3.0
+// InformationalVersion: 1.1.3+f6167551bdfd2449c464509449137c454604db0f
// TargetFramework: .NETFramework,Version=v4.7
// Configuration: Release
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Reflection;
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,
}
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, out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
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) {}
+ [Obsolete("Use GenerateGenericParameterConstraintDeclaration instead.")]
public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericParameterConstraintDeclaration(Type genericParameter, 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 class GeneratorOptions : ICloneable {
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 bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
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 WithEnumTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
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; }
}
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; }
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 ff6378a..6d4f4bc 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,124 +1,126 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.2)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.3)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.2.0
-// InformationalVersion: 1.1.2+775287448dc58ab1c9fb7f0618d8c8bb6de9e775
+// AssemblyVersion: 1.1.3.0
+// InformationalVersion: 1.1.3+f6167551bdfd2449c464509449137c454604db0f
// TargetFramework: .NETCoreApp,Version=v5.0
// Configuration: Release
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
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,
}
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 IEnumerable<string> ToNamespaceList(Type t) {}
}
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) {}
+ [Obsolete("Use GenerateGenericParameterConstraintDeclaration instead.")]
public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericParameterConstraintDeclaration(Type genericParameter, 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 class GeneratorOptions : ICloneable {
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 bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
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 WithEnumTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
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; }
}
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; }
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 236901d..639194d 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,133 +1,135 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.2)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.3)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.2.0
-// InformationalVersion: 1.1.2+775287448dc58ab1c9fb7f0618d8c8bb6de9e775
+// AssemblyVersion: 1.1.3.0
+// InformationalVersion: 1.1.3+f6167551bdfd2449c464509449137c454604db0f
// TargetFramework: .NETCoreApp,Version=v6.0
// Configuration: Release
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
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,
}
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, 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, 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, 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, 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, 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, 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, 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 IEnumerable<string> ToNamespaceList(Type t) {}
}
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) {}
+ [Obsolete("Use GenerateGenericParameterConstraintDeclaration instead.")]
public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericParameterConstraintDeclaration(Type genericParameter, 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 class GeneratorOptions : ICloneable {
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 bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
public class MemberDeclarationOptions {
public MemberDeclarationOptions() {}
public MethodBodyOption AccessorBody { get; set; }
public MethodBodyOption MethodBody { get; set; }
public NullabilityInfoContext? NullabilityInfoContext { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool WithAccessibility { get; set; }
public bool WithDeclaringTypeName { get; set; }
public bool WithEnumTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public class TypeDeclarationOptions {
public TypeDeclarationOptions() {}
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; }
}
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; }
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 0dcbe84..ce55469 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,123 +1,125 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.2)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.1.3)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.1.2.0
-// InformationalVersion: 1.1.2+775287448dc58ab1c9fb7f0618d8c8bb6de9e775
+// AssemblyVersion: 1.1.3.0
+// InformationalVersion: 1.1.3+f6167551bdfd2449c464509449137c454604db0f
// TargetFramework: .NETStandard,Version=v2.0
// Configuration: Release
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.Reflection;
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,
}
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, out string primitiveTypeName) {}
public static IEnumerable<string> ToNamespaceList(Type t) {}
}
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) {}
+ [Obsolete("Use GenerateGenericParameterConstraintDeclaration instead.")]
public static string GenerateGenericArgumentConstraintDeclaration(Type genericArgument, ISet<string>? referencingNamespaces, GeneratorOptions options) {}
+ public static string GenerateGenericParameterConstraintDeclaration(Type genericParameter, 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 class GeneratorOptions : ICloneable {
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 bool WithDeclaringTypeName { get; set; }
public bool WithNamedArguments { get; set; }
public bool WithNamespace { get; set; }
}
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 WithEnumTypeName { get; set; }
public bool WithNamespace { get; set; }
}
public class ParameterDeclarationOptions {
public ParameterDeclarationOptions() {}
public bool WithDeclaringTypeName { get; set; }
public bool WithNamespace { get; set; }
}
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; }
}
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; }
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 4c7f3ca..4acc473 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.2</VersionPrefix>
+ <VersionPrefix>1.1.3</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
<Nullable>enable</Nullable>
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeName.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeName.cs
similarity index 100%
rename from src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeName.cs
rename to src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeName.cs
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameCore.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameCore.cs
similarity index 100%
rename from src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameCore.cs
rename to src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameCore.cs
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameWithNullabilityAnnotation.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameWithNullabilityAnnotation.cs
similarity index 100%
rename from src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.FormatTypeNameWithNullabilityAnnotation.cs
rename to src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameWithNullabilityAnnotation.cs
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.cs
similarity index 99%
rename from src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.cs
rename to src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.cs
index 6ecbac5..89cc7a9 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpTypeFormatter.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.cs
@@ -10,8 +10,6 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
-using Smdn.Reflection.Attributes;
-
namespace Smdn.Reflection.ReverseGenerating;
public static partial class CSharpFormatter /* ITypeFormatter */ {
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.Attributes.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.Attributes.cs
index 869e8d3..0032795 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.Attributes.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.Attributes.cs
@@ -39,6 +39,8 @@ partial class Generator {
{
if (attributeProvider is null)
throw new ArgumentNullException(nameof(attributeProvider));
+ if (options is null)
+ throw new ArgumentNullException(nameof(options));
const string attributeSectionPrefixDefault = "[";
const string attributeSectionPrefixField = "[field: ";
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
index 083d45c..d32235f 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
@@ -12,13 +12,33 @@ using System.Text;
namespace Smdn.Reflection.ReverseGenerating;
public static partial class Generator {
+ private static Type GenerateDeclarationValidateTypeArgument(Type? t, string paramName)
+ {
+ if (t is null)
+ throw new ArgumentNullException(paramName);
+ if (t.IsConstructedGenericType)
+ throw new ArgumentException($"can not generate declaration of constructed generic types (type: {t})");
+
+ return t;
+ }
+
+ private static Type GenerateDeclarationValidateGenericParameterArgument(Type? genericParameter, string paramName)
+ {
+ if (genericParameter is null)
+ throw new ArgumentNullException(paramName);
+ if (!genericParameter.IsGenericParameter)
+ throw new ArgumentException($"can not generate declaration of types which does not represent generic parameter ({genericParameter.FullName})");
+
+ return genericParameter;
+ }
+
public static string GenerateTypeDeclaration(
Type t,
ISet<string>? referencingNamespaces,
GeneratorOptions options
) =>
GenerateTypeDeclaration(
- t,
+ GenerateDeclarationValidateTypeArgument(t, nameof(t)),
false,
referencingNamespaces,
options ?? throw new ArgumentNullException(nameof(options))
@@ -30,7 +50,7 @@ public static partial class Generator {
GeneratorOptions options
) =>
GenerateTypeDeclaration(
- t,
+ GenerateDeclarationValidateTypeArgument(t, nameof(t)),
true,
referencingNamespaces,
options ?? throw new ArgumentNullException(nameof(options))
@@ -68,16 +88,16 @@ public static partial class Generator {
yield break;
}
- var genericArgumentConstraints = t
+ var genericParameterConstraints = t
.GetGenericArguments()
.Select(
- arg => GenerateGenericArgumentConstraintDeclaration(arg, referencingNamespaces, options)
+ param => GenerateGenericParameterConstraintDeclaration(param, referencingNamespaces, options)
)
.Where(static d => !string.IsNullOrEmpty(d))
.ToList();
- string GetSingleLineGenericArgumentConstraintsDeclaration()
- => genericArgumentConstraints.Count == 0 ? string.Empty : " " + string.Join(" ", genericArgumentConstraints);
+ string GetSingleLineGenericParameterConstraintsDeclaration()
+ => genericParameterConstraints.Count == 0 ? string.Empty : " " + string.Join(" ", genericParameterConstraints);
var modifierNew = t.IsHidingInheritedType(nonPublic: true) ? "new " : null;
@@ -111,7 +131,7 @@ public static partial class Generator {
}
if (!generateExplicitBaseTypeAndInterfaces) {
- yield return typeDeclaration + GetSingleLineGenericArgumentConstraintsDeclaration();
+ yield return typeDeclaration + GetSingleLineGenericParameterConstraintsDeclaration();
yield break;
}
@@ -121,9 +141,9 @@ public static partial class Generator {
var baseTypeDeclaration = baseTypeList.Count == 0
? string.Empty
: " : " + baseTypeList[0];
- var genericArgumentConstraintDeclaration = GetSingleLineGenericArgumentConstraintsDeclaration();
+ var genericParameterConstraintsDeclaration = GetSingleLineGenericParameterConstraintsDeclaration();
- yield return typeDeclaration + baseTypeDeclaration + genericArgumentConstraintDeclaration;
+ yield return typeDeclaration + baseTypeDeclaration + genericParameterConstraintsDeclaration;
}
else {
yield return typeDeclaration + " :";
@@ -135,18 +155,35 @@ public static partial class Generator {
yield return options.Indent + baseTypeList[index] + ",";
}
- foreach (var constraint in genericArgumentConstraints) {
+ foreach (var constraint in genericParameterConstraints) {
yield return options.Indent + constraint;
}
}
}
+ [Obsolete($"Use {nameof(GenerateGenericParameterConstraintDeclaration)} instead.")]
public static string GenerateGenericArgumentConstraintDeclaration(
Type genericArgument,
ISet<string>? referencingNamespaces,
GeneratorOptions options
+ )
+ => GenerateGenericParameterConstraintDeclaration(
+ genericParameter: GenerateDeclarationValidateGenericParameterArgument(genericArgument, nameof(genericArgument)),
+ referencingNamespaces: referencingNamespaces,
+ options: options
+ );
+
+ public static string GenerateGenericParameterConstraintDeclaration(
+ Type genericParameter,
+ ISet<string>? referencingNamespaces,
+ GeneratorOptions options
)
{
+ GenerateDeclarationValidateGenericParameterArgument(genericParameter, nameof(genericParameter));
+
+ if (options is null)
+ throw new ArgumentNullException(nameof(options));
+
static bool HasUnmanagedConstraint(Type genericParameter)
=> genericParameter.CustomAttributes.Any(
static attr => attr.AttributeType.FullName.Equals("System.Runtime.CompilerServices.IsUnmanagedAttribute", StringComparison.Ordinal)
@@ -155,7 +192,7 @@ public static partial class Generator {
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);
- static IEnumerable<string> GetGenericArgumentConstraintsOf(
+ static IEnumerable<string> GetGenericParameterConstraintsOf(
Type genericParameter,
ISet<string>? referencingNns,
bool typeWithNamespace
@@ -211,17 +248,17 @@ public static partial class Generator {
var constraints = string.Join(
", ",
- GetGenericArgumentConstraintsOf(
- genericArgument,
+ GetGenericParameterConstraintsOf(
+ genericParameter,
referencingNamespaces,
- genericArgument.DeclaringMethod == null
+ genericParameter.DeclaringMethod == null
? options.TypeDeclaration.WithNamespace
: options.MemberDeclaration.WithNamespace
)
);
if (0 < constraints.Length)
- return $"where {genericArgument.FormatTypeName(typeWithNamespace: false)} : {constraints}";
+ return $"where {genericParameter.FormatTypeName(typeWithNamespace: false)} : {constraints}";
return string.Empty;
}
@@ -232,6 +269,8 @@ public static partial class Generator {
GeneratorOptions options
)
{
+ if (t is null)
+ throw new ArgumentNullException(nameof(t));
if (options == null)
throw new ArgumentNullException(nameof(options));
@@ -666,7 +705,10 @@ public static partial class Generator {
{
MethodInfo? explicitInterfaceMethod = null;
- if (!asDelegateDeclaration) {
+ if (asDelegateDeclaration) {
+ GenerateDeclarationValidateTypeArgument(m.GetDeclaringTypeOrThrow(), nameof(m));
+ }
+ else {
var isExplicitInterfaceMethod = m.TryFindExplicitInterfaceMethod(
out explicitInterfaceMethod,
findOnlyPublicInterfaces: options.IgnorePrivateOrAssembly
@@ -728,18 +770,20 @@ public static partial class Generator {
p => GenerateParameterDeclaration(p, referencingNamespaces, options)
)
);
- var genericArguments = method is null
+ var genericParameters = method is null
? null
: asDelegateDeclaration
? m.GetDeclaringTypeOrThrow().GetGenericArguments()
- : method.GetGenericArguments();
- var methodConstraints = genericArguments is null
+ : method.IsGenericMethodDefinition
+ ? method.GetGenericArguments()
+ : null;
+ var methodConstraints = genericParameters is null
? null
: string.Join(
" ",
- genericArguments
+ genericParameters
.Select(
- arg => GenerateGenericArgumentConstraintDeclaration(arg, referencingNamespaces, options)
+ param => GenerateGenericParameterConstraintDeclaration(param, referencingNamespaces, options)
)
.Where(static d => !string.IsNullOrEmpty(d))
);
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeElementTypeExtensions.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeElementTypeExtensions.cs
index 1a87ec2..67b51f2 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeElementTypeExtensions.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeElementTypeExtensions.cs
@@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2022 smdn <smdn@smdn.jp>
// SPDX-License-Identifier: MIT
using System;
-using System.Reflection;
namespace Smdn.Reflection;
Full Changelog: releases/Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks-1.1.2...releases/Smdn.Reflection.ReverseGenerating-1.1.3