Update project for multi-targeting and nullable types

Updated `DigitalData.UserManager.Domain.csproj` to support .NET 4.6.2, 7.0, 8.0, and 9.0. Adjusted implicit usings and nullable reference types settings based on the target framework, disabling nullable types for `net462` and enabling them for others.

Refactored entity classes (`BaseEntity`, `ClientUser`, `Group`, `GroupOfUser`, `Module`, `ModuleOfUser`, `User`, and `UserRep`) to conditionally include nullable reference types. Added `?` operator for string properties in .NET 7.0 and above, enhancing code safety and reducing null reference exceptions.
This commit is contained in:
tekh 2025-06-26 13:15:36 +02:00
parent b1075c8b82
commit bc44de63ee
9 changed files with 28 additions and 28 deletions

View File

@ -2,8 +2,6 @@
<PropertyGroup>
<TargetFrameworks>net462;net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>UserManager.Domain</PackageId>
<Version>3.1.0</Version>
<Authors>Digital Data GmbH</Authors>
@ -19,11 +17,13 @@
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net462'">
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
</PropertyGroup>

View File

@ -17,7 +17,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(50)]
[Column("ADDED_WHO")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
AddedWho
@ -26,7 +26,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(50)]
[Column("CHANGED_WHO")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
ChangedWho

View File

@ -25,7 +25,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("COMMENT")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment
@ -34,7 +34,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(50)]
[Column("ADDED_WHO")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
AddedWho

View File

@ -9,7 +9,7 @@ namespace DigitalData.UserManager.Domain.Entities
{
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Name { get; set; }
@ -29,7 +29,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(200)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment

View File

@ -16,21 +16,21 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(200)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment { get; set; }
[ForeignKey("UserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("GroupId")]
public virtual Group
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Group { get; set; }

View File

@ -13,7 +13,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Name { get; set; }
@ -21,7 +21,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(20)]
[Column("SHORT_NAME")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
ShortName { get; set; }

View File

@ -22,7 +22,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("COMMENT")]
[StringLength(200)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment { get; set; }
@ -30,7 +30,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("ADDED_WHO")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
AddedWho { get; set; } = "DEFAULT";
@ -38,21 +38,21 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("CHANGED_WHO")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
ChangedWho { get; set; }
[ForeignKey("UserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("ModuleId")]
public virtual Module
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Module { get; set; }

View File

@ -10,7 +10,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("PRENAME")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Prename { get; set; }
@ -18,7 +18,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("NAME")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Name { get; set; }
@ -31,7 +31,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("SHORTNAME")]
[StringLength(30)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Shortname
@ -40,7 +40,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("EMAIL")]
[StringLength(100)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Email { get; set; }
@ -50,7 +50,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(5)]
[DefaultValue("de-DE")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Language { get; set; }
@ -58,7 +58,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("COMMENT")]
[StringLength(500)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment { get; set; }

View File

@ -28,28 +28,28 @@ namespace DigitalData.UserManager.Domain.Entities
[ForeignKey("UserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("RepGroupId")]
public virtual Group
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
RepGroup { get; set; }
[ForeignKey("GroupId")]
public virtual Group
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Group { get; set; }
[ForeignKey("RepUserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
RepUser { get; set; }