add PropertyObject & PropertyValue, move to Pilz, make everything .net 8 only

This commit is contained in:
Pilzinsel64
2025-04-02 07:25:41 +02:00
parent 91e1987d75
commit 9a17cd4e9e
27 changed files with 136 additions and 30 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<StartupObject />
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<MyType>Windows</MyType>
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<DocumentationFile>Pilz.Drawing.xml</DocumentationFile>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@@ -1,5 +1,5 @@
using Pilz.Net.Api.Messages;
using Pilz.Net.Data;
using Pilz.Data;
using Pilz.Net.Api.Messages;
namespace Pilz.Net.Api.Client;

View File

@@ -1,5 +1,5 @@
using Pilz.Net.Api.Messages;
using Pilz.Net.Data;
using Pilz.Data;
using Pilz.Net.Api.Messages;
namespace Pilz.Net.Api.Client;

View File

@@ -1,5 +1,5 @@
using Pilz.Net.Api.Messages;
using Pilz.Net.Data;
using Pilz.Data;
using Pilz.Net.Api.Messages;
namespace Pilz.Net.Api.Client;

View File

@@ -1,4 +1,4 @@
using Pilz.Net.Data;
using Pilz.Data;
namespace Pilz.Net.Api.Client;

View File

@@ -1,4 +1,4 @@
using Pilz.Net.Data;
using Pilz.Data;
namespace Pilz.Net.Api.Client;

View File

@@ -1,4 +1,4 @@
using Pilz.Net.Data;
using Pilz.Data;
namespace Pilz.Net.Api.Client;

View File

@@ -1,5 +1,5 @@
using Pilz.Extensions.Reflection;
using Pilz.Net.Data;
using Pilz.Data;
using Pilz.Extensions.Reflection;
using Pilz.Net.Extensions;
using System.Diagnostics;

View File

@@ -1,5 +1,5 @@
using Pilz.Extensions.Reflection;
using Pilz.Net.Data;
using Pilz.Data;
using Pilz.Extensions.Reflection;
using Pilz.Net.Extensions;
using System.Diagnostics;

View File

@@ -1,5 +1,5 @@
using Pilz.Extensions.Reflection;
using Pilz.Net.Data;
using Pilz.Data;
using Pilz.Extensions.Reflection;
using Pilz.Net.Extensions;
using System.Diagnostics;

View File

@@ -18,6 +18,11 @@
<ItemGroup>
<ProjectReference Include="..\Pilz.Extensions\Pilz.Extensions.csproj" />
<ProjectReference Include="..\Pilz\Pilz.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>
</Project>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<MyType>Windows</MyType>
<TargetFrameworks>net6.0-windows;net8.0-windows;netframework4.8</TargetFrameworks>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<DocumentationFile>Pilz.Threading.xml</DocumentationFile>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>annotations</Nullable>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<MyType>Windows</MyType>
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion>
<DocumentationFile>Pilz.UI.xml</DocumentationFile>
<UseWindowsForms>true</UseWindowsForms>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion>
<UseWindowsForms>true</UseWindowsForms>
<Version>2.1.1</Version>

View File

@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;
namespace Pilz.Net.Data;
namespace Pilz.Data;
public abstract class DataManager : IDataManager
{

View File

@@ -1,4 +1,4 @@
namespace Pilz.Net.Data;
namespace Pilz.Data;
public class DataManagerEventArgs(IDataManager manager) : EventArgs
{

View File

@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;
namespace Pilz.Net.Data;
namespace Pilz.Data;
public interface IDataManager
{

View File

@@ -1,4 +1,4 @@
namespace Pilz.Net.Data;
namespace Pilz.Data;
public interface IDataObject
{

View File

@@ -0,0 +1,47 @@
namespace Pilz.Data;
#pragma warning disable CA2231
[Serializable]
public struct PropertyObject<T>(T value) where T : class
{
private readonly bool hasValue = true; // Do not rename (binary serialization)
internal T? value = value; // Do not rename (binary serialization) or make readonly (can be mutated in ToString, etc.)
public static PropertyObject<T> Empty => default;
public readonly bool HasValue
{
get => hasValue;
}
public readonly T? Value
{
get
{
if (!hasValue)
throw new InvalidOperationException("No value");
return value;
}
}
public readonly T? GetValueOrDefault() => value;
public readonly T? GetValueOrDefault(T defaultValue) =>
hasValue ? value : defaultValue;
public override readonly bool Equals(object? other)
{
if (!hasValue || value is null) return other == null;
if (other == null) return false;
return value.Equals(other);
}
public override readonly int GetHashCode() => hasValue && value is not null ? value.GetHashCode() : 0;
public override readonly string? ToString() => hasValue && value is not null ? value.ToString() : string.Empty;
public static implicit operator PropertyObject<T>(T value) => new(value);
public static explicit operator T?(PropertyObject<T> value) => value.Value;
}

View File

@@ -0,0 +1,54 @@
using Newtonsoft.Json;
namespace Pilz.Data;
#pragma warning disable CA2231
[Serializable]
public struct PropertyValue<T>(T value) where T : struct
{
[JsonProperty(PropertyName = "HasValue")]
private readonly bool hasValue = true; // Do not rename (binary serialization)
[JsonProperty(PropertyName = "Value")]
internal T value = value; // Do not rename (binary serialization) or make readonly (can be mutated in ToString, etc.)
[JsonIgnore]
public static PropertyValue<T> Empty => default;
[JsonIgnore]
public readonly bool HasValue
{
get => hasValue;
}
[JsonIgnore]
public readonly T Value
{
get
{
if (!hasValue)
throw new InvalidOperationException("No value");
return value;
}
}
public readonly T GetValueOrDefault() => value;
public readonly T GetValueOrDefault(T defaultValue) =>
hasValue ? value : defaultValue;
public override readonly bool Equals(object? other)
{
if (!hasValue) return other == null;
if (other == null) return false;
return value.Equals(other);
}
public override readonly int GetHashCode() => hasValue ? value.GetHashCode() : 0;
public override readonly string? ToString() => hasValue ? value.ToString() : string.Empty;
public static implicit operator PropertyValue<T>(T value) => new(value);
public static explicit operator T(PropertyValue<T> value) => value.Value;
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>annotations</Nullable>