Skip to content

Commit

Permalink
feat: make most classes sealed
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The following classes are now sealed: AssetPathAttribute, Dependency, DependencyAttribute, DependencyInjector, DiContainer, DiContext, LayoutAttribute, MissingProviderException, ProvideAttribute, QueryAttribute, RootClassAttribute, StylesheetAttribute, TestBed, TestBedBuilder, TestBedTimeoutException.
  • Loading branch information
jonisavo committed Sep 18, 2022
1 parent da16ee4 commit c4ff845
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Assets/UIComponents/Core/AssetPathAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace UIComponents
/// </example>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof(UIComponent))]
public class AssetPathAttribute : Attribute
public sealed class AssetPathAttribute : Attribute
{
public readonly string Path;

Expand All @@ -40,4 +40,4 @@ public AssetPathAttribute(string path)
Path = path;
}
}
}
}
4 changes: 2 additions & 2 deletions Assets/UIComponents/Core/DependencyInjection/Dependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace UIComponents.DependencyInjection
/// <summary>
/// An internal class for provided dependencies.
/// </summary>
internal class Dependency
internal sealed class Dependency
{
/// <summary>
/// The instance of the dependency which is provided to consumers.
Expand Down Expand Up @@ -88,4 +88,4 @@ public void Clear()
Instance = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace UIComponents
/// </summary>
/// <seealso cref="UIComponent"/>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class DependencyAttribute : Attribute
public sealed class DependencyAttribute : Attribute
{
public readonly Type DependencyType;

Expand All @@ -22,4 +22,4 @@ public DependencyAttribute(Type dependency, Type provide, Scope scope = Scope.Si
Scope = scope;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace UIComponents.DependencyInjection
/// </summary>
/// <seealso cref="UIComponent"/>
/// <seealso cref="DependencyAttribute"/>
public class DependencyInjector
public sealed class DependencyInjector
{
private readonly DiContainer _container;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace UIComponents.DependencyInjection
/// <summary>
/// A class for storing injectors and singleton instances.
/// </summary>
public class DiContainer
public sealed class DiContainer
{
/// <summary>
/// Contains all injectors created for consumers.
Expand Down
4 changes: 2 additions & 2 deletions Assets/UIComponents/Core/DependencyInjection/DiContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace UIComponents.DependencyInjection
/// <summary>
/// Dependency injection context for consumers.
/// </summary>
public class DiContext
public sealed class DiContext
{
/// <summary>
/// The current dependency injection context.
Expand Down Expand Up @@ -138,4 +138,4 @@ public void RemoveInjector(Type consumerType)
Container.RemoveInjector(consumerType);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace UIComponents
/// <summary>
/// Thrown when a dependency does not have a provider.
/// </summary>
public class MissingProviderException : Exception
public sealed class MissingProviderException : Exception
{
/// <summary>
/// The dependency type.
Expand All @@ -20,4 +20,4 @@ public MissingProviderException(Type dependencyType)

public override string Message { get; }
}
}
}
4 changes: 2 additions & 2 deletions Assets/UIComponents/Core/LayoutAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace UIComponents
/// <seealso cref="AssetPathAttribute"/>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
[BaseTypeRequired(typeof(UIComponent))]
public class LayoutAttribute : PathAttribute
public sealed class LayoutAttribute : PathAttribute
{
public LayoutAttribute(string path)
{
Path = path;
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/UIComponents/Core/ProvideAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace UIComponents
/// <seealso cref="DependencyAttribute"/>
[AttributeUsage(AttributeTargets.Field)]
[MeansImplicitUse]
public class ProvideAttribute : Attribute
public sealed class ProvideAttribute : Attribute
{
/// <summary>
/// If set, an instance of the specified type will be provided and
Expand Down
2 changes: 1 addition & 1 deletion Assets/UIComponents/Core/QueryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace UIComponents
/// </example>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
[MeansImplicitUse]
public class QueryAttribute : Attribute
public sealed class QueryAttribute : Attribute
{
/// <summary>
/// USS name to query by.
Expand Down
2 changes: 1 addition & 1 deletion Assets/UIComponents/Core/RootClassAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace UIComponents
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof(UIComponent))]
public class RootClassAttribute : UIComponentEffectAttribute
public sealed class RootClassAttribute : UIComponentEffectAttribute
{
private readonly string _className;

Expand Down
4 changes: 2 additions & 2 deletions Assets/UIComponents/Core/StylesheetAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace UIComponents
/// <seealso cref="AssetPathAttribute"/>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof(UIComponent))]
public class StylesheetAttribute : PathAttribute
public sealed class StylesheetAttribute : PathAttribute
{
public StylesheetAttribute(string path)
{
Path = path;
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/UIComponents/Testing/TestBed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace UIComponents.Testing
/// <para/>
/// You can initialize an instance with <see cref="Create"/>.
/// </summary>
public class TestBed
public sealed class TestBed
{
/// <summary>
/// Timeout for async operations. Defaults to eight seconds.
Expand Down
2 changes: 1 addition & 1 deletion Assets/UIComponents/Testing/TestBedBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace UIComponents.Testing
/// <summary>
/// A class for configuring a <see cref="TestBed"/> instance with dependencies.
/// </summary>
public class TestBedBuilder
public sealed class TestBedBuilder
{
private readonly TestBed _testBed;

Expand Down
2 changes: 1 addition & 1 deletion Assets/UIComponents/Testing/TestBedTimeoutException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace UIComponents.Testing
/// <summary>
/// Thrown when an asynchronous TestBed operation times out.
/// </summary>
public class TestBedTimeoutException : Exception
public sealed class TestBedTimeoutException : Exception
{
public override string Message { get; }

Expand Down

0 comments on commit c4ff845

Please sign in to comment.