Skip to content

Commit

Permalink
fix #465
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghuan committed Jan 4, 2024
1 parent 0424da5 commit 7791b16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CSharp.lua/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public static ITypeSymbol NullableElementType(this ITypeSymbol type) {

public static bool IsNullableWithBasicElementType(this ITypeSymbol type) {
return type.IsNullableType(out var elementType)
&& (elementType.IsBasicType() || type.SpecialType == SpecialType.System_DateTime || type.IsTimeSpanType());
&& (elementType.IsBasicType() || elementType.TypeKind == TypeKind.Enum || type.SpecialType == SpecialType.System_DateTime || type.IsTimeSpanType());
}

public static bool IsEnumType(this ITypeSymbol type, out ITypeSymbol symbol, out bool isNullable) {
Expand Down
3 changes: 3 additions & 0 deletions test/BridgeNetTests/Batch1/src/NullableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ public void GetValueOrDefaultWithArgWorks()
int? a = 3, b = null;
Assert.AreEqual(3, a.GetValueOrDefault(1));
Assert.AreEqual(1, b.GetValueOrDefault(1));

Values? c = null;
Assert.AreEqual(Values.Value1, c.GetValueOrDefault(Values.Value1));
}

[Test]
Expand Down

0 comments on commit 7791b16

Please sign in to comment.