Skip to content

Commit 7a9a86d

Browse files
authored
Enable C#12 (#657)
+semver:minor
1 parent 3e4405c commit 7a9a86d

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<IncludeSymbols>true</IncludeSymbols>
1616
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1717
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
18-
<LangVersion>10</LangVersion>
18+
<LangVersion>12</LangVersion>
1919
<NoWarn>$(NoWarn);1591</NoWarn>
2020
</PropertyGroup>
2121

@@ -31,5 +31,6 @@
3131

3232
<ItemGroup>
3333
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
34+
<PackageReference Include="Polyfill" Version="3.0.0" PrivateAssets="All"/>
3435
</ItemGroup>
3536
</Project>

src/FluentNHibernate/Automapping/Steps/PropertyStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static TypeReference GetDefaultType(Member property)
117117
if (property.PropertyType.IsEnum())
118118
type = new TypeReference(typeof(EnumStringType<>).MakeGenericType(property.PropertyType));
119119

120-
if (property.PropertyType.IsNullable() && property.PropertyType.IsEnum())
120+
if (property.PropertyType.IsNullableType() && property.PropertyType.IsEnum())
121121
type = new TypeReference(typeof(EnumStringType<>).MakeGenericType(property.PropertyType.GetGenericArguments()[0]));
122122

123123
return type;

src/FluentNHibernate/Mapping/PropertyPart.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ PropertyMapping IPropertyMappingProvider.GetPropertyMapping()
324324

325325
foreach (var column in mapping.Columns)
326326
{
327-
if (member.PropertyType.IsNullable() && member.PropertyType.IsEnum())
327+
if (member.PropertyType.IsNullableType() && member.PropertyType.IsEnum())
328328
column.Set(x => x.NotNull, Layer.Defaults, false);
329329

330330
column.MergeAttributes(columnAttributes);
@@ -343,7 +343,7 @@ TypeReference GetDefaultType()
343343
if (member.PropertyType.IsEnum())
344344
type = new TypeReference(typeof(EnumStringType<>).MakeGenericType(member.PropertyType));
345345

346-
if (member.PropertyType.IsNullable() && member.PropertyType.IsEnum())
346+
if (member.PropertyType.IsNullableType() && member.PropertyType.IsEnum())
347347
type = new TypeReference(typeof(EnumStringType<>).MakeGenericType(member.PropertyType.GetGenericArguments()[0]));
348348

349349
return type;

src/FluentNHibernate/Utils/Extensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,19 @@ public static bool ClosesInterface(this Type type, Type openGenericInterface)
3535

3636
public static bool IsEnum(this Type type)
3737
{
38-
if (type.IsNullable())
38+
if (type.IsNullableType())
3939
return type.GetGenericArguments()[0].IsEnum;
4040

4141
return type.IsEnum;
4242
}
4343

44+
[Obsolete("Please use IsNullableType(Type type)")]
4445
public static bool IsNullable(this Type type)
46+
{
47+
return type.IsNullableType();
48+
}
49+
50+
public static bool IsNullableType(this Type type)
4551
{
4652
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
4753
}

0 commit comments

Comments
 (0)