Smdn.Reflection.ReverseGenerating version 1.3.0
smdn
released this
11 Feb 09:33
·
49 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:
- 2024-02-11 update assembly version
- 2024-02-10 improve Generate[Property|Event]Declaration() to work in reflection-only context
- 2024-02-10 bump Smdn.Fundamental.Reflection up to 3.6.0
- 2024-02-10 improve to support 'ref readonly' fields
- 2024-02-10 split workaround classes into individual files
- 2024-02-10 reduce duplicate code
- 2024-02-10 add support for C# 11 'ref' fields
- 2024-02-09 disable NullabilityInfo workarounds for by-ref types on .NET 8.0 or greater
- 2024-02-08 improve formatting default value for enum or value type to support for reflection-only context
- 2024-02-08 improve CompilerGeneratedAttribute detection for event accessor methods to support for reflection-only context
- 2024-02-08 improve option OmitAttributeSuffix to support for reflection-only context
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 d3f7e7d..3ee4c42 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,134 +1,134 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.2.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.3.0)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.2.0.0
-// InformationalVersion: 1.2.0+ce6c623225b7a5aa5f272f2a960a28811e358e41
+// AssemblyVersion: 1.3.0.0
+// InformationalVersion: 1.3.0+1e9a9d918b8a2ba6fe994e2fa60ff5f7c5b2544e
// TargetFramework: .NETFramework,Version=v4.5
// Configuration: Release
// Referenced assemblies:
-// Smdn.Fundamental.Reflection, Version=3.5.0.0, Culture=neutral
+// Smdn.Fundamental.Reflection, Version=3.6.0.0, Culture=neutral
// System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
#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 OmitEnumUnderlyingTypeIfPossible { 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() {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.0.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.1.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
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 b2a9837..7e7faee 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,133 +1,133 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.2.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.3.0)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.2.0.0
-// InformationalVersion: 1.2.0+ce6c623225b7a5aa5f272f2a960a28811e358e41
+// AssemblyVersion: 1.3.0.0
+// InformationalVersion: 1.3.0+1e9a9d918b8a2ba6fe994e2fa60ff5f7c5b2544e
// TargetFramework: .NETFramework,Version=v4.7
// Configuration: Release
// Referenced assemblies:
-// Smdn.Fundamental.Reflection, Version=3.5.0.0, Culture=neutral
+// Smdn.Fundamental.Reflection, Version=3.6.0.0, Culture=neutral
// System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
#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 OmitEnumUnderlyingTypeIfPossible { 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() {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.0.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.1.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
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 b19eafc..de3fbcb 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,155 +1,155 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.2.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.3.0)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.2.0.0
-// InformationalVersion: 1.2.0+ce6c623225b7a5aa5f272f2a960a28811e358e41
+// AssemblyVersion: 1.3.0.0
+// InformationalVersion: 1.3.0+1e9a9d918b8a2ba6fe994e2fa60ff5f7c5b2544e
// TargetFramework: .NETCoreApp,Version=v6.0
// Configuration: Release
// Referenced assemblies:
-// Smdn.Fundamental.Reflection, Version=3.5.0.0, Culture=neutral
+// Smdn.Fundamental.Reflection, Version=3.6.0.0, Culture=neutral
// System.Collections, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Linq, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Memory, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Runtime.InteropServices, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Threading, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
#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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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 object? NullabilityInfoContextLockObject { 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 object? NullabilityInfoContextLockObject { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool OmitEnumUnderlyingTypeIfPossible { 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() {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.0.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.1.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
diff --git a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net8.0.apilist.cs b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net8.0.apilist.cs
index 1efb8e2..5964868 100644
--- a/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net8.0.apilist.cs
+++ b/doc/api-list/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating-net8.0.apilist.cs
@@ -1,155 +1,155 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.2.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.3.0)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.2.0.0
-// InformationalVersion: 1.2.0+ce6c623225b7a5aa5f272f2a960a28811e358e41
+// AssemblyVersion: 1.3.0.0
+// InformationalVersion: 1.3.0+1e9a9d918b8a2ba6fe994e2fa60ff5f7c5b2544e
// TargetFramework: .NETCoreApp,Version=v8.0
// Configuration: Release
// Referenced assemblies:
-// Smdn.Fundamental.Reflection, Version=3.5.0.0, Culture=neutral
+// Smdn.Fundamental.Reflection, Version=3.6.0.0, Culture=neutral
// System.Collections, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Linq, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Memory, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Runtime.InteropServices, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Threading, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
#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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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, NullabilityInfoContext? nullabilityInfoContext, object? nullabilityInfoContextLockObject, 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 object? NullabilityInfoContextLockObject { 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 object? NullabilityInfoContextLockObject { get; set; }
public bool OmitEndOfStatement { get; set; }
public bool OmitEnumUnderlyingTypeIfPossible { 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() {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.0.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.1.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
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 525ffc4..39b388d 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,131 +1,131 @@
-// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.2.0)
+// Smdn.Reflection.ReverseGenerating.dll (Smdn.Reflection.ReverseGenerating-1.3.0)
// Name: Smdn.Reflection.ReverseGenerating
-// AssemblyVersion: 1.2.0.0
-// InformationalVersion: 1.2.0+ce6c623225b7a5aa5f272f2a960a28811e358e41
+// AssemblyVersion: 1.3.0.0
+// InformationalVersion: 1.3.0+1e9a9d918b8a2ba6fe994e2fa60ff5f7c5b2544e
// TargetFramework: .NETStandard,Version=v2.0
// Configuration: Release
// Referenced assemblies:
-// Smdn.Fundamental.Reflection, Version=3.5.0.0, Culture=neutral
+// Smdn.Fundamental.Reflection, Version=3.6.0.0, Culture=neutral
// netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
#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 OmitEnumUnderlyingTypeIfPossible { 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() {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.0.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.1.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
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 b91b796..36a6e02 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>net8.0;net6.0;net47;net45;netstandard2.0</TargetFrameworks>
<RootNamespace>Smdn.Reflection.ReverseGenerating</RootNamespace>
- <VersionPrefix>1.2.0</VersionPrefix>
+ <VersionPrefix>1.3.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
<RootNamespace/> <!-- empty the root namespace so that the namespace is determined only by the directory name, for code style rule IDE0030 -->
@@ -26,10 +26,10 @@ SPDX-License-Identifier: MIT
$(TargetFramework.StartsWith('netstandard2'))
)
">$(DefineConstants);CAN_OVERRIDE_CUSTOMATTRIBUTEDATA_ATTRIBUTETYPE</DefineConstants>
+ <!-- enable workaround only on .NET 6.x and .NET 7.x -->
<DefineConstants Condition="
- $(TargetFramework.StartsWith('net6.0')) or
- $(TargetFramework.StartsWith('net7.0')) or
- $(TargetFramework.StartsWith('net8.0'))
+ $(TargetFramework.StartsWith('net6.')) or
+ $(TargetFramework.StartsWith('net7.'))
">$(DefineConstants);WORKAROUND_NULLABILITYINFO_BYREFTYPE</DefineConstants>
</PropertyGroup>
@@ -44,7 +44,7 @@ SPDX-License-Identifier: MIT
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" Condition="$(TargetFramework.StartsWith('net45')) or $(TargetFramework.StartsWith('net46')) or $(TargetFramework.StartsWith('netstandard1'))" />
- <PackageReference Include="Smdn.Fundamental.Reflection" Version="[3.5.0,4.0.0)" />
+ <PackageReference Include="Smdn.Fundamental.Reflection" Version="[3.6.0,4.0.0)" />
</ItemGroup>
<ItemGroup>
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeName.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeName.cs
index ebf2255..7167f64 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeName.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeName.cs
@@ -14,7 +14,7 @@ static partial class CSharpFormatter {
bool TypeWithNamespace,
bool WithDeclaringTypeName,
bool TranslateLanguagePrimitiveType,
-#if SYSTEM_REFLECTION_NULLABILITYINFOCONTEXT && WORKAROUND_NULLABILITYINFO_BYREFTYPE
+#if SYSTEM_REFLECTION_NULLABILITYINFOCONTEXT
NullabilityInfoContext? NullabilityInfoContext = null,
#endif
Func<Type, string, string>? GenericParameterNameModifier = null,
@@ -78,9 +78,7 @@ static partial class CSharpFormatter {
AttributeProvider: f,
TypeWithNamespace: typeWithNamespace,
WithDeclaringTypeName: withDeclaringTypeName,
-#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
NullabilityInfoContext: nullabilityInfoContext,
-#endif
TranslateLanguagePrimitiveType: translateLanguagePrimitiveType
)
).ToString();
@@ -141,9 +139,7 @@ static partial class CSharpFormatter {
AttributeProvider: p,
TypeWithNamespace: typeWithNamespace,
WithDeclaringTypeName: withDeclaringTypeName,
-#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
NullabilityInfoContext: nullabilityInfoContext,
-#endif
TranslateLanguagePrimitiveType: translateLanguagePrimitiveType
)
).ToString();
@@ -204,9 +200,7 @@ static partial class CSharpFormatter {
AttributeProvider: p,
TypeWithNamespace: typeWithNamespace,
WithDeclaringTypeName: withDeclaringTypeName,
-#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
NullabilityInfoContext: nullabilityInfoContext,
-#endif
TranslateLanguagePrimitiveType: translateLanguagePrimitiveType
)
).ToString();
@@ -267,9 +261,7 @@ static partial class CSharpFormatter {
AttributeProvider: ev,
TypeWithNamespace: typeWithNamespace,
WithDeclaringTypeName: withDeclaringTypeName,
-#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
NullabilityInfoContext: nullabilityInfoContext,
-#endif
TranslateLanguagePrimitiveType: translateLanguagePrimitiveType
)
).ToString();
@@ -300,7 +292,7 @@ static partial class CSharpFormatter {
if (
options.OmitAttributeSuffix &&
typeName.EndsWith("Attribute", StringComparison.Ordinal) &&
- typeof(Attribute).IsAssignableFrom(t) &&
+ (typeof(Attribute).IsAssignableFrom(t) || IsAttributeType(t)) &&
t != typeof(Attribute)
) {
const int LengthOfAttributeSuffix = 9; // "Attribute".Length
@@ -309,5 +301,21 @@ static partial class CSharpFormatter {
}
return typeName;
+
+ // alternative method to Type.IsAssignableTo(typeof(Attribute)) for the
+ // reflection-only context types
+ static bool IsAttributeType(Type maybeReflectionOnlyType)
+ {
+ var t = maybeReflectionOnlyType.BaseType;
+
+ for (; ; ) {
+ if (t is null)
+ return false;
+ if (string.Equals(t.FullName, "System.Attribute", StringComparison.Ordinal))
+ return true;
+
+ t = t.BaseType;
+ }
+ }
}
}
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameCore.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameCore.cs
index 1a45bd1..bd43cb3 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameCore.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameCore.cs
@@ -57,6 +57,9 @@ static partial class CSharpFormatter {
case PropertyInfo p:
return "ref " + typeName;
+ case FieldInfo f:
+ return "ref " + typeName;
+
default:
return typeName + "&";
}
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameWithNullabilityAnnotation.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameWithNullabilityAnnotation.cs
index e67be21..ace0b60 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameWithNullabilityAnnotation.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameWithNullabilityAnnotation.cs
@@ -3,9 +3,6 @@
#if SYSTEM_REFLECTION_NULLABILITYINFO
using System;
using System.Collections.Generic;
-#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
-using System.Globalization;
-#endif
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -18,53 +15,22 @@ namespace Smdn.Reflection.ReverseGenerating;
#pragma warning disable IDE0040
static partial class CSharpFormatter {
#pragma warning restore IDE0040
-
-#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
- // Workaround: The pseudo ParameterInfo type which unwraps 'ByRef' type to its element type
- // See https://github.com/dotnet/runtime/issues/72320
- private sealed class ByRefElementTypeParameterInfo : ParameterInfo {
- public ParameterInfo BaseParameter { get; }
-
- public ByRefElementTypeParameterInfo(ParameterInfo baseParam)
+#if DEBUG
+ private static void ThrowIfTypeIsCompoundType(Type type, string name)
{
- BaseParameter = baseParam;
- }
-
- public override MemberInfo Member => BaseParameter.Member;
- public override Type ParameterType => BaseParameter.ParameterType.GetElementType()!;
- public override IList<CustomAttributeData> GetCustomAttributesData()
- => BaseParameter.GetCustomAttributesData();
+ if (type.IsArray || type.IsPointer || type.IsByRef)
+ throw new InvalidOperationException($"'{name}' is expected to be non-compound elemental type, but was compound: {type}");
}
+#endif
- private sealed class ByRefElementTypePropertyInfo : PropertyInfo {
- public PropertyInfo BaseProperty { get; }
-
- public ByRefElementTypePropertyInfo(PropertyInfo baseProperty)
+ private static string GetNullabilityAnnotation(NullabilityInfo target)
{
- BaseProperty = baseProperty;
- }
+ const string NullableAnnotationSyntaxString = "?";
- public override string Name => BaseProperty.Name;
- public override PropertyAttributes Attributes => BaseProperty.Attributes;
- public override bool CanRead => BaseProperty.CanRead;
- public override bool CanWrite => BaseProperty.CanWrite;
- public override Type PropertyType => BaseProperty.PropertyType.GetElementType()!;
- public override Type? DeclaringType => BaseProperty.DeclaringType;
- public override Type? ReflectedType => BaseProperty.ReflectedType;
- public override IList<CustomAttributeData> GetCustomAttributesData() => BaseProperty.GetCustomAttributesData();
- public override object[] GetCustomAttributes(bool inherit) => BaseProperty.GetCustomAttributes(inherit);
- public override object[] GetCustomAttributes(Type attributeType, bool inherit) => BaseProperty.GetCustomAttributes(attributeType, inherit);
- public override bool IsDefined(Type attributeType, bool inherit) => BaseProperty.IsDefined(attributeType, inherit);
- public override MethodInfo[] GetAccessors(bool nonPublic) => BaseProperty.GetAccessors(nonPublic);
- public override MethodInfo? GetGetMethod(bool nonPublic) => BaseProperty.GetGetMethod(nonPublic);
- public override MethodInfo? GetSetMethod(bool nonPublic) => BaseProperty.GetSetMethod(nonPublic);
- public override ParameterInfo[] GetIndexParameters() => BaseProperty.GetIndexParameters();
- public override object? GetValue(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? index, CultureInfo? culture)
- => BaseProperty.GetValue(obj, invokeAttr, binder, index, culture);
- public override void SetValue(object? obj, object? value, BindingFlags invokeAttr, Binder? binder, object?[]? index, CultureInfo? culture)
- => BaseProperty.SetValue(obj, value, invokeAttr, binder, index, culture);
+ return target.ReadState == NullabilityState.Nullable || target.WriteState == NullabilityState.Nullable
+ ? NullableAnnotationSyntaxString
+ : string.Empty;
}
-#endif
#pragma warning disable CA1502 // TODO: reduce code complexity
private static StringBuilder FormatTypeNameWithNullabilityAnnotation(
@@ -73,13 +39,6 @@ static partial class CSharpFormatter {
FormatTypeNameOptions options
)
{
- const string NullableAnnotationSyntaxString = "?";
-
- static string GetNullabilityAnnotation(NullabilityInfo target)
- => target.ReadState == NullabilityState.Nullable || target.WriteState == NullabilityState.Nullable
- ? NullableAnnotationSyntaxString
- : string.Empty;
-
if (target.Type.IsByRef) {
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
var elementTypeNullabilityInfo = target.ElementType;
@@ -100,7 +59,7 @@ static partial class CSharpFormatter {
// Uses the workaround implementation instead in that case.
// See https://github.com/dotnet/runtime/issues/72320
if (options.NullabilityInfoContext is not null && target.ElementType is null && para.ParameterType.HasElementType)
- elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new ByRefElementTypeParameterInfo(para));
+ elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new UnwrapByRefParameterInfo(para));
#endif
break;
@@ -109,8 +68,28 @@ static partial class CSharpFormatter {
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
if (options.NullabilityInfoContext is not null && target.ElementType is null && p.PropertyType.HasElementType)
- elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new ByRefElementTypePropertyInfo(p));
+ elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new UnwrapByRefPropertyInfo(p));
+#endif
+ break;
+
+ // C# 11 ref fields
+ // https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/ref-struct#ref-fields
+ case FieldInfo f:
+ builder.Append("ref ");
+
+ if (f.IsReadOnly())
+ builder.Append("readonly ");
+
+#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
+#if NET7_0_OR_GREATER
+ if (options.NullabilityInfoContext is not null && f.FieldType.HasElementType)
+#else
+ if (options.NullabilityInfoContext is not null && target.ElementType is null && f.FieldType.HasElementType)
#endif
+ elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new UnwrapByRefFieldInfo(f));
+
+#endif
+
break;
}
@@ -122,41 +101,46 @@ static partial class CSharpFormatter {
options
);
}
-#else
- return FormatTypeNameWithNullabilityAnnotation(
- target.ElementType!,
- builder,
- options
- );
#endif
}
- if (target.Type.IsArray) {
- // arrays
- return FormatTypeNameWithNullabilityAnnotation(target.ElementType!, builder, options)
- .Append('[')
- .Append(',', target.Type.GetArrayRank() - 1)
- .Append(']')
- .Append(GetNullabilityAnnotation(target));
- }
+ var type = target.Type;
- if (target.Type.IsPointer || target.Type.IsByRef)
- // pointer types or ByRef types (exclude ParameterInfo and PropertyInfo)
- return builder.Append(FormatTypeNameCore(target.Type, options));
+ if (type.IsArray)
+ return FormatArray(target, type, builder, options);
+
+#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
+ if (type.IsPointer || type.IsByRef)
+ // pointer types or by-ref types (exclude ParameterInfo, PropertyInfo and FieldInfo)
+#else
+ if (type.IsByRef)
+ type = type.GetElementType()!;
+
+ if (type.IsArray)
+ return FormatArray(target, type, builder, options);
+
+ if (type.IsPointer)
+ // pointer types
+#endif
+ return builder.Append(FormatTypeNameCore(type, options));
+
+#if DEBUG
+ // where 'type' should be an non-compound elemental type (i.e., the element type of a type of an array, pointer, or by-ref)
+ ThrowIfTypeIsCompoundType(type, nameof(type));
+#endif
- if (IsValueTupleType(target.Type)) {
+ if (IsValueTupleType(type)) {
// special case for value tuples (ValueTuple<>)
return FormatValueTupleType(target, builder, options)
.Append(GetNullabilityAnnotation(target));
}
- var targetType = target.Type;
var isGenericTypeClosedOrDefinition =
- targetType.IsGenericTypeDefinition ||
- targetType.IsConstructedGenericType ||
- (targetType.IsGenericType && targetType.ContainsGenericParameters);
+ type.IsGenericTypeDefinition ||
+ type.IsConstructedGenericType ||
+ (type.IsGenericType && type.ContainsGenericParameters);
- if (Nullable.GetUnderlyingType(targetType) is Type nullableUnderlyingType) {
+ if (Nullable.GetUnderlyingType(type) is Type nullableUnderlyingType) {
// nullable value types (Nullable<>)
if (IsValueTupleType(nullableUnderlyingType)) {
// special case for nullable value tuples (Nullable<ValueTuple<>>)
@@ -169,67 +153,73 @@ static partial class CSharpFormatter {
.Append(GetNullabilityAnnotation(target));
}
- targetType = nullableUnderlyingType;
+ type = nullableUnderlyingType;
}
else if (isGenericTypeClosedOrDefinition) {
// other generic types
- if (targetType.IsByRef) {
-#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
- // TODO: cannot get NullabilityInfo of generic type arguments from by-ref parameter type
- return builder.Append(FormatTypeNameCore(targetType, options));
-#else
- return FormatTypeNameWithNullabilityAnnotation(target.ElementType!, builder, options);
-#endif
- }
- else {
return FormatClosedGenericTypeOrGenericTypeDefinition(target, builder, options)
.Append(GetNullabilityAnnotation(target));
}
- }
- if (options.TranslateLanguagePrimitiveType && IsLanguagePrimitiveType(targetType, out var n)) {
+ if (options.TranslateLanguagePrimitiveType && IsLanguagePrimitiveType(type, out var n)) {
// language primitive types
return builder
.Append(n)
.Append(GetNullabilityAnnotation(target));
}
- if (targetType.IsGenericParameter && targetType.HasGenericParameterNoConstraints())
+ if (type.IsGenericParameter && type.HasGenericParameterNoConstraints())
// generic parameter which has no constraints must not have nullability annotation
- return builder.Append(GetTypeName(targetType, options));
+ return builder.Append(GetTypeName(type, options));
- if (!targetType.IsGenericParameter) {
- if (targetType.IsNested && options.WithDeclaringTypeName)
- builder.Append(FormatTypeNameCore(targetType.GetDeclaringTypeOrThrow(), options)).Append('.');
+ if (!type.IsGenericParameter) {
+ if (type.IsNested && options.WithDeclaringTypeName)
+ builder.Append(FormatTypeNameCore(type.GetDeclaringTypeOrThrow(), options)).Append('.');
else if (options.TypeWithNamespace)
- builder.Append(targetType.Namespace).Append('.');
+ builder.Append(type.Namespace).Append('.');
}
return builder
- .Append(GetTypeName(targetType, options))
+ .Append(GetTypeName(type, options))
.Append(GetNullabilityAnnotation(target));
}
#pragma warning restore CA1502
+ private static StringBuilder FormatArray(
+ NullabilityInfo target,
+ Type typeOfArray,
+ StringBuilder builder,
+ FormatTypeNameOptions options
+ )
+ => FormatTypeNameWithNullabilityAnnotation(target.ElementType!, builder, options)
+ .Append('[')
+ .Append(',', typeOfArray.GetArrayRank() - 1)
+ .Append(']')
+ .Append(GetNullabilityAnnotation(target));
+
private static StringBuilder FormatClosedGenericTypeOrGenericTypeDefinition(
NullabilityInfo target,
StringBuilder builder,
FormatTypeNameOptions options
)
{
- if (options.TypeWithNamespace && !target.Type.IsNested)
- builder.Append(target.Type.Namespace).Append('.');
+ var type = target.Type.IsByRef
+ ? target.Type.GetElementType()!
+ : target.Type;
+
+ if (options.TypeWithNamespace && !type.IsNested)
+ builder.Append(type.Namespace).Append('.');
IEnumerable<NullabilityInfo> genericTypeArguments = target.GenericTypeArguments;
- if (target.Type.IsNested) {
- var declaringType = target.Type.GetDeclaringTypeOrThrow();
+ if (type.IsNested) {
+ var declaringType = type.GetDeclaringTypeOrThrow();
var genericArgsOfDeclaringType = declaringType.GetGenericArguments();
if (options.WithDeclaringTypeName) {
if (declaringType.IsGenericTypeDefinition) {
declaringType = declaringType.MakeGenericType(
- target.Type.GetGenericArguments().Take(genericArgsOfDeclaringType.Length).ToArray()
+ type.GetGenericArguments().Take(genericArgsOfDeclaringType.Length).ToArray()
);
}
@@ -239,7 +229,7 @@ static partial class CSharpFormatter {
genericTypeArguments = genericTypeArguments.Skip(genericArgsOfDeclaringType.Length);
}
- builder.Append(GetTypeName(target.Type, options));
+ builder.Append(GetTypeName(type, options));
if (genericTypeArguments.Any()) {
builder.Append('<');
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.cs
index 88adb0f..a12675b 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.cs
@@ -589,10 +589,28 @@ public static partial class CSharpFormatter /* ITypeFormatter */ {
return ToString(typeOfValue, options) + "." + f.Name;
}
- if (!typeOfValue.IsPrimitive && val.Equals(Activator.CreateInstance(typeOfValue)))
+ if (!typeOfValue.IsPrimitive) {
+ object? defaultValue;
+
+ try {
+ defaultValue = Activator.CreateInstance(type: typeOfValue);
+ }
+ catch (ArgumentException ex) when (
+ // "Type must be a type provided by the runtime. (Parameter 'type')"
+ string.Equals(ex.ParamName, "type", StringComparison.Ordinal)
+ ) {
+ // may be reflection-only context
+ if (typeOfValue.IsEnum)
+ return "(" + ToString(typeOfValue, options) + ")" + val.ToString();
+
+ return val.ToString() ?? string.Empty;
+ }
+
+ if (val.Equals(defaultValue))
// format as 'default'
return ToDefaultValue(typeOfValue, options);
}
+ }
if (typeOfValue.IsEnum)
return "(" + ToString(typeOfValue, options) + ")" + Convert.ChangeType(val, typeOfValue.GetEnumUnderlyingType(), provider: null);
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
index bcc71a4..8028349 100644
--- a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.cs
@@ -455,11 +455,15 @@ public static partial class Generator {
var explicitInterfaceMethod = property
.GetAccessors(true)
.Select(
- a => a.FindExplicitInterfaceMethod(
+ a => a.TryFindExplicitInterfaceMethod(
+ out var eim,
findOnlyPublicInterfaces: options.IgnorePrivateOrAssembly
)
+ ? eim
+ : null // Type.GetInterfaceMap() is not supported in reflection-only context
)
- .FirstOrDefault();
+ .FirstOrDefault(static a => a is not null);
+
var explicitInterface = explicitInterfaceMethod?.DeclaringType;
if (
@@ -1040,12 +1044,16 @@ public static partial class Generator {
{
var explicitInterfaceMethod = ev
.GetMethods(true)
- .Select(evm =>
- evm.FindExplicitInterfaceMethod(
+ .Select(
+ evm => evm.TryFindExplicitInterfaceMethod(
+ out var eim,
findOnlyPublicInterfaces: options.IgnorePrivateOrAssembly
)
+ ? eim
+ : null // Type.GetInterfaceMap() is not supported in reflection-only context
)
- .FirstOrDefault();
+ .FirstOrDefault(static evm => evm is not null);
+
var explicitInterface = explicitInterfaceMethod?.DeclaringType;
if (
@@ -1116,10 +1124,9 @@ public static partial class Generator {
);
}
- var emitAccessor = !ev.GetDeclaringTypeOrThrow().IsInterface && (
- ev.AddMethod?.GetCustomAttribute<CompilerGeneratedAttribute>() is null ||
- ev.RemoveMethod?.GetCustomAttribute<CompilerGeneratedAttribute>() is null
- );
+ static bool IsCompilerGeneratedAttribute(CustomAttributeData d)
+ => d.AttributeType == typeof(CompilerGeneratedAttribute)
+ || string.Equals(d.AttributeType.FullName, "System.Runtime.CompilerServices.CompilerGeneratedAttribute", StringComparison.Ordinal);
static bool HasAttributeExceptCompilerGeneratedAttribute(MethodInfo? accessor, AttributeTypeFilter? filter)
{
@@ -1127,15 +1134,21 @@ public static partial class Generator {
return false;
var attributesExceptCompilerGenerated = accessor
- .GetCustomAttributes()
- .Where(static a => a.GetType() != typeof(CompilerGeneratedAttribute));
+ .GetCustomAttributesData()
+ .Where(static d => !IsCompilerGeneratedAttribute(d));
if (filter is null)
return attributesExceptCompilerGenerated.Any();
else
- return attributesExceptCompilerGenerated.Any(a => filter(a.GetType(), accessor));
+ return attributesExceptCompilerGenerated.Any(d => filter(d.AttributeType, accessor));
}
+ var compilerGeneratedAccessors =
+ (ev.AddMethod?.GetCustomAttributesData()?.Any(IsCompilerGeneratedAttribute) ?? false) &&
+ (ev.RemoveMethod?.GetCustomAttributesData()?.Any(IsCompilerGeneratedAttribute) ?? false);
+
+ var emitAccessor = !ev.GetDeclaringTypeOrThrow().IsInterface && !compilerGeneratedAccessors;
+
emitAccessor |= HasAttributeExceptCompilerGeneratedAttribute(ev.AddMethod, options.AttributeDeclaration.TypeFilter);
emitAccessor |= HasAttributeExceptCompilerGeneratedAttribute(ev.RemoveMethod, options.AttributeDeclaration.TypeFilter);
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefFieldInfo.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefFieldInfo.cs
new file mode 100644
index 0000000..cc18866
--- /dev/null
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefFieldInfo.cs
@@ -0,0 +1,40 @@
+// SPDX-FileCopyrightText: 2024 smdn <smdn@smdn.jp>
+// SPDX-License-Identifier: MIT
+#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Reflection;
+
+namespace Smdn.Reflection;
+
+// Workaround: The pseudo FieldInfo type which unwraps 'ByRef' type to its element type
+// See https://github.com/dotnet/runtime/issues/72320
+internal sealed class UnwrapByRefFieldInfo : FieldInfo {
+ public FieldInfo BaseField { get; }
+
+ public UnwrapByRefFieldInfo(FieldInfo baseField)
+ {
+#if DEBUG
+ if (!baseField.FieldType.IsByRef)
+ throw new ArgumentException($"{baseField.FieldType} must be by-ref");
+#endif
+
+ BaseField = baseField;
+ }
+
+ public override string Name => BaseField.Name;
+ public override FieldAttributes Attributes => BaseField.Attributes;
+ public override Type FieldType => BaseField.FieldType.GetElementType()!;
+ public override Type? DeclaringType => BaseField.DeclaringType;
+ public override Type? ReflectedType => BaseField.ReflectedType;
+ public override RuntimeFieldHandle FieldHandle => BaseField.FieldHandle;
+ public override IList<CustomAttributeData> GetCustomAttributesData() => BaseField.GetCustomAttributesData();
+ public override object[] GetCustomAttributes(bool inherit) => BaseField.GetCustomAttributes(inherit);
+ public override object[] GetCustomAttributes(Type attributeType, bool inherit) => BaseField.GetCustomAttributes(attributeType, inherit);
+ public override bool IsDefined(Type attributeType, bool inherit) => BaseField.IsDefined(attributeType, inherit);
+ public override object? GetValue(object? obj) => BaseField.GetValue(obj);
+ public override void SetValue(object? obj, object? value, BindingFlags invokeAttr, Binder? binder, CultureInfo? culture)
+ => BaseField.SetValue(obj, value, invokeAttr, binder, culture);
+}
+#endif
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefParameterInfo.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefParameterInfo.cs
new file mode 100644
index 0000000..dbde904
--- /dev/null
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefParameterInfo.cs
@@ -0,0 +1,30 @@
+// SPDX-FileCopyrightText: 2022 smdn <smdn@smdn.jp>
+// SPDX-License-Identifier: MIT
+#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+namespace Smdn.Reflection;
+
+// Workaround: The pseudo ParameterInfo type which unwraps 'ByRef' type to its element type
+// See https://github.com/dotnet/runtime/issues/72320
+internal sealed class UnwrapByRefParameterInfo : ParameterInfo {
+ public ParameterInfo BaseParameter { get; }
+
+ public UnwrapByRefParameterInfo(ParameterInfo baseParamameter)
+ {
+#if DEBUG
+ if (!baseParamameter.ParameterType.IsByRef)
+ throw new ArgumentException($"{baseParamameter.ParameterType} must be by-ref");
+#endif
+
+ BaseParameter = baseParamameter;
+ }
+
+ public override MemberInfo Member => BaseParameter.Member;
+ public override Type ParameterType => BaseParameter.ParameterType.GetElementType()!;
+ public override IList<CustomAttributeData> GetCustomAttributesData()
+ => BaseParameter.GetCustomAttributesData();
+}
+#endif
diff --git a/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefPropertyInfo.cs b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefPropertyInfo.cs
new file mode 100644
index 0000000..699a140
--- /dev/null
+++ b/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefPropertyInfo.cs
@@ -0,0 +1,46 @@
+// SPDX-FileCopyrightText: 2022 smdn <smdn@smdn.jp>
+// SPDX-License-Identifier: MIT
+#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Reflection;
+
+namespace Smdn.Reflection;
+
+// Workaround: The pseudo PropertyInfo type which unwraps 'ByRef' type to its element type
+// See https://github.com/dotnet/runtime/issues/72320
+internal sealed class UnwrapByRefPropertyInfo : PropertyInfo {
+ public PropertyInfo BaseProperty { get; }
+
+ public UnwrapByRefPropertyInfo(PropertyInfo baseProperty)
+ {
+#if DEBUG
+ if (!baseProperty.PropertyType.IsByRef)
+ throw new ArgumentException($"{baseProperty.PropertyType} must be by-ref");
+#endif
+
+ BaseProperty = baseProperty;
+ }
+
+ public override string Name => BaseProperty.Name;
+ public override PropertyAttributes Attributes => BaseProperty.Attributes;
+ public override bool CanRead => BaseProperty.CanRead;
+ public override bool CanWrite => BaseProperty.CanWrite;
+ public override Type PropertyType => BaseProperty.PropertyType.GetElementType()!;
+ public override Type? DeclaringType => BaseProperty.DeclaringType;
+ public override Type? ReflectedType => BaseProperty.ReflectedType;
+ public override IList<CustomAttributeData> GetCustomAttributesData() => BaseProperty.GetCustomAttributesData();
+ public override object[] GetCustomAttributes(bool inherit) => BaseProperty.GetCustomAttributes(inherit);
+ public override object[] GetCustomAttributes(Type attributeType, bool inherit) => BaseProperty.GetCustomAttributes(attributeType, inherit);
+ public override bool IsDefined(Type attributeType, bool inherit) => BaseProperty.IsDefined(attributeType, inherit);
+ public override MethodInfo[] GetAccessors(bool nonPublic) => BaseProperty.GetAccessors(nonPublic);
+ public override MethodInfo? GetGetMethod(bool nonPublic) => BaseProperty.GetGetMethod(nonPublic);
+ public override MethodInfo? GetSetMethod(bool nonPublic) => BaseProperty.GetSetMethod(nonPublic);
+ public override ParameterInfo[] GetIndexParameters() => BaseProperty.GetIndexParameters();
+ public override object? GetValue(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? index, CultureInfo? culture)
+ => BaseProperty.GetValue(obj, invokeAttr, binder, index, culture);
+ public override void SetValue(object? obj, object? value, BindingFlags invokeAttr, Binder? binder, object?[]? index, CultureInfo? culture)
+ => BaseProperty.SetValue(obj, value, invokeAttr, binder, index, culture);
+}
+#endif
Notes
Full Changelog: releases/Smdn.Reflection.ReverseGenerating-1.2.0...releases/Smdn.Reflection.ReverseGenerating-1.3.0