Add .NET Framework 4.6.2 support and improve nullability

Updated `DigitalData.UserManager.Domain.csproj` to target .NET Framework 4.6.2 alongside .NET 7.0, 8.0, and 9.0. Corrected `PackageTags` from "user maanger" to "user manager" and added property groups for implicit usings and language versions.

Introduced nullable reference types in entity classes (`BaseEntity`, `ClientUser`, `Group`, `User`, etc.) for enhanced type safety. Updated properties in the `User` and `UserRep` classes to use the new nullable syntax, ensuring consistency across the codebase.

These changes improve compatibility with newer C# features and maintain support for multiple frameworks.
This commit is contained in:
tekh 2025-06-26 12:27:24 +02:00
parent 40deb9968f
commit b1075c8b82
9 changed files with 230 additions and 85 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net462;net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>UserManager.Domain</PackageId>
@ -13,11 +13,38 @@
<Copyright>Copyright 2024</Copyright>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>http://git.dd:3000/AppStd/WebUserManager.git</RepositoryUrl>
<PackageTags>digital data domain user maanger</PackageTags>
<PackageTags>digital data domain user manager</PackageTags>
<AssemblyVersion>3.1.0</AssemblyVersion>
<FileVersion>3.1.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<ImplicitUsings>disable</ImplicitUsings>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net462'">
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="System.Drawing.Common" Version="8.0.16" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="System.Drawing.Common" Version="9.0.5" />
</ItemGroup>
<ItemGroup>
<None Include="..\Assets\icon.png">
<Pack>True</Pack>

View File

@ -1,6 +1,9 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
#endif
namespace DigitalData.UserManager.Domain.Entities
{
@ -13,11 +16,21 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(50)]
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
AddedWho
{ get; set; }
[StringLength(50)]
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
ChangedWho
{ get; set; }
//TODO: assign it to default value in create dto, not here!
[Column("ADDED_WHEN", TypeName = "datetime")]

View File

@ -1,6 +1,9 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
#endif
namespace DigitalData.UserManager.Domain.Entities
{
@ -14,18 +17,28 @@ namespace DigitalData.UserManager.Domain.Entities
[Required]
[Column("USER_ID")]
public int UserId { get; init; }
public int UserId { get; set; }
[Required]
[Column("CLIENT_ID")]
public int ClientId { get; init; }
public int ClientId { get; set; }
[Column("COMMENT")]
public string? Comment { get; init; }
public string
#if NET6_0_OR_GREATER
?
#endif
Comment
{ get; set; }
[StringLength(50)]
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
AddedWho
{ get; set; }
[Column("ADDED_WHEN", TypeName = "datetime")]
[DefaultValue("GETDATE()")]

View File

@ -8,7 +8,11 @@ namespace DigitalData.UserManager.Domain.Entities
public class Group : BaseEntity
{
[StringLength(50)]
public string? Name { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Name { get; set; }
[Required]
[DefaultValue(false)]
@ -24,12 +28,17 @@ namespace DigitalData.UserManager.Domain.Entities
public bool Active { get; set; }
[StringLength(200)]
public string? Comment { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Comment
{ get; set; }
// TODO: this column should be assigned by triggers. despite this it is not null and this is problem for creation. talk with others
[Required]
[Column("ECM_FK_ID")]
[DefaultValue(-1)]
public int EcmFkId { get; init; } = -1;
public int EcmFkId { get; set; } = -1;
}
}

View File

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

View File

@ -12,11 +12,19 @@ namespace DigitalData.UserManager.Domain.Entities
public int Id { get; set; }
[StringLength(50)]
public string? Name { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Name { get; set; }
[StringLength(20)]
[Column("SHORT_NAME")]
public string? ShortName { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
ShortName { get; set; }
#region IGNORED COLUMNS
//[Required]

View File

@ -21,21 +21,41 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("COMMENT")]
[StringLength(200)]
public string? Comment { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Comment { get; set; }
[Column("ADDED_WHO")]
[StringLength(50)]
public string? AddedWho { get; set; } = "DEFAULT";
public string
#if NET6_0_OR_GREATER
?
#endif
AddedWho { get; set; } = "DEFAULT";
[Column("CHANGED_WHO")]
[StringLength(50)]
public string? ChangedWho { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
ChangedWho { get; set; }
[ForeignKey("UserId")]
public virtual User? User { get; set; }
public virtual User
#if NET6_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("ModuleId")]
public virtual Module? Module { get; set; }
public virtual Module
#if NET6_0_OR_GREATER
?
#endif
Module { get; set; }
#region IGNORED COLUMNS
//public bool IsAdmin { get; set; }
@ -53,5 +73,4 @@ namespace DigitalData.UserManager.Domain.Entities
//public DateTime? ChangedWhen { get; set; }
#endregion
}
}

View File

@ -2,18 +2,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.UserManager.Domain.Entities;
namespace DigitalData.UserManager.Domain.Entities
{
[Table("TBDD_USER", Schema = "dbo")]
public class User : BaseEntity
{
[Column("PRENAME")]
[StringLength(50)]
public string? Prename { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Prename { get; set; }
[Column("NAME")]
[StringLength(50)]
public string? Name { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Name { get; set; }
[Required]
[Column("USERNAME")]
@ -22,21 +30,38 @@ public class User : BaseEntity
[Column("SHORTNAME")]
[StringLength(30)]
public string? Shortname { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Shortname
{ get; set; }
[Column("EMAIL")]
[StringLength(100)]
public string? Email { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Email { get; set; }
[Required]
[Column("LANGUAGE")]
[StringLength(5)]
[DefaultValue("de-DE")]
public string Language { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Language { get; set; }
[Column("COMMENT")]
[StringLength(500)]
public string? Comment { get; set; }
public string
#if NET6_0_OR_GREATER
?
#endif
Comment { get; set; }
[Column("DELETED")]
public bool Deleted { get; set; }
@ -74,3 +99,4 @@ public class User : BaseEntity
//public string? DeletedWho { get; set; }
#endregion
}
}

View File

@ -1,5 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
#endif
namespace DigitalData.UserManager.Domain.Entities
{
@ -25,15 +27,31 @@ namespace DigitalData.UserManager.Domain.Entities
public DateTime? ValidTo { get; set; }
[ForeignKey("UserId")]
public virtual User? User { get; set; }
public virtual User
#if NET6_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("RepGroupId")]
public virtual Group? RepGroup { get; set; }
public virtual Group
#if NET6_0_OR_GREATER
?
#endif
RepGroup { get; set; }
[ForeignKey("GroupId")]
public virtual Group? Group { get; set; }
public virtual Group
#if NET6_0_OR_GREATER
?
#endif
Group { get; set; }
[ForeignKey("RepUserId")]
public virtual User? RepUser { get; set; }
public virtual User
#if NET6_0_OR_GREATER
?
#endif
RepUser { get; set; }
}
}