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

IAssetType static abstract instance fix #451

Merged
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
2 changes: 1 addition & 1 deletion Mutagen.Bethesda.Core/Assets/IAssetType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Mutagen.Bethesda.Assets;
public interface IAssetType
{
#if NET7_0_OR_GREATER
static abstract IAssetType Instance { get; }
static virtual IAssetType Instance => null!;
#endif

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Mutagen.Bethesda.Skyrim/Assets/SkyrimBehaviorAssetType.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mutagen.Bethesda.Assets;
namespace Mutagen.Bethesda.Skyrim.Assets;

public class SkyrimBehaviorAssetType : SkyrimModelAssetType
public class SkyrimBehaviorAssetType : IAssetType
{
#if NET7_0_OR_GREATER
public static IAssetType Instance { get; } = new SkyrimBehaviorAssetType();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mutagen.Bethesda.Assets;
namespace Mutagen.Bethesda.Skyrim.Assets;

public class SkyrimBodyTextureAssetType : SkyrimModelAssetType
public class SkyrimBodyTextureAssetType : IAssetType
{
#if NET7_0_OR_GREATER
public static IAssetType Instance { get; } = new SkyrimBodyTextureAssetType();
Expand Down
44 changes: 44 additions & 0 deletions Mutagen.Bethesda.UnitTests/Skyrim/Assets/AssetTypeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using FluentAssertions;
using Mutagen.Bethesda.Assets;
using Noggog;
using Xunit;

namespace Mutagen.Bethesda.UnitTests.Skyrim.Assets;

public class AssetTypeTests
{
#if NET7_0_OR_GREATER
public IAssetType GetInstance<TAssetType>()
where TAssetType : class, IAssetType
{
return TAssetType.Instance;
}

[Fact]
public void TestAllImplementationsAreNotNull()
{
var methodInfo = typeof(AssetTypeTests).GetMethod("GetInstance");

foreach (var implementation in typeof(IAssetType).GetInheritingFromInterface())
{
var method = methodInfo?.MakeGenericMethod(implementation);

var instance = method?.Invoke(this, null);

instance.Should().NotBeNull();
}

}

[Fact]
public void TestAllImplementationsHaveNoBaseClass()
{
var objectType = typeof(object);

foreach (var implementation in typeof(IAssetType).GetInheritingFromInterface())
{
implementation.BaseType.Should().Be(objectType);
}
}
#endif
}