Skip to content

Commit 87fa129

Browse files
committed
Move to correct class
1 parent 3289722 commit 87fa129

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/DynamoDBGenerator.SourceGenerator/Extensions/NotNullEvaluationExtensions.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@ public static string NotNullTernaryExpression(this ITypeSymbol typeSymbol, in st
1313
return $"({result})";
1414
}
1515

16-
public static bool IsNullable(this ITypeSymbol typeSymbol)
17-
{
18-
return typeSymbol switch
19-
{
20-
{ IsReferenceType: true, NullableAnnotation: NullableAnnotation.None or NullableAnnotation.Annotated } => true,
21-
{ IsReferenceType: true, NullableAnnotation: NullableAnnotation.NotAnnotated } => false,
22-
{ IsValueType: true, OriginalDefinition.SpecialType: SpecialType.System_Nullable_T } => true,
23-
{ IsValueType: true } => false,
24-
_ => throw new ArgumentOutOfRangeException($"Could not determine nullablity of type '{typeSymbol.ToDisplayString()}'.")
25-
};
26-
}
27-
28-
2916
private static string CreateException(in string accessPattern)
3017
{
3118
return $"throw {Constants.DynamoDBGenerator.ExceptionHelper.NullExceptionMethod}(nameof({accessPattern}));";

src/DynamoDBGenerator.SourceGenerator/Extensions/TypeExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ public static Func<ITypeSymbol, T> CacheFactory<T>(IEqualityComparer<ISymbol> co
1818

1919
private static readonly Dictionary<ITypeSymbol, TypeIdentifier> TypeIdentifierDictionary =
2020
new(SymbolEqualityComparer.IncludeNullability);
21+
22+
public static bool IsNullable(this ITypeSymbol typeSymbol)
23+
{
24+
return typeSymbol switch
25+
{
26+
{ IsReferenceType: true, NullableAnnotation: NullableAnnotation.None or NullableAnnotation.Annotated } => true,
27+
{ IsReferenceType: true, NullableAnnotation: NullableAnnotation.NotAnnotated } => false,
28+
{ IsValueType: true, OriginalDefinition.SpecialType: SpecialType.System_Nullable_T } => true,
29+
{ IsValueType: true } => false,
30+
_ => throw new ArgumentOutOfRangeException($"Could not determine nullablity of type '{typeSymbol.ToDisplayString()}'.")
31+
};
32+
}
2133

2234
public static TypeIdentifier TypeIdentifier(this ITypeSymbol type)
2335
{

0 commit comments

Comments
 (0)