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"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks> <TargetFrameworks>net462;net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<PackageId>UserManager.Domain</PackageId> <PackageId>UserManager.Domain</PackageId>
@ -13,11 +13,38 @@
<Copyright>Copyright 2024</Copyright> <Copyright>Copyright 2024</Copyright>
<PackageIcon>icon.png</PackageIcon> <PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>http://git.dd:3000/AppStd/WebUserManager.git</RepositoryUrl> <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> <AssemblyVersion>3.1.0</AssemblyVersion>
<FileVersion>3.1.0</FileVersion> <FileVersion>3.1.0</FileVersion>
</PropertyGroup> </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> <ItemGroup>
<None Include="..\Assets\icon.png"> <None Include="..\Assets\icon.png">
<Pack>True</Pack> <Pack>True</Pack>

View File

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

View File

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

View File

@ -8,7 +8,11 @@ namespace DigitalData.UserManager.Domain.Entities
public class Group : BaseEntity public class Group : BaseEntity
{ {
[StringLength(50)] [StringLength(50)]
public string? Name { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Name { get; set; }
[Required] [Required]
[DefaultValue(false)] [DefaultValue(false)]
@ -24,12 +28,17 @@ namespace DigitalData.UserManager.Domain.Entities
public bool Active { get; set; } public bool Active { get; set; }
[StringLength(200)] [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 // TODO: this column should be assigned by triggers. despite this it is not null and this is problem for creation. talk with others
[Required] [Required]
[Column("ECM_FK_ID")] [Column("ECM_FK_ID")]
[DefaultValue(-1)] [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; } public int GroupId { get; set; }
[StringLength(200)] [StringLength(200)]
public string? Comment { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Comment { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual User? User { get; set; } public virtual User
#if NET6_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("GroupId")] [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; } public int Id { get; set; }
[StringLength(50)] [StringLength(50)]
public string? Name { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Name { get; set; }
[StringLength(20)] [StringLength(20)]
[Column("SHORT_NAME")] [Column("SHORT_NAME")]
public string? ShortName { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
ShortName { get; set; }
#region IGNORED COLUMNS #region IGNORED COLUMNS
//[Required] //[Required]

View File

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

View File

@ -2,75 +2,101 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; 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")] [Table("TBDD_USER", Schema = "dbo")]
[StringLength(50)] public class User : BaseEntity
public string? Prename { get; set; } {
[Column("PRENAME")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
?
#endif
Prename { get; set; }
[Column("NAME")] [Column("NAME")]
[StringLength(50)] [StringLength(50)]
public string? Name { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Name { get; set; }
[Required] [Required]
[Column("USERNAME")] [Column("USERNAME")]
[StringLength(50)] [StringLength(50)]
public string Username { get; set; } public string Username { get; set; }
[Column("SHORTNAME")] [Column("SHORTNAME")]
[StringLength(30)] [StringLength(30)]
public string? Shortname { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Shortname
{ get; set; }
[Column("EMAIL")] [Column("EMAIL")]
[StringLength(100)] [StringLength(100)]
public string? Email { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Email { get; set; }
[Required] [Required]
[Column("LANGUAGE")] [Column("LANGUAGE")]
[StringLength(5)] [StringLength(5)]
[DefaultValue("de-DE")] [DefaultValue("de-DE")]
public string Language { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Language { get; set; }
[Column("COMMENT")] [Column("COMMENT")]
[StringLength(500)] [StringLength(500)]
public string? Comment { get; set; } public string
#if NET6_0_OR_GREATER
?
#endif
Comment { get; set; }
[Column("DELETED")] [Column("DELETED")]
public bool Deleted { get; set; } public bool Deleted { get; set; }
[Required] [Required]
[Column("DATE_FORMAT")] [Column("DATE_FORMAT")]
[StringLength(10)] [StringLength(10)]
[DefaultValue("dd.MM.yyyy")] [DefaultValue("dd.MM.yyyy")]
public string DateFormat { get; set; } public string DateFormat { get; set; }
[Required] [Required]
[Column("ACTIVE")] [Column("ACTIVE")]
public bool Active { get; set; } public bool Active { get; set; }
#region IGNORED COLUMNS #region IGNORED COLUMNS
//[Required] //[Required]
//[Column("GENERAL_VIEWER")] //[Column("GENERAL_VIEWER")]
//[StringLength(30)] //[StringLength(30)]
//[DefaultValue("NONE")] //[DefaultValue("NONE")]
//public string GeneralViewer { get; set; } //public string GeneralViewer { get; set; }
//[Required] //[Required]
//[Column("WAN_ENVIRONMENT")] //[Column("WAN_ENVIRONMENT")]
//public bool WanEnvironment { get; set; } //public bool WanEnvironment { get; set; }
//[Required] //[Required]
//[Column("USERID_FK_INT_ECM")] //[Column("USERID_FK_INT_ECM")]
//public int UseridFkIntEcm { get; set; } //public int UseridFkIntEcm { get; set; }
//[Column("DELETED_WHEN")] //[Column("DELETED_WHEN")]
//public DateTime? DeletedWhen { get; set; } //public DateTime? DeletedWhen { get; set; }
//[Column("DELETED_WHO")] //[Column("DELETED_WHO")]
//[StringLength(50)] //[StringLength(50)]
//public string? DeletedWho { get; set; } //public string? DeletedWho { get; set; }
#endregion #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 namespace DigitalData.UserManager.Domain.Entities
{ {
@ -25,15 +27,31 @@ namespace DigitalData.UserManager.Domain.Entities
public DateTime? ValidTo { get; set; } public DateTime? ValidTo { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual User? User { get; set; } public virtual User
#if NET6_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("RepGroupId")] [ForeignKey("RepGroupId")]
public virtual Group? RepGroup { get; set; } public virtual Group
#if NET6_0_OR_GREATER
?
#endif
RepGroup { get; set; }
[ForeignKey("GroupId")] [ForeignKey("GroupId")]
public virtual Group? Group { get; set; } public virtual Group
#if NET6_0_OR_GREATER
?
#endif
Group { get; set; }
[ForeignKey("RepUserId")] [ForeignKey("RepUserId")]
public virtual User? RepUser { get; set; } public virtual User
#if NET6_0_OR_GREATER
?
#endif
RepUser { get; set; }
} }
} }