Skip to content

Commit

Permalink
Merge pull request #3 from chickensoft-games/fix/static-properties
Browse files Browse the repository at this point in the history
fix: static properties
  • Loading branch information
jolexxa authored Jun 9, 2024
2 parents 281a55f + 58488fd commit 47c30b3
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public partial class TypeRegistry : Chickensoft.Introspection.ITypeRegistry {
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.PartialModel)] = new Chickensoft.Introspection.IdentifiableTypeMetadata("PartialModel", (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.PartialModel>(), () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.PartialModel>(), new Chickensoft.Introspection.Generator.Tests.TestCases.PartialModel.MetatypeMetadata(), "multiple_partial_definitions", 1),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.PropertyModel)] = new Chickensoft.Introspection.AbstractIntrospectiveTypeMetadata("PropertyModel", (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.PropertyModel>(), new Chickensoft.Introspection.Generator.Tests.TestCases.PropertyModel.MetatypeMetadata()),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.SomeType)] = new Chickensoft.Introspection.IntrospectiveTypeMetadata("SomeType", (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.SomeType>(), () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.SomeType>(), new Chickensoft.Introspection.Generator.Tests.TestCases.SomeType.MetatypeMetadata(), 1),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.StaticPropertyIsSkipped)] = new Chickensoft.Introspection.IntrospectiveTypeMetadata("StaticPropertyIsSkipped", (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.StaticPropertyIsSkipped>(), () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.StaticPropertyIsSkipped>(), new Chickensoft.Introspection.Generator.Tests.TestCases.StaticPropertyIsSkipped.MetatypeMetadata(), 1),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A)] = new Chickensoft.Introspection.ConcreteTypeMetadata("A", (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A>(), () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A>()),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A.AA)] = new Chickensoft.Introspection.ConcreteTypeMetadata("AA", (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A.AA>(), () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A.AA>()),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A.AA.AAA)] = new Chickensoft.Introspection.ConcreteTypeMetadata("AAA", (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A.AA.AAA>(), () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.TraditionalNamespace.A.AA.AAA>()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma warning disable
#nullable enable
namespace Chickensoft.Introspection.Generator.Tests.TestCases;

using Chickensoft.Introspection;

partial class StaticPropertyIsSkipped : Chickensoft.Introspection.IIntrospective {
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public Chickensoft.Introspection.MixinBlackboard MixinState { get; } = new();

[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public Chickensoft.Introspection.IMetatype Metatype => ((Chickensoft.Introspection.IIntrospectiveTypeMetadata)Chickensoft.Introspection.Types.Graph.GetMetadata(typeof(StaticPropertyIsSkipped))).Metatype;

public class MetatypeMetadata : Chickensoft.Introspection.IMetatype {
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public System.Type Type => typeof(StaticPropertyIsSkipped);
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public bool HasInitProperties { get; } = false;

[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public System.Collections.Generic.IReadOnlyList<Chickensoft.Introspection.PropertyMetadata> Properties { get; } = new System.Collections.Generic.List<Chickensoft.Introspection.PropertyMetadata>() {
};

[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public System.Collections.Generic.IReadOnlyDictionary<System.Type, System.Attribute[]> Attributes { get; } = new System.Collections.Generic.Dictionary<System.Type, System.Attribute[]>() {
[typeof(MetaAttribute)] = new System.Attribute[] {
new MetaAttribute()
}
};

[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public System.Collections.Generic.IReadOnlyList<System.Type> Mixins { get; } = new System.Collections.Generic.List<System.Type>() {
};

[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public System.Collections.Generic.IReadOnlyDictionary<System.Type, System.Action<object>> MixinHandlers { get; } = new System.Collections.Generic.Dictionary<System.Type, System.Action<object>>() {
};


[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public object Construct(System.Collections.Generic.IReadOnlyDictionary<string, object?>? args = null) {
return new StaticPropertyIsSkipped();
}
[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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Chickensoft.Introspection.Generator.Tests.TestCases;

using Chickensoft.Introspection;

[Meta]
public partial class StaticPropertyIsSkipped {
public static string Name => "StaticPropertyIsSkipped";
}
4 changes: 4 additions & 0 deletions Chickensoft.Introspection.Generator/src/TypeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ TypeDeclarationSyntax type
) {
var properties = ImmutableArray.CreateBuilder<DeclaredProperty>();
foreach (var property in type.Members.OfType<PropertyDeclarationSyntax>()) {
if (property.Modifiers.Any(SyntaxKind.StaticKeyword)) {
continue;
}

var propertyAttributes = GetAttributes(property.AttributeLists);

// Never identified a situation in which the accessor list is null.
Expand Down

0 comments on commit 47c30b3

Please sign in to comment.