Skip to content

Commit

Permalink
feat(UIComponent): remove GetTypeName method
Browse files Browse the repository at this point in the history
BREAKING CHANGE: UIComponent's GetTypeName method has been removed as it was unnecessary. Use GetType().Name instead.
  • Loading branch information
jonisavo committed Oct 23, 2022
1 parent 5749d0f commit 1f7343a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
13 changes: 0 additions & 13 deletions Assets/UIComponents.Tests/UIComponentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,5 @@ public void Bare_Component_Initializes_Synchronously()
Assert.That(component.Initialized, Is.True);
}
}

[TestFixture]
public partial class GetTypeName
{
private partial class TestComponent : UIComponent {}

[Test]
public void ShouldReturnTypeName()
{
var component = new TestComponent();
Assert.That(nameof(TestComponent), Is.EqualTo(component.GetTypeName()));
}
}
}
}
21 changes: 6 additions & 15 deletions Assets/UIComponents/Core/UIComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace UIComponents
/// <seealso cref="StylesheetAttribute"/>
/// <seealso cref="DependencyAttribute"/>
/// <seealso cref="ResourcesAssetResolver"/>
/// <seealso cref="UIComponentDebugLogger"/>
/// <seealso cref="DebugLogger"/>
[Dependency(typeof(IAssetResolver), provide: typeof(ResourcesAssetResolver))]
[Dependency(typeof(IUIComponentLogger), provide: typeof(UIComponentDebugLogger))]
[Dependency(typeof(ILogger), provide: typeof(DebugLogger))]
public abstract class UIComponent : VisualElement
{
/// <summary>
Expand All @@ -42,10 +42,10 @@ public abstract class UIComponent : VisualElement
public Task<UIComponent> InitializationTask => _initCompletionSource.Task;

/// <summary>
/// The IUIComponentLogger used by this UIComponent.
/// Defaults to <see cref="UIComponentDebugLogger"/>.
/// The logger used by this UIComponent.
/// Defaults to <see cref="DebugLogger"/>.
/// </summary>
protected readonly IUIComponentLogger Logger;
protected readonly ILogger Logger;

private readonly DependencyInjector _dependencyInjector;

Expand All @@ -70,7 +70,7 @@ protected UIComponent()

_dependencyInjector = DiContext.Current.GetInjector(_componentType);
AssetResolver = Provide<IAssetResolver>();
Logger = Provide<IUIComponentLogger>();
Logger = Provide<ILogger>();
UIC_PopulateProvideFields();

DependencySetupProfilerMarker.End();
Expand Down Expand Up @@ -179,15 +179,6 @@ public IEnumerator WaitForInitializationEnumerator()
yield return _initCompletionSource.Task.AsEnumerator();
}

/// <summary>
/// Returns the component's type's name.
/// </summary>
/// <returns>Type name</returns>
public string GetTypeName()
{
return _componentType.Name;
}

/// <summary>
/// Returns a dependency. Throws a <see cref="MissingProviderException"/>
/// if the dependency can not be provided.
Expand Down
2 changes: 1 addition & 1 deletion Assets/UIComponents/Testing/TestBed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task<TComponent> CreateComponentAsync<TComponent>(Func<TComponent>
var task = await Task.WhenAny(initTask, timeoutTask);

if (task == timeoutTask)
throw new TestBedTimeoutException(component.GetTypeName(), (int) AsyncTimeout.TotalMilliseconds);
throw new TestBedTimeoutException(component.GetType().Name, (int) AsyncTimeout.TotalMilliseconds);

var initializedComponent = await initTask;

Expand Down

0 comments on commit 1f7343a

Please sign in to comment.