Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: static properties #3

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading