Skip to content

Commit

Permalink
feat: annotate generated code with GeneratedCodeAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jonisavo committed Oct 18, 2022
1 parent ae18491 commit 75b0c35
Show file tree
Hide file tree
Showing 70 changed files with 295 additions and 81 deletions.
24 changes: 12 additions & 12 deletions Assets/UIComponents/Core/UIComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected UIComponent()
_dependencyInjector = DiContext.Current.GetInjector(_componentType);
AssetResolver = Provide<IAssetResolver>();
Logger = Provide<IUIComponentLogger>();
PopulateProvideFields();
UIC_PopulateProvideFields();

DependencySetupProfilerMarker.End();

Expand Down Expand Up @@ -105,8 +105,8 @@ private async void Initialize()

PostHierarchySetupProfilerMarker.Begin();

ApplyEffects();
PopulateQueryFields();
UIC_ApplyEffects();
UIC_PopulateQueryFields();
RegisterEventInterfaceCallbacks();

PostHierarchySetupProfilerMarker.End();
Expand Down Expand Up @@ -213,15 +213,15 @@ public string GetTypeName()
{
return _dependencyInjector.TryProvide(out instance);
}

protected virtual Task<VisualTreeAsset> StartLayoutLoad()
protected virtual Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return Task.FromResult<VisualTreeAsset>(null);
}

private Task<VisualTreeAsset> GetLayout()
{
return StartLayoutLoad();
return UIC_StartLayoutLoad();
}

protected readonly struct StyleSheetLoadTuple
Expand All @@ -236,15 +236,15 @@ public StyleSheetLoadTuple(string path, StyleSheet styleSheet)
}
}

protected virtual Task<StyleSheetLoadTuple>[] StartStyleSheetLoad()
protected virtual Task<StyleSheetLoadTuple>[] UIC_StartStyleSheetLoad()
{
return Array.Empty<Task<StyleSheetLoadTuple>>();
}

private async Task<List<StyleSheet>> GetStyleSheets()
{
var styleSheetLoadTasks =
StartStyleSheetLoad();
UIC_StartStyleSheetLoad();

await Task.WhenAll(styleSheetLoadTasks);

Expand All @@ -266,10 +266,10 @@ private async Task<List<StyleSheet>> GetStyleSheets()
return loadedStyleSheets;
}

protected virtual void ApplyEffects() {}
protected virtual void UIC_ApplyEffects() {}

protected virtual void PopulateQueryFields() {}
protected virtual void UIC_PopulateQueryFields() {}

protected virtual void PopulateProvideFields() {}
protected virtual void UIC_PopulateProvideFields() {}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
// </auto-generated>

using System;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class PriorityEffectComponent
{
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static UIComponentEffectAttribute[] UIC_EffectAttributes;

[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static void UIC_InitializeEffectAttributes()
{
UIC_EffectAttributes = new [] {
Expand All @@ -20,7 +23,8 @@ private static void UIC_InitializeEffectAttributes()
Array.Sort(UIC_EffectAttributes);
}

protected override void ApplyEffects()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override void UIC_ApplyEffects()
{
if (UIC_EffectAttributes == null)
UIC_InitializeEffectAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
// </auto-generated>

using System;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class BasicEffectComponent
{
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static UIComponentEffectAttribute[] UIC_EffectAttributes;

[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static void UIC_InitializeEffectAttributes()
{
UIC_EffectAttributes = new [] {
Expand All @@ -20,7 +23,8 @@ private static void UIC_InitializeEffectAttributes()
Array.Sort(UIC_EffectAttributes);
}

protected override void ApplyEffects()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override void UIC_ApplyEffects()
{
if (UIC_EffectAttributes == null)
UIC_InitializeEffectAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
// </auto-generated>

using System;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class BaseEffectComponent
{
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static UIComponentEffectAttribute[] UIC_EffectAttributes;

[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static void UIC_InitializeEffectAttributes()
{
UIC_EffectAttributes = new [] {
Expand All @@ -19,7 +22,8 @@ private static void UIC_InitializeEffectAttributes()
Array.Sort(UIC_EffectAttributes);
}

protected override void ApplyEffects()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override void UIC_ApplyEffects()
{
if (UIC_EffectAttributes == null)
UIC_InitializeEffectAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
// </auto-generated>

using System;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class SecondSubclassEffectComponent
{
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static UIComponentEffectAttribute[] UIC_EffectAttributes;

[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static void UIC_InitializeEffectAttributes()
{
UIC_EffectAttributes = new [] {
Expand All @@ -21,7 +24,8 @@ private static void UIC_InitializeEffectAttributes()
Array.Sort(UIC_EffectAttributes);
}

protected override void ApplyEffects()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override void UIC_ApplyEffects()
{
if (UIC_EffectAttributes == null)
UIC_InitializeEffectAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
// </auto-generated>

using System;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class SubclassEffectComponent
{
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static UIComponentEffectAttribute[] UIC_EffectAttributes;

[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private static void UIC_InitializeEffectAttributes()
{
UIC_EffectAttributes = new [] {
Expand All @@ -20,7 +23,8 @@ private static void UIC_InitializeEffectAttributes()
Array.Sort(UIC_EffectAttributes);
}

protected override void ApplyEffects()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override void UIC_ApplyEffects()
{
if (UIC_EffectAttributes == null)
UIC_InitializeEffectAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class BaseLayoutComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/BaseLayoutComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class OverriddenLayoutComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/OverriddenLayoutComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class LayoutTestComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/LayoutTestComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class ParentClass
{
public partial class FirstNestedComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/FirstNestedComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class ParentClass
{
private partial class SecondNestedComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/SecondNestedComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class LayoutTestComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("UI/Components/LayoutTestComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class BaseLayoutComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/BaseLayoutComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class SuperclassLayoutComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/BaseLayoutComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// </auto-generated>

using System.Threading.Tasks;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class ThirdLayoutComponent
{
protected override Task<VisualTreeAsset> StartLayoutLoad()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override Task<VisualTreeAsset> UIC_StartLayoutLoad()
{
return AssetResolver.LoadAsset<VisualTreeAsset>("Components/BaseLayoutComponent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

using System;
using UIComponents;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class MyClass
{
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private void UIC_SetProvideField<TField, TCastFrom>(ref TField value, string fieldName) where TField : class where TCastFrom : class
{
try
Expand All @@ -26,7 +28,8 @@ public partial class MyClass
}
}

protected override void PopulateProvideFields()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override void UIC_PopulateProvideFields()
{
UIC_SetProvideField<IDependency, IDependency>(ref Dependency, "Dependency");
UIC_SetProvideField<Dependency, IDependency>(ref ConcreteDependency, "ConcreteDependency");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

using System;
using UIComponents;
using System.CodeDom.Compiler;
using UnityEngine.UIElements;

public partial class InvalidProvideComponent
{
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
private void UIC_SetProvideField<TField, TCastFrom>(ref TField value, string fieldName) where TField : class where TCastFrom : class
{
try
Expand All @@ -26,7 +28,8 @@ public partial class InvalidProvideComponent
}
}

protected override void PopulateProvideFields()
[GeneratedCode("UIComponents.Roslyn.Generation", "0.26.0")]
protected override void UIC_PopulateProvideFields()
{
UIC_SetProvideField<IDependency, IDependency>(ref Dependency, "Dependency");
}
Expand Down
Loading

0 comments on commit 75b0c35

Please sign in to comment.