diff --git a/ExampleGenerator/Unity/Ui/UIBackingClassGenerator.cs b/ExampleGenerator/Unity/Ui/UIBackingClassGenerator.cs index 2ceef29..7b47568 100644 --- a/ExampleGenerator/Unity/Ui/UIBackingClassGenerator.cs +++ b/ExampleGenerator/Unity/Ui/UIBackingClassGenerator.cs @@ -83,10 +83,10 @@ internal class {Helpers.UiElementAttribute} : Attribute , SymbolEqualityComparer.Default ) ) { var classSymbol = group.Key; - // if (! Helpers.IsDerivedFrom( classSymbol , "AtVisualElement" ) ) - // { - // continue; - // } + if (classSymbol is null || ! Helpers.IsDerivedFrom( classSymbol , "AtVisualElement" ) ) + { + continue; + } var classSource = ProcessClassUiElement( classSymbol , group , uiElementAttributeSymbol ); if ( classSource == null ) continue; @@ -95,14 +95,10 @@ internal class {Helpers.UiElementAttribute} : Attribute } foreach ( var classSymbol in receiver.Classes ) { - if ( classSymbol is null ) + if (classSymbol is null || ! Helpers.IsDerivedFrom( classSymbol , "AtVisualElement" ) ) { continue; } - // if (! Helpers.IsDerivedFrom( classSymbol , "AtVisualElement" ) ) - // { - // continue; - // } var classSource = ProcessClassUiComponent( classSymbol , atUiComponentAttributeSymbol ); if ( classSource == null ) continue; @@ -167,7 +163,7 @@ internal class {Helpers.UiElementAttribute} : Attribute using UnityEngine.UIElements; namespace {classSymbol.ContainingNamespace} {{ -public partial class {classSymbol.Name} : AtVisualElement +public partial class {classSymbol.Name} {{"); } private static void AppendClassFrameEnd( StringBuilder source ) diff --git a/TestConsole/Program.cs b/TestConsole/Program.cs index c8fddfb..a13bf4b 100644 --- a/TestConsole/Program.cs +++ b/TestConsole/Program.cs @@ -22,21 +22,26 @@ namespace TestConsole public partial class Test1 : AtVisualElement { // protected override string UxmlPath =>""; - // [UiElement] + [UiElement] public AtVisualElement test; public void Test123() { - Console.WriteLine( "test" ); - Console.WriteLine( $"UxmlPath: '{UxmlPath}'" ); + Console.WriteLine( "test start" ); QueryElements(); + Console.WriteLine( "test end" ); } } public abstract class AtVisualElement { - protected abstract string UxmlPath { get; } - // protected virtual string UxmlPath { get; } + protected AtVisualElement() + { + // ReSharper disable once VirtualMemberCallInConstructor + Console.WriteLine( $"UxmlPath: '{UxmlPath}'" ); + } + // protected abstract string UxmlPath { get; } + protected virtual string UxmlPath { get; } protected virtual void QueryElements() {