From f26fa45113c4e84a26ddca010dcfdd8260b7cce7 Mon Sep 17 00:00:00 2001 From: Joanna May Date: Fri, 11 Apr 2025 18:28:58 -0500 Subject: [PATCH] feat: support value type metadata generation --- .editorconfig | 2 +- .../A_ChildBaseFullyQualified58F37FBE84.g.cs | 2 +- .../AliasedStuff_Nested_Child.g.cs | 2 +- .../AliasedStuff_Nested_Child2.g.cs | 2 +- .../AliasedStuff_Nested_DirectChild.g.cs | 2 +- .../B_ChildBaseFullyQualifiedF9E7B51DD8.g.cs | 2 +- .../BaseClasses_A_BaseClass.g.cs | 2 +- .../BaseClasses_B_Child.g.cs | 2 +- .../C_ChildBaseFullyQualifiedD92201992B.g.cs | 2 +- .../One_Two_A.g.cs | 2 +- .../StaticUsings_ChildWithStaticBaseRef.g.cs | 2 +- .../TestCases_SetOnlyPropertyE303C8557E.g.cs | 2 +- .../TestCases_ValueTypeWithId770D11E1C0.g.cs | 89 ++++++++++ .../TestCases_VersionedModel065A186606F.g.cs | 2 +- .../TestCases_VersionedModel16E175F28F0.g.cs | 2 +- .../TestCases_VersionedModel2BDB0396AC8.g.cs | 2 +- .../TestCases_VersionedModel3F29481B82C.g.cs | 2 +- .../Tests_TestCases_BaseModel6634CD33B5.g.cs | 2 +- .../Tests_TestCases_ValueType4E2A8A5477.g.cs | 86 +++++++++ .../TypeRegistry.g.cs | 2 + .../_AInnerContainer_ZMyModel860D3B41EA.g.cs | 2 +- .../_ChildBaseFullyQualified2447EE53E80.g.cs | 2 +- .../_MyContainerClass_MyModel67E837FC39.g.cs | 2 +- .../_TestCases_OtherValueType8BF246155F.g.cs | 48 +++++ .../_TestCases_OuterContainer41DE6B7671.g.cs | 2 +- .../_TestCases_VersionedModel97F401129D.g.cs | 2 +- .../_Tests_TestCases_NameOfId962412A9E9.g.cs | 2 +- .../_Tests_TestCases_SomeType31193CB4B4.g.cs | 2 +- .../ator_Tests_TestCases_NoId2554B6C950.g.cs | 2 +- .../e_ChildBaseFullyQualifiedF82AB94D12.g.cs | 2 +- .../eeplyNamespaced_SomeChild7E3B519F42.g.cs | 2 +- .../endsTypeFromSomewhereElseE4FBAC4551.g.cs | 2 +- .../er2_DeeplyNestedBaseClassAC795ED913.g.cs | 2 +- .../estCases_ConcreteChildOneCC2D9F5CA5.g.cs | 2 +- .../estCases_ConcreteChildTwo177A70AE02.g.cs | 2 +- .../her_A_B_C_D_SomeBaseClassECA01F390E.g.cs | 2 +- .../hildBaseNotFullyQualified96BFFBDF77.g.cs | 2 +- .../ingDeeplyNamespaced_ChildB31D784D2E.g.cs | 2 +- .../nnerContainer_AOtherModel42232E4BF8.g.cs | 2 +- .../ntainer_TypeInGlobalScopeF72964AC7A.g.cs | 2 +- .../or_Tests_TestCases_MyType1CDCCD6086.g.cs | 2 +- .../r_ChildBaseFullyQualified695F3233EA.g.cs | 2 +- .../s_AttributesWithNamedArgs21E465F742.g.cs | 2 +- .../s_StaticPropertyIsSkipped2497B0B66A.g.cs | 2 +- .../s_TestCases_InitArgsModel651DDFA4A7.g.cs | 2 +- .../s_TestCases_PropertyModel4D221791B1.g.cs | 2 +- .../ses_NullablePropertyTypesC877B09C3B.g.cs | 2 +- .../sts_TestCases_Collections23D60571D5.g.cs | 2 +- .../tractTypeWithVersionIsBad8F1C3FCB0B.g.cs | 2 +- .../ts_TestCases_AbstractTypeF9039C5995.g.cs | 2 +- .../ts_TestCases_DerivedModel2583598D69.g.cs | 2 +- .../ts_TestCases_PartialModelED2F9C08D8.g.cs | 2 +- .../wo_IThree_Four_NestedType7FDE758058.g.cs | 2 +- ...nsoft.Introspection.Generator.Tests.csproj | 2 +- .../badges/branch_coverage.svg | 4 +- .../badges/line_coverage.svg | 4 +- .../test/src/models/DeclaredAttributeTest.cs | 9 +- .../test/src/models/DeclaredTypeTest.cs | 84 ++++++--- .../test_cases/ValueType.cs | 13 ++ .../src/TypeGenerator.cs | 30 ++-- .../src/models/DeclaredType.cs | 23 ++- .../src/models/ScopeNode.cs | 2 + .../src/utils/Constants.cs | 2 + .../Tests_TypeGraphTest_Model4FF6A4782E.g.cs | 2 +- .../_TypeGraphTest_NoSubtypesB50BED7369.g.cs | 2 +- .../aphTest_SubtypeA_SubtypeBCECBE7E572.g.cs | 2 +- .../erMetadataTest_ChildModelD70FB8BF24.g.cs | 2 +- .../hMemberMetadataTest_Model8D28D57DDD.g.cs | 2 +- .../on_Tests_MyTypeWithAMixin444DFB44AF.g.cs | 2 +- .../peGraphVersionTest_Model112B5DD8E71.g.cs | 2 +- .../peGraphVersionTest_Model222666FE7CE.g.cs | 2 +- .../peGraphVersionTest_Model3B7B5491774.g.cs | 2 +- .../ts_TypeGraphTest_SubtypeA96F062FA2B.g.cs | 2 +- .../ts_TypeGraphTest_SubtypeCC2FA7FBDBB.g.cs | 2 +- .../ypeGraphVersionTest_Model691E41E943.g.cs | 2 +- .../Chickensoft.Introspection.Tests.csproj | 2 +- .../test/models/IIntrospectiveTest.cs | 6 +- .../src/attributes/IdAttribute.cs | 2 +- .../src/attributes/MetaAttribute.cs | 4 +- .../src/types/IIntrospective.cs | 22 ++- Chickensoft.Introspection/src/types/IMixin.cs | 2 +- README.md | 168 ++++++++++++++---- 82 files changed, 563 insertions(+), 163 deletions(-) create mode 100644 Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_ValueTypeWithId770D11E1C0.g.cs create mode 100644 Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_ValueType4E2A8A5477.g.cs create mode 100644 Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OtherValueType8BF246155F.g.cs create mode 100644 Chickensoft.Introspection.Generator.Tests/test_cases/ValueType.cs diff --git a/.editorconfig b/.editorconfig index a9e0a78..8a5ff8d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -122,7 +122,7 @@ dotnet_style_predefined_type_for_locals_parameters_members = true:warning dotnet_style_predefined_type_for_member_access = true:warning # Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning +dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:warning dotnet_style_readonly_field = true:warning diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/A_ChildBaseFullyQualified58F37FBE84.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/A_ChildBaseFullyQualified58F37FBE84.g.cs index 214a91a..4ba2f9d 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/A_ChildBaseFullyQualified58F37FBE84.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/A_ChildBaseFullyQualified58F37FBE84.g.cs @@ -5,7 +5,7 @@ namespace OtherNamespace.Altogether; using Chickensoft.Introspection; partial class A { - partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospective { + partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child.g.cs index 9394ad2..6481df6 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child.g.cs @@ -6,7 +6,7 @@ namespace AliasedStuff.Nested; using X = OtherNamespace.Altogether.A; using Y = OtherNamespace.Altogether.A.B; -partial class Child : Chickensoft.Introspection.IIntrospective { +partial class Child : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child2.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child2.g.cs index 7c5fc64..b077ec0 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child2.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_Child2.g.cs @@ -6,7 +6,7 @@ namespace AliasedStuff.Nested; using X = OtherNamespace.Altogether.A; using Y = OtherNamespace.Altogether.A.B; -partial class Child2 : Chickensoft.Introspection.IIntrospective { +partial class Child2 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_DirectChild.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_DirectChild.g.cs index aad225a..e25b3f0 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_DirectChild.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/AliasedStuff_Nested_DirectChild.g.cs @@ -6,7 +6,7 @@ namespace AliasedStuff.Nested; using X = OtherNamespace.Altogether.A; using Y = OtherNamespace.Altogether.A.B; -partial class DirectChild : Chickensoft.Introspection.IIntrospective { +partial class DirectChild : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/B_ChildBaseFullyQualifiedF9E7B51DD8.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/B_ChildBaseFullyQualifiedF9E7B51DD8.g.cs index 0c9e38c..7b2df81 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/B_ChildBaseFullyQualifiedF9E7B51DD8.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/B_ChildBaseFullyQualifiedF9E7B51DD8.g.cs @@ -6,7 +6,7 @@ namespace OtherNamespace.Altogether; partial class A { partial class B { - partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospective { + partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_A_BaseClass.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_A_BaseClass.g.cs index fa628f7..4e7f493 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_A_BaseClass.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_A_BaseClass.g.cs @@ -4,7 +4,7 @@ namespace BaseClasses.A; using Chickensoft.Introspection; -partial class BaseClass : Chickensoft.Introspection.IIntrospective { +partial class BaseClass : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_B_Child.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_B_Child.g.cs index 14f02bf..9c46dd1 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_B_Child.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/BaseClasses_B_Child.g.cs @@ -5,7 +5,7 @@ namespace BaseClasses.B; using BaseClasses.A; using Chickensoft.Introspection; -partial class Child : Chickensoft.Introspection.IIntrospective { +partial class Child : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/C_ChildBaseFullyQualifiedD92201992B.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/C_ChildBaseFullyQualifiedD92201992B.g.cs index 6d4bf16..1424564 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/C_ChildBaseFullyQualifiedD92201992B.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/C_ChildBaseFullyQualifiedD92201992B.g.cs @@ -7,7 +7,7 @@ namespace OtherNamespace.Altogether; partial class A { partial class B { partial class C { - partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospective { + partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/One_Two_A.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/One_Two_A.g.cs index be02885..a1a9ba5 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/One_Two_A.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/One_Two_A.g.cs @@ -4,7 +4,7 @@ namespace One.Two; using Chickensoft.Introspection; -partial class A : Chickensoft.Introspection.IIntrospective { +partial class A : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/StaticUsings_ChildWithStaticBaseRef.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/StaticUsings_ChildWithStaticBaseRef.g.cs index 3d40e70..6f46470 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/StaticUsings_ChildWithStaticBaseRef.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/StaticUsings_ChildWithStaticBaseRef.g.cs @@ -5,7 +5,7 @@ namespace StaticUsings; using Chickensoft.Introspection; using static OtherNamespace.Altogether.A; -partial class ChildWithStaticBaseRef : Chickensoft.Introspection.IIntrospective { +partial class ChildWithStaticBaseRef : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_SetOnlyPropertyE303C8557E.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_SetOnlyPropertyE303C8557E.g.cs index 54845f9..8b2d941 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_SetOnlyPropertyE303C8557E.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_SetOnlyPropertyE303C8557E.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class SetOnlyProperty : Chickensoft.Introspection.IIntrospective { +partial record class SetOnlyProperty : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_ValueTypeWithId770D11E1C0.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_ValueTypeWithId770D11E1C0.g.cs new file mode 100644 index 0000000..2003bce --- /dev/null +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_ValueTypeWithId770D11E1C0.g.cs @@ -0,0 +1,89 @@ +๏ปฟ#pragma warning disable +#nullable enable +namespace Chickensoft.Introspection.Generator.Tests.TestCases; + +partial record struct ValueTypeWithId : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public Chickensoft.Introspection.IMetatype Metatype => ((Chickensoft.Introspection.IIntrospectiveTypeMetadata)Chickensoft.Introspection.Types.Graph.GetMetadata(typeof(ValueTypeWithId))).Metatype; + + public class MetatypeMetadata : Chickensoft.Introspection.IMetatype { + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Type Type => typeof(ValueTypeWithId); + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool HasInitProperties { get; } = true; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyList Properties { get; } = new System.Collections.Generic.List() { + new Chickensoft.Introspection.PropertyMetadata( + Name: "Description", + IsInit: true, + IsRequired: false, + HasDefaultValue: false, + Getter: static (object obj) => ((ValueTypeWithId)obj).Description, + Setter: null, + TypeNode: new Chickensoft.Introspection.TypeNode( + OpenType: typeof(string), + ClosedType: typeof(string), + IsNullable: true, + Arguments: System.Array.Empty(), + GenericTypeGetter: static receiver => receiver.Receive(), + GenericTypeGetter2: default + ), + Attributes: new System.Collections.Generic.Dictionary() { + } + ), + new Chickensoft.Introspection.PropertyMetadata( + Name: "Number", + IsInit: true, + IsRequired: true, + HasDefaultValue: false, + Getter: static (object obj) => ((ValueTypeWithId)obj).Number, + Setter: null, + TypeNode: new Chickensoft.Introspection.TypeNode( + OpenType: typeof(int), + ClosedType: typeof(int), + IsNullable: false, + Arguments: System.Array.Empty(), + GenericTypeGetter: static receiver => receiver.Receive(), + GenericTypeGetter2: default + ), + Attributes: new System.Collections.Generic.Dictionary() { + } + ) + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyDictionary Attributes { get; } = new System.Collections.Generic.Dictionary() { + [typeof(IdAttribute)] = new System.Attribute[] { + new IdAttribute("value_type_with_id") + }, + [typeof(MetaAttribute)] = new System.Attribute[] { + new MetaAttribute() + } + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyList Mixins { get; } = new System.Collections.Generic.List() { + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyDictionary> MixinHandlers { get; } = new System.Collections.Generic.Dictionary>() { + }; + + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public object Construct(System.Collections.Generic.IReadOnlyDictionary? args = null) { + args = args ?? throw new System.ArgumentNullException(nameof(args), "Constructing ValueTypeWithId requires init args."); + return new ValueTypeWithId() { + Description = args.ContainsKey("Description") ? (string?)args["Description"] : default(string?), + Number = args.ContainsKey("Number") ? (int)args["Number"] : default(int)! + }; + } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public override bool Equals(object obj) => true; + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public override int GetHashCode() => base.GetHashCode(); + } +} +#nullable restore +#pragma warning restore diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel065A186606F.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel065A186606F.g.cs index 3950e5b..733e83c 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel065A186606F.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel065A186606F.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class VersionedModel0 : Chickensoft.Introspection.IIntrospective { +partial record class VersionedModel0 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel16E175F28F0.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel16E175F28F0.g.cs index 3aa0040..1452931 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel16E175F28F0.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel16E175F28F0.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class VersionedModel1 : Chickensoft.Introspection.IIntrospective { +partial record class VersionedModel1 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel2BDB0396AC8.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel2BDB0396AC8.g.cs index 38f8c1b..7a59100 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel2BDB0396AC8.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel2BDB0396AC8.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class VersionedModel2 : Chickensoft.Introspection.IIntrospective { +partial record class VersionedModel2 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel3F29481B82C.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel3F29481B82C.g.cs index 283d3d6..64f5241 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel3F29481B82C.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TestCases_VersionedModel3F29481B82C.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class VersionedModel3 : Chickensoft.Introspection.IIntrospective { +partial record class VersionedModel3 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_BaseModel6634CD33B5.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_BaseModel6634CD33B5.g.cs index 9b73e58..2198a31 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_BaseModel6634CD33B5.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_BaseModel6634CD33B5.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection; using Chickensoft.Introspection.Generator.Tests.TestUtils; -partial class BaseModel : Chickensoft.Introspection.IIntrospective { +partial class BaseModel : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_ValueType4E2A8A5477.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_ValueType4E2A8A5477.g.cs new file mode 100644 index 0000000..14dd234 --- /dev/null +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TestCases_ValueType4E2A8A5477.g.cs @@ -0,0 +1,86 @@ +๏ปฟ#pragma warning disable +#nullable enable +namespace Chickensoft.Introspection.Generator.Tests.TestCases; + +partial record struct ValueType : Chickensoft.Introspection.IIntrospective { + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public Chickensoft.Introspection.IMetatype Metatype => ((Chickensoft.Introspection.IIntrospectiveTypeMetadata)Chickensoft.Introspection.Types.Graph.GetMetadata(typeof(ValueType))).Metatype; + + public class MetatypeMetadata : Chickensoft.Introspection.IMetatype { + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Type Type => typeof(ValueType); + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool HasInitProperties { get; } = true; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyList Properties { get; } = new System.Collections.Generic.List() { + new Chickensoft.Introspection.PropertyMetadata( + Name: "Description", + IsInit: true, + IsRequired: false, + HasDefaultValue: false, + Getter: static (object obj) => ((ValueType)obj).Description, + Setter: null, + TypeNode: new Chickensoft.Introspection.TypeNode( + OpenType: typeof(string), + ClosedType: typeof(string), + IsNullable: true, + Arguments: System.Array.Empty(), + GenericTypeGetter: static receiver => receiver.Receive(), + GenericTypeGetter2: default + ), + Attributes: new System.Collections.Generic.Dictionary() { + } + ), + new Chickensoft.Introspection.PropertyMetadata( + Name: "Number", + IsInit: true, + IsRequired: true, + HasDefaultValue: false, + Getter: static (object obj) => ((ValueType)obj).Number, + Setter: null, + TypeNode: new Chickensoft.Introspection.TypeNode( + OpenType: typeof(int), + ClosedType: typeof(int), + IsNullable: false, + Arguments: System.Array.Empty(), + GenericTypeGetter: static receiver => receiver.Receive(), + GenericTypeGetter2: default + ), + Attributes: new System.Collections.Generic.Dictionary() { + } + ) + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyDictionary Attributes { get; } = new System.Collections.Generic.Dictionary() { + [typeof(MetaAttribute)] = new System.Attribute[] { + new MetaAttribute() + } + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyList Mixins { get; } = new System.Collections.Generic.List() { + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyDictionary> MixinHandlers { get; } = new System.Collections.Generic.Dictionary>() { + }; + + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public object Construct(System.Collections.Generic.IReadOnlyDictionary? args = null) { + args = args ?? throw new System.ArgumentNullException(nameof(args), "Constructing ValueType requires init args."); + return new ValueType() { + Description = args.ContainsKey("Description") ? (string?)args["Description"] : default(string?), + Number = args.ContainsKey("Number") ? (int)args["Number"] : default(int)! + }; + } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public override bool Equals(object obj) => true; + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public override int GetHashCode() => base.GetHashCode(); + } +} +#nullable restore +#pragma warning restore diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TypeRegistry.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TypeRegistry.g.cs index 297b6ff..5bd27e1 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TypeRegistry.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TypeRegistry.g.cs @@ -88,6 +88,8 @@ public partial class TypeRegistry : Chickensoft.Introspection.ITypeRegistry { [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.GC<,,>.GCH<,>)] = new Chickensoft.Introspection.TypeMetadata("GCH"), [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.GC<,,>.GCI<,,,>)] = new Chickensoft.Introspection.TypeMetadata("GCI"), [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.GC<,,>.GCI<,,>)] = new Chickensoft.Introspection.TypeMetadata("GCI"), + [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.ValueType)] = new Chickensoft.Introspection.IntrospectiveTypeMetadata("ValueType", static (r) => r.Receive(), static () => System.Activator.CreateInstance(), new Chickensoft.Introspection.Generator.Tests.TestCases.ValueType.MetatypeMetadata(), 1), + [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.ValueTypeWithId)] = new Chickensoft.Introspection.IdentifiableTypeMetadata("ValueTypeWithId", static (r) => r.Receive(), static () => System.Activator.CreateInstance(), new Chickensoft.Introspection.Generator.Tests.TestCases.ValueTypeWithId.MetatypeMetadata(), "value_type_with_id", 1), [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.VersionedModel)] = new Chickensoft.Introspection.AbstractIdentifiableTypeMetadata("VersionedModel", static (r) => r.Receive(), new Chickensoft.Introspection.Generator.Tests.TestCases.VersionedModel.MetatypeMetadata(), "versioned_model"), [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.VersionedModel0)] = new Chickensoft.Introspection.IntrospectiveTypeMetadata("VersionedModel0", static (r) => r.Receive(), static () => System.Activator.CreateInstance(), new Chickensoft.Introspection.Generator.Tests.TestCases.VersionedModel0.MetatypeMetadata(), 0), [typeof(Chickensoft.Introspection.Generator.Tests.TestCases.VersionedModel1)] = new Chickensoft.Introspection.IntrospectiveTypeMetadata("VersionedModel1", static (r) => r.Receive(), static () => System.Activator.CreateInstance(), new Chickensoft.Introspection.Generator.Tests.TestCases.VersionedModel1.MetatypeMetadata(), 1), diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_AInnerContainer_ZMyModel860D3B41EA.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_AInnerContainer_ZMyModel860D3B41EA.g.cs index f59a983..ed733a1 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_AInnerContainer_ZMyModel860D3B41EA.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_AInnerContainer_ZMyModel860D3B41EA.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; partial class OuterContainer { partial class MidContainer { partial class AInnerContainer { - partial class ZMyModel : Chickensoft.Introspection.IIntrospective { + partial class ZMyModel : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_ChildBaseFullyQualified2447EE53E80.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_ChildBaseFullyQualified2447EE53E80.g.cs index 533c483..97ebe9a 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_ChildBaseFullyQualified2447EE53E80.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_ChildBaseFullyQualified2447EE53E80.g.cs @@ -4,7 +4,7 @@ namespace OtherNamespace.Altogether; using Chickensoft.Introspection; -partial class ChildBaseFullyQualified2 : Chickensoft.Introspection.IIntrospective { +partial class ChildBaseFullyQualified2 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_MyContainerClass_MyModel67E837FC39.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_MyContainerClass_MyModel67E837FC39.g.cs index ec82022..a7b2eb4 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_MyContainerClass_MyModel67E837FC39.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_MyContainerClass_MyModel67E837FC39.g.cs @@ -6,7 +6,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection.Generator.Tests.TestUtils; partial class MyContainerClass { - partial record class MyModel : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable, IMyMixin, IMySecondMixin { + partial record class MyModel : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable, IMyMixin, IMySecondMixin { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OtherValueType8BF246155F.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OtherValueType8BF246155F.g.cs new file mode 100644 index 0000000..185bd3d --- /dev/null +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OtherValueType8BF246155F.g.cs @@ -0,0 +1,48 @@ +๏ปฟ#pragma warning disable +#nullable enable +namespace Chickensoft.Introspection.Generator.Tests.TestCases; + +partial record struct OtherValueType : Chickensoft.Introspection.IIntrospective, IMyMixin { + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public Chickensoft.Introspection.IMetatype Metatype => ((Chickensoft.Introspection.IIntrospectiveTypeMetadata)Chickensoft.Introspection.Types.Graph.GetMetadata(typeof(OtherValueType))).Metatype; + + public class MetatypeMetadata : Chickensoft.Introspection.IMetatype { + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Type Type => typeof(OtherValueType); + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool HasInitProperties { get; } = false; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyList Properties { get; } = new System.Collections.Generic.List() { + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyDictionary Attributes { get; } = new System.Collections.Generic.Dictionary() { + [typeof(MetaAttribute)] = new System.Attribute[] { + new MetaAttribute(typeof(IMyMixin)) + } + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyList Mixins { get; } = new System.Collections.Generic.List() { + typeof(IMyMixin) + }; + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public System.Collections.Generic.IReadOnlyDictionary> MixinHandlers { get; } = new System.Collections.Generic.Dictionary>() { + [typeof(IMyMixin)] = static (obj) => ((IMyMixin)obj).Handler() + }; + + + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public object Construct(System.Collections.Generic.IReadOnlyDictionary? args = null) { + return new OtherValueType(); + } + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public override bool Equals(object obj) => true; + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public override int GetHashCode() => base.GetHashCode(); + } +} +#nullable restore +#pragma warning restore diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OuterContainer41DE6B7671.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OuterContainer41DE6B7671.g.cs index 4a600e9..fe6fb5d 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OuterContainer41DE6B7671.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_OuterContainer41DE6B7671.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial class OuterContainer : Chickensoft.Introspection.IIntrospective { +partial class OuterContainer : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_VersionedModel97F401129D.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_VersionedModel97F401129D.g.cs index f4f196a..6078acc 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_VersionedModel97F401129D.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TestCases_VersionedModel97F401129D.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class VersionedModel : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial record class VersionedModel : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_NameOfId962412A9E9.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_NameOfId962412A9E9.g.cs index fecae69..935242d 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_NameOfId962412A9E9.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_NameOfId962412A9E9.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class NameOfId : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial record class NameOfId : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_SomeType31193CB4B4.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_SomeType31193CB4B4.g.cs index b98146a..9cf697b 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_SomeType31193CB4B4.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_Tests_TestCases_SomeType31193CB4B4.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial class SomeType : Chickensoft.Introspection.IIntrospective, ISomeMixin { +partial class SomeType : Chickensoft.Introspection.IIntrospectiveRef, ISomeMixin { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ator_Tests_TestCases_NoId2554B6C950.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ator_Tests_TestCases_NoId2554B6C950.g.cs index 169cea4..0166f06 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ator_Tests_TestCases_NoId2554B6C950.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ator_Tests_TestCases_NoId2554B6C950.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class NoId : Chickensoft.Introspection.IIntrospective { +partial record class NoId : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/e_ChildBaseFullyQualifiedF82AB94D12.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/e_ChildBaseFullyQualifiedF82AB94D12.g.cs index 22b6893..6b98f01 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/e_ChildBaseFullyQualifiedF82AB94D12.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/e_ChildBaseFullyQualifiedF82AB94D12.g.cs @@ -5,7 +5,7 @@ namespace AlternativeNamespace; using Chickensoft.Introspection; using OtherNamespace.Altogether; -partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospective { +partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/eeplyNamespaced_SomeChild7E3B519F42.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/eeplyNamespaced_SomeChild7E3B519F42.g.cs index f964d8d..8b3bae0 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/eeplyNamespaced_SomeChild7E3B519F42.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/eeplyNamespaced_SomeChild7E3B519F42.g.cs @@ -5,7 +5,7 @@ namespace BaseClasses.A.B.UsingDeeplyNamespaced; using BaseClasses.A.B.DeeplyNamespaced; using Chickensoft.Introspection; -partial class SomeChild : Chickensoft.Introspection.IIntrospective { +partial class SomeChild : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/endsTypeFromSomewhereElseE4FBAC4551.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/endsTypeFromSomewhereElseE4FBAC4551.g.cs index d479f83..a2fcc15 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/endsTypeFromSomewhereElseE4FBAC4551.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/endsTypeFromSomewhereElseE4FBAC4551.g.cs @@ -6,7 +6,7 @@ namespace AliasedStuff.Nested; using X = OtherNamespace.Altogether.A; using Y = OtherNamespace.Altogether.A.B; -partial class ExtendsTypeFromSomewhereElse : Chickensoft.Introspection.IIntrospective { +partial class ExtendsTypeFromSomewhereElse : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/er2_DeeplyNestedBaseClassAC795ED913.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/er2_DeeplyNestedBaseClassAC795ED913.g.cs index d095497..f744f00 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/er2_DeeplyNestedBaseClassAC795ED913.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/er2_DeeplyNestedBaseClassAC795ED913.g.cs @@ -6,7 +6,7 @@ namespace BaseClasses.A.B.DeeplyNamespaced; partial class Container { partial class Container2 { - partial class DeeplyNestedBaseClass : Chickensoft.Introspection.IIntrospective { + partial class DeeplyNestedBaseClass : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildOneCC2D9F5CA5.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildOneCC2D9F5CA5.g.cs index 227a5c0..70a5719 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildOneCC2D9F5CA5.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildOneCC2D9F5CA5.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class ConcreteChildOne : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial record class ConcreteChildOne : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildTwo177A70AE02.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildTwo177A70AE02.g.cs index 277809f..a9425d3 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildTwo177A70AE02.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/estCases_ConcreteChildTwo177A70AE02.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class ConcreteChildTwo : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial record class ConcreteChildTwo : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/her_A_B_C_D_SomeBaseClassECA01F390E.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/her_A_B_C_D_SomeBaseClassECA01F390E.g.cs index 909b4b8..59175af 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/her_A_B_C_D_SomeBaseClassECA01F390E.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/her_A_B_C_D_SomeBaseClassECA01F390E.g.cs @@ -8,7 +8,7 @@ partial class A { partial class B { partial class C { partial class D { - partial class SomeBaseClass : Chickensoft.Introspection.IIntrospective { + partial class SomeBaseClass : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hildBaseNotFullyQualified96BFFBDF77.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hildBaseNotFullyQualified96BFFBDF77.g.cs index f6a8e85..2b464bc 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hildBaseNotFullyQualified96BFFBDF77.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hildBaseNotFullyQualified96BFFBDF77.g.cs @@ -5,7 +5,7 @@ namespace AlternativeNamespace; using Chickensoft.Introspection; using OtherNamespace.Altogether; -partial class ChildBaseNotFullyQualified : Chickensoft.Introspection.IIntrospective { +partial class ChildBaseNotFullyQualified : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ingDeeplyNamespaced_ChildB31D784D2E.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ingDeeplyNamespaced_ChildB31D784D2E.g.cs index ee5441b..689538e 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ingDeeplyNamespaced_ChildB31D784D2E.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ingDeeplyNamespaced_ChildB31D784D2E.g.cs @@ -5,7 +5,7 @@ namespace BaseClasses.A.B.UsingDeeplyNamespaced; using BaseClasses.A.B.DeeplyNamespaced; using Chickensoft.Introspection; -partial class Child : Chickensoft.Introspection.IIntrospective { +partial class Child : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/nnerContainer_AOtherModel42232E4BF8.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/nnerContainer_AOtherModel42232E4BF8.g.cs index dc1a82d..42e272e 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/nnerContainer_AOtherModel42232E4BF8.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/nnerContainer_AOtherModel42232E4BF8.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; partial class OuterContainer { partial class MidContainer { partial class AInnerContainer { - partial class AOtherModel : Chickensoft.Introspection.IIntrospective { + partial class AOtherModel : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ntainer_TypeInGlobalScopeF72964AC7A.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ntainer_TypeInGlobalScopeF72964AC7A.g.cs index f9f790c..21abf25 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ntainer_TypeInGlobalScopeF72964AC7A.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ntainer_TypeInGlobalScopeF72964AC7A.g.cs @@ -3,7 +3,7 @@ using Chickensoft.Introspection; partial class GlobalScopeContainer { - partial class TypeInGlobalScope : Chickensoft.Introspection.IIntrospective { + partial class TypeInGlobalScope : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/or_Tests_TestCases_MyType1CDCCD6086.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/or_Tests_TestCases_MyType1CDCCD6086.g.cs index 21e1ad6..6186d0b 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/or_Tests_TestCases_MyType1CDCCD6086.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/or_Tests_TestCases_MyType1CDCCD6086.g.cs @@ -9,7 +9,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using System.Text; using JSON = System.Text.Json; -partial class MyType : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial class MyType : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/r_ChildBaseFullyQualified695F3233EA.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/r_ChildBaseFullyQualified695F3233EA.g.cs index a95dc85..ccf18a1 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/r_ChildBaseFullyQualified695F3233EA.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/r_ChildBaseFullyQualified695F3233EA.g.cs @@ -4,7 +4,7 @@ namespace OtherNamespace.Altogether; using Chickensoft.Introspection; -partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospective { +partial class ChildBaseFullyQualified : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_AttributesWithNamedArgs21E465F742.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_AttributesWithNamedArgs21E465F742.g.cs index 19af972..018359d 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_AttributesWithNamedArgs21E465F742.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_AttributesWithNamedArgs21E465F742.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection; using Chickensoft.Introspection.Generator.Tests.TestUtils; -partial class AttributesWithNamedArgs : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial class AttributesWithNamedArgs : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_StaticPropertyIsSkipped2497B0B66A.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_StaticPropertyIsSkipped2497B0B66A.g.cs index 2c414a5..8908b1c 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_StaticPropertyIsSkipped2497B0B66A.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_StaticPropertyIsSkipped2497B0B66A.g.cs @@ -4,7 +4,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection; -partial class StaticPropertyIsSkipped : Chickensoft.Introspection.IIntrospective { +partial class StaticPropertyIsSkipped : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_InitArgsModel651DDFA4A7.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_InitArgsModel651DDFA4A7.g.cs index 761cfe0..d820759 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_InitArgsModel651DDFA4A7.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_InitArgsModel651DDFA4A7.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection; using Chickensoft.Introspection.Generator.Tests.TestUtils; -partial class InitArgsModel : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial class InitArgsModel : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_PropertyModel4D221791B1.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_PropertyModel4D221791B1.g.cs index e9bc2bc..c33f9da 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_PropertyModel4D221791B1.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/s_TestCases_PropertyModel4D221791B1.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class PropertyModel : Chickensoft.Introspection.IIntrospective { +partial record class PropertyModel : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ses_NullablePropertyTypesC877B09C3B.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ses_NullablePropertyTypesC877B09C3B.g.cs index f7076c4..3391ac6 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ses_NullablePropertyTypesC877B09C3B.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ses_NullablePropertyTypesC877B09C3B.g.cs @@ -7,7 +7,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using System; using System.Collections.Generic; -partial class NullablePropertyTypes : Chickensoft.Introspection.IIntrospective { +partial class NullablePropertyTypes : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/sts_TestCases_Collections23D60571D5.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/sts_TestCases_Collections23D60571D5.g.cs index a55f09a..0d3acc0 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/sts_TestCases_Collections23D60571D5.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/sts_TestCases_Collections23D60571D5.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection.Generator.Tests.TestUtils; using System.Collections.Generic; -partial class Collections : Chickensoft.Introspection.IIntrospective { +partial class Collections : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/tractTypeWithVersionIsBad8F1C3FCB0B.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/tractTypeWithVersionIsBad8F1C3FCB0B.g.cs index dd5b1e5..52c5286 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/tractTypeWithVersionIsBad8F1C3FCB0B.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/tractTypeWithVersionIsBad8F1C3FCB0B.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial class AbstractTypeWithVersionIsBad : Chickensoft.Introspection.IIntrospective { +partial class AbstractTypeWithVersionIsBad : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_AbstractTypeF9039C5995.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_AbstractTypeF9039C5995.g.cs index 08680e4..1242c28 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_AbstractTypeF9039C5995.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_AbstractTypeF9039C5995.g.cs @@ -2,7 +2,7 @@ #nullable enable namespace Chickensoft.Introspection.Generator.Tests.TestCases; -partial record class AbstractType : Chickensoft.Introspection.IIntrospective { +partial record class AbstractType : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_DerivedModel2583598D69.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_DerivedModel2583598D69.g.cs index 5f0f6d5..645325a 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_DerivedModel2583598D69.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_DerivedModel2583598D69.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection; using Chickensoft.Introspection.Generator.Tests.TestUtils; -partial class DerivedModel : Chickensoft.Introspection.IIntrospective { +partial class DerivedModel : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_PartialModelED2F9C08D8.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_PartialModelED2F9C08D8.g.cs index e320587..e438b14 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_PartialModelED2F9C08D8.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TestCases_PartialModelED2F9C08D8.g.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection.Generator.Tests.TestCases; using Chickensoft.Introspection; using Chickensoft.Introspection.Generator.Tests.TestUtils; -partial class PartialModel : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { +partial class PartialModel : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/wo_IThree_Four_NestedType7FDE758058.g.cs b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/wo_IThree_Four_NestedType7FDE758058.g.cs index 56ebb0b..13764a0 100644 --- a/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/wo_IThree_Four_NestedType7FDE758058.g.cs +++ b/Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/wo_IThree_Four_NestedType7FDE758058.g.cs @@ -13,7 +13,7 @@ static partial class One { partial record struct Two { partial interface IThree { partial record class Four { - partial class NestedType : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { + partial class NestedType : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Generator.Tests/Chickensoft.Introspection.Generator.Tests.csproj b/Chickensoft.Introspection.Generator.Tests/Chickensoft.Introspection.Generator.Tests.csproj index d028f4a..cf7b3bc 100644 --- a/Chickensoft.Introspection.Generator.Tests/Chickensoft.Introspection.Generator.Tests.csproj +++ b/Chickensoft.Introspection.Generator.Tests/Chickensoft.Introspection.Generator.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 disable enable preview diff --git a/Chickensoft.Introspection.Generator.Tests/badges/branch_coverage.svg b/Chickensoft.Introspection.Generator.Tests/badges/branch_coverage.svg index cc017fc..d896256 100644 --- a/Chickensoft.Introspection.Generator.Tests/badges/branch_coverage.svg +++ b/Chickensoft.Introspection.Generator.Tests/badges/branch_coverage.svg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ce7844d3ba8c9572c3b69e692577880eef0a933dd29df2cee61acc8b0c8f8c3 -size 7388 +oid sha256:0141c5ddd23d392645980a7c41dfa73066669edc0450a51489039a1d66a5c79b +size 8492 diff --git a/Chickensoft.Introspection.Generator.Tests/badges/line_coverage.svg b/Chickensoft.Introspection.Generator.Tests/badges/line_coverage.svg index c2cc7ce..ef6abaf 100644 --- a/Chickensoft.Introspection.Generator.Tests/badges/line_coverage.svg +++ b/Chickensoft.Introspection.Generator.Tests/badges/line_coverage.svg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b5770c82fa07a9f273c9e27a171fa96075709de25820e6b636918206b5cb465c -size 5161 +oid sha256:f44227d6a3ef7ab64c961b7ce5f0649b7d327d506692c5ab10db071830989b61 +size 6265 diff --git a/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredAttributeTest.cs b/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredAttributeTest.cs index d1f2d16..a53f4b7 100644 --- a/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredAttributeTest.cs +++ b/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredAttributeTest.cs @@ -1,6 +1,5 @@ namespace Chickensoft.Introspection.Generator.Tests.Models; -using System.Collections.Immutable; using Chickensoft.Introspection.Generator.Models; using Shouldly; using Xunit; @@ -9,22 +8,22 @@ public class DeclaredAttributeTest { [Fact] public void Equality() { var attr = new DeclaredAttribute( - "", ImmutableArray.Empty, ImmutableArray.Empty + "", [], [] ); attr.GetHashCode().ShouldBeOfType(); attr.ShouldBe( new DeclaredAttribute( - "", ImmutableArray.Empty, ImmutableArray.Empty + "", [], [] ) ); new DeclaredAttribute( - "", ImmutableArray.Empty, new string[] { "b" }.ToImmutableArray() + "", [], ["b"] ).ShouldNotBe( new DeclaredAttribute( - "a", ImmutableArray.Empty, ImmutableArray.Empty + "a", [], [] ) ); diff --git a/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredTypeTest.cs b/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredTypeTest.cs index 6a7f948..c52e599 100644 --- a/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredTypeTest.cs +++ b/Chickensoft.Introspection.Generator.Tests/test/src/models/DeclaredTypeTest.cs @@ -1,6 +1,5 @@ namespace Chickensoft.Introspection.Generator.Tests.Models; -using System.Collections.Immutable; using Chickensoft.Introspection.Generator.Models; using Shouldly; using Xunit; @@ -11,34 +10,32 @@ public class DeclaredTypeTest { "SomeType", Construction: Construction.Class, IsPartial: true, - TypeParameters: ImmutableArray.Empty + TypeParameters: [] ), SyntaxLocation: Microsoft.CodeAnalysis.Location.None, Location: new TypeLocation( - Namespaces: ImmutableArray.Empty, - ContainingTypes: ImmutableArray.Empty + Namespaces: [], + ContainingTypes: [] ), BaseType: null, - Usings: ImmutableHashSet.Empty, + Usings: [], Kind: DeclaredTypeKind.ConcreteType, IsStatic: false, IsPublicOrInternal: true, - Properties: ImmutableArray.Empty, - Attributes: ImmutableArray.Empty, - Mixins: ImmutableArray.Empty + Properties: [], + Attributes: [], + Mixins: [] ); [Fact] public void Version() { var type = _type with { - Attributes = ImmutableArray.Create( - new DeclaredAttribute( + Attributes = [new DeclaredAttribute( Name: Constants.VERSION_ATTRIBUTE_NAME, ConstructorArgs: - new[] { "a" }.ToImmutableArray(), - InitializerArgs: new[] { "b" }.ToImmutableArray() - ) - ) + ["a"], + InitializerArgs: ["b"] + )] }; type.Version.ShouldBe(1); @@ -48,13 +45,11 @@ public void Version() { public void MergePartialPicksCorrectSyntaxLocation() { var type = _type with { SyntaxLocation = Microsoft.CodeAnalysis.Location.None, - Attributes = ImmutableArray.Create( - new DeclaredAttribute( + Attributes = [new DeclaredAttribute( Name: Constants.INTROSPECTIVE_ATTRIBUTE_NAME, - ConstructorArgs: ImmutableArray.Empty, - InitializerArgs: ImmutableArray.Empty - ) - ) + ConstructorArgs: [], + InitializerArgs: [] + )] }; var other = _type with { @@ -113,13 +108,11 @@ public void DoesNotWriteMetadataForUnsupportedStates() { public void HasFallbackId() { var type = _type with { SyntaxLocation = Microsoft.CodeAnalysis.Location.None, - Attributes = ImmutableArray.Create( - new DeclaredAttribute( + Attributes = [new DeclaredAttribute( Name: Constants.ID_ATTRIBUTE_NAME, - ConstructorArgs: ImmutableArray.Create("id"), - InitializerArgs: ImmutableArray.Empty - ) - ) + ConstructorArgs: ["id"], + InitializerArgs: [] + )] }; var writer = TypeGenerator.CreateCodeWriter(); @@ -129,4 +122,43 @@ public void HasFallbackId() { writer.InnerWriter.ToString().ShouldBeOfType(); } + + [Theory] + [InlineData( + DeclaredTypeKind.ConcreteType, + DeclaredTypeKind.ConcreteType, + DeclaredTypeKind.ConcreteType + )] + [InlineData( + DeclaredTypeKind.AbstractType, + DeclaredTypeKind.ConcreteType, + DeclaredTypeKind.AbstractType + )] + [InlineData( + DeclaredTypeKind.ConcreteType, + DeclaredTypeKind.AbstractType, + DeclaredTypeKind.AbstractType + )] + [InlineData( + DeclaredTypeKind.StaticClass, + DeclaredTypeKind.ConcreteType, + DeclaredTypeKind.StaticClass + )] + [InlineData( + DeclaredTypeKind.ConcreteType, + DeclaredTypeKind.StaticClass, + DeclaredTypeKind.StaticClass + )] + [InlineData( + DeclaredTypeKind.Error, + DeclaredTypeKind.ConcreteType, + DeclaredTypeKind.Error + )] + public void PickDeclaredTypeKind( + DeclaredTypeKind kind, + DeclaredTypeKind other, + DeclaredTypeKind expected + ) { + DeclaredType.PickDeclaredTypeKind(kind, other).ShouldBe(expected); + } } diff --git a/Chickensoft.Introspection.Generator.Tests/test_cases/ValueType.cs b/Chickensoft.Introspection.Generator.Tests/test_cases/ValueType.cs new file mode 100644 index 0000000..93dc20d --- /dev/null +++ b/Chickensoft.Introspection.Generator.Tests/test_cases/ValueType.cs @@ -0,0 +1,13 @@ +namespace Chickensoft.Introspection.Generator.Tests.TestCases; + +[Meta] +public readonly partial record struct ValueType { + public required int Number { get; init; } + public string? Description { get; init; } +} + +[Meta, Id("value_type_with_id")] +public readonly partial record struct ValueTypeWithId { + public required int Number { get; init; } + public string? Description { get; init; } +} diff --git a/Chickensoft.Introspection.Generator/src/TypeGenerator.cs b/Chickensoft.Introspection.Generator/src/TypeGenerator.cs index b39361f..9d6a6be 100644 --- a/Chickensoft.Introspection.Generator/src/TypeGenerator.cs +++ b/Chickensoft.Introspection.Generator/src/TypeGenerator.cs @@ -79,8 +79,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { .Select( // Combine non-unique type entries together. group => group.Aggregate( - (DeclaredType typeA, DeclaredType typeB) => - typeA.MergePartialDefinition(typeB) + (typeA, typeB) => typeA.MergePartialDefinition(typeB) ) ) .Where(type => type.Kind != DeclaredTypeKind.Error) @@ -117,8 +116,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { context.RegisterSourceOutput( source: incrementalGenerationData, action: static ( - SourceProductionContext context, - DeclaredTypeRegistry registry + context, + registry ) => { if (OutputMetatypesAndReportDiagnostics(context, registry)) { GenerateTypeRegistry(context, registry); @@ -248,7 +247,11 @@ type.Kind is DeclaredTypeKind.AbstractType && reference: baseTypeReference ); - if (currentType is not null) { + if ( + currentType is not null and not DeclaredType { + Kind: DeclaredTypeKind.Interface + } + ) { baseTypes.Add(currentType); continue; } @@ -400,7 +403,7 @@ TypeDeclarationSyntax typeDecl typeDecl.TypeParameterList?.Parameters .Select(p => p.Identifier.ValueText) .ToImmutableArray() - ?? ImmutableArray.Empty; + ?? []; /// /// True if the type declaration is explicitly marked as visible at the @@ -437,7 +440,8 @@ public static TypeLocation GetLocation(TypeDeclarationSyntax source) { ) { if (parent is BaseNamespaceDeclarationSyntax @namespace) { foreach ( - var namespacePart in @namespace.Name.ToString().Split('.').Reverse() + var namespacePart in @namespace.Name + .ToString().Split('.').AsEnumerable().Reverse() ) { namespaces.AddFirst(namespacePart); } @@ -446,7 +450,7 @@ var namespacePart in @namespace.Name.ToString().Split('.').Reverse() var typeParameters = type.TypeParameterList?.Parameters .Select(p => p.Identifier.ValueText) .ToImmutableArray() - ?? ImmutableArray.Empty; + ?? []; var construction = GetConstruction(type); var isPartial = IsPartial(type); @@ -463,8 +467,8 @@ var namespacePart in @namespace.Name.ToString().Split('.').Reverse() } return new TypeLocation( - namespaces.ToImmutableArray(), - types.ToImmutableArray() + [.. namespaces], + [.. types] ); } @@ -480,7 +484,7 @@ TypeDeclarationSyntax type allUsings = allUsings.AddRange(comp.Usings); } } - return allUsings + return [.. allUsings // `Name` will be null if used as an alias for a tuple (unrelated to // the using import directive). // @@ -488,7 +492,7 @@ TypeDeclarationSyntax type // introduced after Microsoft.CodeAnalysis.CSharp v4.4.0 which would // reference the tuple aliasing. .Where(@using => @using.Name is not null) - .Select(GetUsing).ToImmutableHashSet(); + .Select(GetUsing)]; } public static UsingDirective GetUsing(UsingDirectiveSyntax @using) => @@ -572,7 +576,7 @@ TypeDeclarationSyntax typeDecl .Select(arg => arg.Expression) .OfType() .Select(arg => arg.Type.NormalizeWhitespace().ToString()) - .ToImmutableArray() ?? ImmutableArray.Empty + .ToImmutableArray() ?? [] ); } } diff --git a/Chickensoft.Introspection.Generator/src/models/DeclaredType.cs b/Chickensoft.Introspection.Generator/src/models/DeclaredType.cs index 70d930f..f7e8479 100644 --- a/Chickensoft.Introspection.Generator/src/models/DeclaredType.cs +++ b/Chickensoft.Introspection.Generator/src/models/DeclaredType.cs @@ -346,6 +346,9 @@ public void WriteMetatype( IndentedTextWriter writer, IEnumerable baseTypes ) { + var isValueType = Reference.Construction is + Construction.RecordStruct or Construction.Struct; + if (!string.IsNullOrEmpty(Location.Namespace)) { writer.WriteLine($"namespace {Location.Namespace};\n"); } @@ -386,19 +389,25 @@ IEnumerable baseTypes .Where(prop => prop.IsInit || prop.IsRequired) .ToArray(); + var introspectiveInterface = isValueType + ? Constants.INTROSPECTIVE + : Constants.INTROSPECTIVE_REF; + // Nest inside us. writer.WriteLine( $"{Reference.CodeString} : " + - $"{Constants.INTROSPECTIVE}{identifiable}{mixins} {{" + $"{introspectiveInterface}{identifiable}{mixins} {{" ); writer.Indent++; - // Add a mixin state bucket to the type itself. - writer.WriteLine($"[{Constants.EXCLUDE_COVERAGE}]"); - writer.WriteLine( - $"public {Constants.MIXIN_BLACKBOARD} MixinState {{ get; }} = new();" - ); - writer.WriteLine(); + if (!isValueType) { + // Add a mixin state bucket to the type itself. + writer.WriteLine($"[{Constants.EXCLUDE_COVERAGE}]"); + writer.WriteLine( + $"public {Constants.MIXIN_BLACKBOARD} MixinState {{ get; }} = new();" + ); + writer.WriteLine(); + } // Add a metatype accessor to the type for convenience writer.WriteLine($"[{Constants.EXCLUDE_COVERAGE}]"); diff --git a/Chickensoft.Introspection.Generator/src/models/ScopeNode.cs b/Chickensoft.Introspection.Generator/src/models/ScopeNode.cs index 4ed9506..d2f3f2e 100644 --- a/Chickensoft.Introspection.Generator/src/models/ScopeNode.cs +++ b/Chickensoft.Introspection.Generator/src/models/ScopeNode.cs @@ -18,6 +18,7 @@ public abstract record ScopeNode( /// Parent node. /// Declared type.ย  /// Map of type names to type nodes. +[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] // due to net8 glitch? public sealed record TypeTreeNode( ScopeNode? Parent, DeclaredType Type, @@ -32,6 +33,7 @@ Dictionary TypeChildren /// Map of child namespaces names to child namespaces. /// /// Map of type names to type nodes. +[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] // due to net8 glitch? public sealed record NamespaceNode( ScopeNode? Parent, string Name, diff --git a/Chickensoft.Introspection.Generator/src/utils/Constants.cs b/Chickensoft.Introspection.Generator/src/utils/Constants.cs index d0cb97e..31c5249 100644 --- a/Chickensoft.Introspection.Generator/src/utils/Constants.cs +++ b/Chickensoft.Introspection.Generator/src/utils/Constants.cs @@ -7,6 +7,8 @@ public static class Constants { public const string VERSION_ATTRIBUTE_NAME = "Version"; public const string INTROSPECTIVE = "Chickensoft.Introspection.IIntrospective"; + public const string INTROSPECTIVE_REF = + "Chickensoft.Introspection.IIntrospectiveRef"; public const string IDENTIFIABLE = "Chickensoft.Introspection.IIdentifiable"; public const string MIXIN_BLACKBOARD = "Chickensoft.Introspection.MixinBlackboard"; diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TypeGraphTest_Model4FF6A4782E.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TypeGraphTest_Model4FF6A4782E.g.cs index 5939d1f..cb71b45 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TypeGraphTest_Model4FF6A4782E.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/Tests_TypeGraphTest_Model4FF6A4782E.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphTest { - partial class Model : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { + partial class Model : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TypeGraphTest_NoSubtypesB50BED7369.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TypeGraphTest_NoSubtypesB50BED7369.g.cs index a03c409..6487d0f 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TypeGraphTest_NoSubtypesB50BED7369.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/_TypeGraphTest_NoSubtypesB50BED7369.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphTest { - partial class NoSubtypes : Chickensoft.Introspection.IIntrospective { + partial class NoSubtypes : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/aphTest_SubtypeA_SubtypeBCECBE7E572.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/aphTest_SubtypeA_SubtypeBCECBE7E572.g.cs index f1c1a6b..9478c8b 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/aphTest_SubtypeA_SubtypeBCECBE7E572.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/aphTest_SubtypeA_SubtypeBCECBE7E572.g.cs @@ -13,7 +13,7 @@ namespace Chickensoft.Introspection.Tests; partial class TypeGraphTest { partial class SubtypeA { - partial class SubtypeB : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { + partial class SubtypeB : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/erMetadataTest_ChildModelD70FB8BF24.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/erMetadataTest_ChildModelD70FB8BF24.g.cs index 9b9ba12..88951e4 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/erMetadataTest_ChildModelD70FB8BF24.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/erMetadataTest_ChildModelD70FB8BF24.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphMemberMetadataTest { - partial class ChildModel : Chickensoft.Introspection.IIntrospective { + partial class ChildModel : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hMemberMetadataTest_Model8D28D57DDD.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hMemberMetadataTest_Model8D28D57DDD.g.cs index d251524..5500b69 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hMemberMetadataTest_Model8D28D57DDD.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/hMemberMetadataTest_Model8D28D57DDD.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphMemberMetadataTest { - partial class Model : Chickensoft.Introspection.IIntrospective { + partial class Model : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/on_Tests_MyTypeWithAMixin444DFB44AF.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/on_Tests_MyTypeWithAMixin444DFB44AF.g.cs index 1ea9c91..7b9b145 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/on_Tests_MyTypeWithAMixin444DFB44AF.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/on_Tests_MyTypeWithAMixin444DFB44AF.g.cs @@ -6,7 +6,7 @@ namespace Chickensoft.Introspection.Tests; using System; using Xunit; -partial class MyTypeWithAMixin : Chickensoft.Introspection.IIntrospective, IMixin1, IMixin2 { +partial class MyTypeWithAMixin : Chickensoft.Introspection.IIntrospectiveRef, IMixin1, IMixin2 { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model112B5DD8E71.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model112B5DD8E71.g.cs index c077daa..2d5c7f9 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model112B5DD8E71.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model112B5DD8E71.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphVersionTest { - partial class Model1 : Chickensoft.Introspection.IIntrospective { + partial class Model1 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model222666FE7CE.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model222666FE7CE.g.cs index da0fa9d..9e2a504 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model222666FE7CE.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model222666FE7CE.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphVersionTest { - partial class Model2 : Chickensoft.Introspection.IIntrospective { + partial class Model2 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model3B7B5491774.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model3B7B5491774.g.cs index 9046f42..9e50ebb 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model3B7B5491774.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/peGraphVersionTest_Model3B7B5491774.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphVersionTest { - partial class Model3 : Chickensoft.Introspection.IIntrospective { + partial class Model3 : Chickensoft.Introspection.IIntrospectiveRef { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeA96F062FA2B.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeA96F062FA2B.g.cs index fe5539a..bbf4e13 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeA96F062FA2B.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeA96F062FA2B.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphTest { - partial class SubtypeA : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { + partial class SubtypeA : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeCC2FA7FBDBB.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeCC2FA7FBDBB.g.cs index bcf13e6..659b48d 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeCC2FA7FBDBB.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ts_TypeGraphTest_SubtypeCC2FA7FBDBB.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphTest { - partial class SubtypeC : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { + partial class SubtypeC : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ypeGraphVersionTest_Model691E41E943.g.cs b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ypeGraphVersionTest_Model691E41E943.g.cs index 25fdeed..b5d3641 100644 --- a/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ypeGraphVersionTest_Model691E41E943.g.cs +++ b/Chickensoft.Introspection.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/ypeGraphVersionTest_Model691E41E943.g.cs @@ -12,7 +12,7 @@ namespace Chickensoft.Introspection.Tests; using Xunit; partial class TypeGraphVersionTest { - partial class Model : Chickensoft.Introspection.IIntrospective, Chickensoft.Introspection.IIdentifiable { + partial class Model : Chickensoft.Introspection.IIntrospectiveRef, Chickensoft.Introspection.IIdentifiable { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new(); diff --git a/Chickensoft.Introspection.Tests/Chickensoft.Introspection.Tests.csproj b/Chickensoft.Introspection.Tests/Chickensoft.Introspection.Tests.csproj index 203e53d..0de1ddc 100644 --- a/Chickensoft.Introspection.Tests/Chickensoft.Introspection.Tests.csproj +++ b/Chickensoft.Introspection.Tests/Chickensoft.Introspection.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 disable enable diff --git a/Chickensoft.Introspection.Tests/test/models/IIntrospectiveTest.cs b/Chickensoft.Introspection.Tests/test/models/IIntrospectiveTest.cs index 1b3ec8d..1adbd0d 100644 --- a/Chickensoft.Introspection.Tests/test/models/IIntrospectiveTest.cs +++ b/Chickensoft.Introspection.Tests/test/models/IIntrospectiveTest.cs @@ -29,7 +29,7 @@ public IIntrospectiveTest() { [Fact] public void MixinIsCalled() { - IIntrospective myType = new MyTypeWithAMixin(); + IIntrospectiveRef myType = new MyTypeWithAMixin(); myType.InvokeMixin(typeof(IMixin1)); Called1.ShouldBeTrue(); @@ -37,7 +37,7 @@ public void MixinIsCalled() { [Fact] public void AllMixinsCalled() { - IIntrospective myType = new MyTypeWithAMixin(); + IIntrospectiveRef myType = new MyTypeWithAMixin(); myType.InvokeMixins(); Called1.ShouldBeTrue(); @@ -46,7 +46,7 @@ public void AllMixinsCalled() { [Fact] public void ThrowsOnMissingMixin() { - IIntrospective myType = new MyTypeWithAMixin(); + IIntrospectiveRef myType = new MyTypeWithAMixin(); Should.Throw( () => myType.InvokeMixin(typeof(IIntrospectiveTest)) ); diff --git a/Chickensoft.Introspection/src/attributes/IdAttribute.cs b/Chickensoft.Introspection/src/attributes/IdAttribute.cs index 6b98b81..3c41c0b 100644 --- a/Chickensoft.Introspection/src/attributes/IdAttribute.cs +++ b/Chickensoft.Introspection/src/attributes/IdAttribute.cs @@ -9,7 +9,7 @@ namespace Chickensoft.Introspection; /// across all introspective types from every assembly used in your project. /// [AttributeUsage( - AttributeTargets.Class, + AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true )] diff --git a/Chickensoft.Introspection/src/attributes/MetaAttribute.cs b/Chickensoft.Introspection/src/attributes/MetaAttribute.cs index ac777b9..21c932f 100644 --- a/Chickensoft.Introspection/src/attributes/MetaAttribute.cs +++ b/Chickensoft.Introspection/src/attributes/MetaAttribute.cs @@ -8,7 +8,9 @@ namespace Chickensoft.Introspection; /// (referred to as a metatype) will be generated at compile-time by the /// introspection generator. /// -[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] +[AttributeUsage( + AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false +)] public sealed class MetaAttribute : Attribute { /// diff --git a/Chickensoft.Introspection/src/types/IIntrospective.cs b/Chickensoft.Introspection/src/types/IIntrospective.cs index bae994b..2bdf74b 100644 --- a/Chickensoft.Introspection/src/types/IIntrospective.cs +++ b/Chickensoft.Introspection/src/types/IIntrospective.cs @@ -8,15 +8,21 @@ namespace Chickensoft.Introspection; /// public interface IIntrospective { /// - /// Arbitrary data that is shared between mixins. Mixins are free to store - /// additional instance state in this blackboard. + /// Generated metatype information. /// - MixinBlackboard MixinState { get; } + IMetatype Metatype { get; } +} +/// +/// Interface applied to a type to introspective reference types. Introspective +/// reference types support mixins. +/// +public interface IIntrospectiveRef : IIntrospective { /// - /// Generated metatype information. + /// Arbitrary data that is shared between mixins. Mixins are free to store + /// additional instance state in this blackboard. /// - public IMetatype Metatype { get; } + MixinBlackboard MixinState { get; } /// /// Determines if the type has a mixin applied to it. @@ -24,12 +30,12 @@ public interface IIntrospective { /// Type of mixin to look for. /// True if the type has the specified mixin, false otherwise. /// - public bool HasMixin(Type type) => Metatype.MixinHandlers.ContainsKey(type); + bool HasMixin(Type type) => Metatype.MixinHandlers.ContainsKey(type); /// /// Invokes the handler of each mixin that is applied to the type. /// - public void InvokeMixins() { + void InvokeMixins() { for (var i = 0; i < Metatype.Mixins.Count; i++) { Metatype.MixinHandlers[Metatype.Mixins[i]](this); } @@ -40,7 +46,7 @@ public void InvokeMixins() { /// /// Mixin type. /// - public void InvokeMixin(Type type) { + void InvokeMixin(Type type) { if (!HasMixin(type)) { throw new InvalidOperationException( $"Type {GetType()} does not have mixin {type}" diff --git a/Chickensoft.Introspection/src/types/IMixin.cs b/Chickensoft.Introspection/src/types/IMixin.cs index ffd1758..0fea735 100644 --- a/Chickensoft.Introspection/src/types/IMixin.cs +++ b/Chickensoft.Introspection/src/types/IMixin.cs @@ -5,7 +5,7 @@ namespace Chickensoft.Introspection; /// mixin with the . /// /// Type of the mixin. -public interface IMixin : IIntrospective { +public interface IMixin : IIntrospectiveRef { /// /// Mixin handler method. Types marked with the /// have information about their mixins diff --git a/README.md b/README.md index 69bed61..21f7937 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ๐Ÿ”ฎ Introspection -[![Chickensoft Badge][chickensoft-badge]][chickensoft-website] [![Discord][discord-badge]][discord] [![Read the docs][read-the-docs-badge]][docs] ![line coverage][line-coverage] ![branch coverage][branch-coverage] +[![Chickensoft Badge][chickensoft-badge]][chickensoft-website] [![Discord][discord-badge]][discord] ![line coverage][line-coverage] ![branch coverage][branch-coverage] Create mixins and generate metadata about types at build time to enable reflection in ahead-of-time (AOT) environments. @@ -53,6 +53,9 @@ You don't need to fully understand this package to make the most of it. In fact, - ๐Ÿ’‰ [AutoInject] uses this tool to allow you to add mixins to classes at build-time and invoke their methods at runtime without reflection. It also leverages this to read attributes on types without having to use reflection. - ๐Ÿ’ก [LogicBlocks] uses this tool to look up possible states for a state machine so it can pre-allocate them at runtime without needing reflection. +> [!NOTE] +> In general, you will typically just include this project and its source generator in your project so that other tools can make use of the generated metadata about the types in your project. For those interested in building metaprogramming tools which leverage this package, read on! + The introspection generator is designed to be performant as a project grows. The generator only uses syntax information to generate metadata, rather than relying on the C# analyzer's symbol data, which can be very slow. > [!NOTE] @@ -81,11 +84,11 @@ The generator will generate a [type registry] for your assembly that lists every The generated registry automatically registers types with the Introspection library's [type graph] using a [module initializer], so no action is needed on the developer's part. The module initializer registration process also performs some logic at runtime to resolve the type graph and cache the type hierarchy in a way that makes it performant to lookup. This preprocessing runs in roughly linear time and is negligible. -All introspective types must be a class or record, partial, visible from the global scope. Introspective types cannot be generic. +All introspective types must be a class, record, struct, or record struct. They must also be partial and visible from the global scope (nesting inside other types is allowed if all nested types are visible from the global scope and partial). **Introspective types cannot be generic** โ€” this is an intentional limitation. ### ๐Ÿชช Identifiable Types -An introspective type can also be an identifiable type if it is given the `[Id]` attribute. Identifiable types get additional metadata generated about them, allowing them to be looked up by their identifier. +An introspective type can also be an _identifiable_ type if it is given the `[Id]` attribute. Identifiable types get additional metadata generated about them, allowing them to be looked up by their identifier. Identifiable types can be used to create a [serialization][Serialization] system, since id's are strings which should be kept stable even if the type itself is renamed. ```csharp [Meta, Id("my_type")] @@ -94,7 +97,7 @@ An introspective type can also be an identifiable type if it is given the `[Id]` ### โคต๏ธ The Type Graph -The type graph can be used to query information about types at runtime. If the type graph has to compute a query, the results are cached for all future queries. Most api's are simple O(1) lookups. +The type graph can be used to query information about types at runtime. If the type graph has to compute a query, the results are cached for all future queries. Most api's are simple `O(1)` lookups. ```csharp @@ -117,11 +120,19 @@ var properties = Types.Graph.GetProperties(typeof(Model)); ### ๐Ÿ‘ฏโ€โ™€๏ธ Versioning -All concrete introspective types have a simple integer version associated with them. By default, the version is `1`. You can use the `[Version]` attribute to denote the version of an introspective type. +All concrete (not abstract) introspective types have a simple integer version associated with them. By default, the version is `1`. You can use the `[Version]` attribute to denote the version of introspective reference types. ```csharp [Meta, Version(2)] public partial class MyType; +``` + +A single identifiable type can have multiple versions. Each version is indicated by making another type which extends it and denotes its version with the `[Version]` attribute. + +> [!CAUTION] +> **Value types cannot be versioned since C# does not support struct inheritance.**. + +```csharp // Or, multiple versions of the same identifiable type. @@ -138,7 +149,7 @@ public class MyType2 : MyType; public class MyType3 : MyType; ``` -During type registration, the type graph will "promote" introspective types which inherit from an identifiable type to an identifiable type themselves, sharing the same identifier as their parent or ancestor identifiable type. Promoted identifiable types must, however, have uniquely specified versions. +During type registration, the type graph will "promote" introspective types which inherit from an identifiable type to an identifiable type themselves, sharing the same identifier as their parent or ancestor identifiable type. Promoted identifiable types must, however, have uniquely specified versions. For example, the types shown above (`MyType1`, `MyType2`, and `MyType3`) would be promoted at runtime by the type graph when the application first starts, allowing them to be seen as the same identifiable type as their parent, `MyType`. Fortunately, this all happens automatically. ## ๐Ÿ”Ž Metadata Types @@ -203,30 +214,90 @@ if (metadata is IIdentifiableTypeMetadata idMetadata) { } ``` -## ฮ” Metatypes +The metadata type hierarchy is admittedly quite crazy, but extremely useful since it allows tools built on this library to understand what information is available about a type depending on how it was attributed with `[Meta]`, `[Id]`, or `[Version]` attributes (or not at all). In the class diagram below, solid lines indicate inheritance, while dashed lines indicate interface implementation. -The introspection generator generates additional metadata for introspective and identifiable types known as a "metatype." A type's metatype information can be accessed from its metadata. +```mermaid +classDiagram + %% โ”€โ”€โ”€ Interfaces โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + class ITypeMetadata { + +string Name + } -```csharp -var metadata = Types.Graph.GetMetadata(typeof(Model)); + class IClosedTypeMetadata { + +Action GenericTypeGetter + } + ITypeMetadata <|-- IClosedTypeMetadata -if (metadata is IIntrospectiveTypeMetadata introMetadata) { - var metatype = introMetadata.Metatype; + class IConcreteTypeMetadata { + +Func Factory + } + IClosedTypeMetadata <|-- IConcreteTypeMetadata - foreach (var attribute in metatype.Attributes) { - // Iterate the attributes on an introspective type. - } + class IIntrospectiveTypeMetadata { + +IMetatype Metatype + } + IClosedTypeMetadata <|-- IIntrospectiveTypeMetadata - foreach (var property in metatype.Properties) { - // Iterate the properties of an introspective type. - if (property.Setter is { } setter) { - // We can set the value of the property. - setter(obj, value); + class IConcreteIntrospectiveTypeMetadata { + +int Version } + IIntrospectiveTypeMetadata <|-- IConcreteIntrospectiveTypeMetadata + IConcreteTypeMetadata <|-- IConcreteIntrospectiveTypeMetadata + + class IIdentifiableTypeMetadata { + +string Id + } + IIntrospectiveTypeMetadata <|-- IIdentifiableTypeMetadata + + + %% โ”€โ”€โ”€ Records / concrete types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + class TypeMetadata { + +string Name + } + ITypeMetadata <|.. TypeMetadata + + class ConcreteTypeMetadata { + +Action GenericTypeGetter + +Func Factory + } + TypeMetadata <|-- ConcreteTypeMetadata + IConcreteTypeMetadata <|.. ConcreteTypeMetadata + + class AbstractIntrospectiveTypeMetadata { + +Action GenericTypeGetter + +IMetatype Metatype + } + TypeMetadata <|-- AbstractIntrospectiveTypeMetadata + IIntrospectiveTypeMetadata <|.. AbstractIntrospectiveTypeMetadata + + class IntrospectiveTypeMetadata { + +Action GenericTypeGetter + +Func Factory + +IMetatype Metatype + +int Version + } + ConcreteTypeMetadata <|-- IntrospectiveTypeMetadata + IConcreteIntrospectiveTypeMetadata <|.. IntrospectiveTypeMetadata + + class AbstractIdentifiableTypeMetadata { + +Action GenericTypeGetter + +IMetatype Metatype + +string Id + } + AbstractIntrospectiveTypeMetadata <|-- AbstractIdentifiableTypeMetadata + IIdentifiableTypeMetadata <|.. AbstractIdentifiableTypeMetadata + + class IdentifiableTypeMetadata { + +Action GenericTypeGetter + +Func Factory + +IMetatype Metatype + +string Id + +int Version + } + IntrospectiveTypeMetadata <|-- IdentifiableTypeMetadata + IIdentifiableTypeMetadata <|.. IdentifiableTypeMetadata + IConcreteIntrospectiveTypeMetadata <|.. IdentifiableTypeMetadata - // etc. - } -} ``` Metatype data provides information about a specific type, its properties, and attributes. The type graph combines metatype information with its understanding of the type hierarchy to enable you to fetch all properties of an introspective type, including those it inherited from other introspective types. Metatypes will only contain information about the type itself, not anything it inherits from. @@ -235,11 +306,14 @@ To see all of the information that a metatype exposes, please see the [Metatype ## ๐ŸŽ›๏ธ Mixins -The introspection generator allows you to create mixins to add additional functionality to the type they are applied to. Unlike [default interface method implementations], mixins are able to add _[instance state]_ via a [blackboard]. Every introspective type has a `MixinState` blackboard which allows mixins to add instance data to the type they are applied to. +The introspection generator allows you to create mixins on introspective reference types to add additional functionality to the type. Unlike [default interface method implementations], mixins are able to add _[instance state]_ via a [blackboard]. Every introspective reference type has a `MixinState` blackboard which allows mixins to add instance data to the type they are applied to. Additionally, mixins must implement a single handler method. An introspective type's `Metatype` has a `Mixins` property containing a list of mixin types that were applied to it. Additionally, a `MixinHandler` table is provided which maps the mixin type to a closure which invokes the mixin's handler. -Introspective type instances can also cast themselves to `IIntrospective` to invoke a given mixin easily. +Introspective type instances can also cast themselves to `IIntrospectiveRef` to invoke a given mixin easily. + +> [!WARNING] +> Value types do not support mixins. ```csharp // Declare a mixin @@ -255,25 +329,57 @@ public partial class MyModel { // Use mixins public void MyMethod() { // Call all applied mixin handlers - (this as IIntrospective).InvokeMixins(); + (this as IIntrospectiveRef).InvokeMixins(); // Call a specific mixin handler - (this as IIntrospective).InvokeMixin(typeof(IMyMixin)); + (this as IIntrospectiveRef).InvokeMixin(typeof(IMyMixin)); } } ``` +## ๐Ÿฅž Value Types + +The introspection generator can generate metadata about value types, too. + +> [!CAUTION] +> **Value types do not support versioning or mixins.** +> +> Mixins _could have_ been supported, but we chose not to support them since they would add a heap-allocated object to each value type, defeating the memory performance gains that value types provide. + +```csharp +[Meta] +public readonly partial record struct ValueType { + public required int Number { get; init; } + public string? Description { get; init; } +} + +[Meta, Id("value_type_with_id")] +public readonly partial record struct ValueTypeWithId { + public required int Number { get; init; } + public string? Description { get; init; } +} +``` + +Likewise, you can introspect a value type the same as other introspective types: + +```csharp +// Get a type's properties +var properties = Types.Graph.GetProperties(typeof(ValueType)); + +foreach (var property in properties) { + // ... do something with the properties of the type +} +``` + --- ๐Ÿฃ Package generated from a ๐Ÿค Chickensoft Template โ€” -[chickensoft-badge]: https://raw.githubusercontent.com/chickensoft-games/chickensoft_site/main/static/img/badges/chickensoft_badge.svg +[chickensoft-badge]: https://chickensoft.games/img/badges/chickensoft_badge.svg [chickensoft-website]: https://chickensoft.games [philosophy]: https://chickensoft.games/philosophy -[discord-badge]: https://raw.githubusercontent.com/chickensoft-games/chickensoft_site/main/static/img/badges/discord_badge.svg +[discord-badge]: https://chickensoft.games/img/badges/discord_badge.svg [discord]: https://discord.gg/gSjaPgMmYW -[read-the-docs-badge]: https://raw.githubusercontent.com/chickensoft-games/chickensoft_site/main/static/img/badges/read_the_docs_badge.svg -[docs]: https://chickensoft.games/docs/ [line-coverage]: Chickensoft.Introspection.Tests/badges/line_coverage.svg [branch-coverage]: Chickensoft.Introspection.Tests/badges/branch_coverage.svg