Skip to content
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
10 changes: 5 additions & 5 deletions src/Marten/Schema/Identity/ValueTypeIdGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Threading;
using JasperFx.CodeGeneration;
Expand Down Expand Up @@ -133,6 +134,10 @@ public ISelectClause BuildSelectClause(string tableName)

public static bool IsCandidate(Type idType, [NotNullWhen(true)]out ValueTypeIdGeneration? idGeneration)
{
idGeneration = default;
if (idType == typeof(Type)) return false;
if (idType == typeof(BigInteger)) return false;

if (idType.IsGenericType && idType.IsNullable())
{
idType = idType.GetGenericArguments().Single();
Expand All @@ -144,11 +149,6 @@ public static bool IsCandidate(Type idType, [NotNullWhen(true)]out ValueTypeIdGe
return false;
}

if (!idType.Name.EndsWith("Id"))
{
return false;
}

if (!idType.IsPublic && !idType.IsNestedPublic)
{
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/ValueTypeTests/TestingTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace ValueTypeTests;
[ValueObject<int>]
public readonly partial struct IntId;

[ValueObject<int>]
public readonly partial struct WeirdNamed;

[ValueObject<long>]
public readonly partial struct LongId;

Expand Down
2 changes: 2 additions & 0 deletions src/ValueTypeTests/applicability_of_identity_types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class applicability_of_identity_types
[InlineData(typeof(string), false)]
[InlineData(typeof(GuidId), true)]
[InlineData(typeof(IntId), true)]
[InlineData(typeof(WeirdNamed), true)]
[InlineData(typeof(LongId), true)]
[InlineData(typeof(StringId), true)]
[InlineData(typeof(GuidId?), true)]
Expand Down Expand Up @@ -47,6 +48,7 @@ public void FSharpIdGeneration_IsCandidate(Type candidate, bool isCandidate)
[Theory]
[InlineData(typeof(GuidId), typeof(GuidId), typeof(ValueTypeIdGeneration))]
[InlineData(typeof(IntId), typeof(IntId), typeof(ValueTypeIdGeneration))]
[InlineData(typeof(WeirdNamed), typeof(WeirdNamed), typeof(ValueTypeIdGeneration))]
[InlineData(typeof(LongId), typeof(LongId), typeof(ValueTypeIdGeneration))]
[InlineData(typeof(StringId), typeof(StringId), typeof(ValueTypeIdGeneration))]
[InlineData(typeof(GuidId?), typeof(GuidId), typeof(ValueTypeIdGeneration))]
Expand Down
Loading