From 44681cfc9bfc4d274b6fb8f6e30cc6d737ea73d1 Mon Sep 17 00:00:00 2001 From: "David G. Moore, Jr." Date: Wed, 27 Dec 2023 03:33:07 -0500 Subject: [PATCH] Zu vielen Changes! --- Samples/LICENSE.md | 6 +++--- samples/Fuck.cs | 2 +- samples/YesNoIdc.cs | 2 +- src/Dgmjr.Enumerations.CodeGenerator.csproj | 2 +- src/LICENSE.md | 6 +++--- src/Resources/Enumeration.scriban | 6 +++--- .../GenerateEnumerationTypeAttributeDeclarations.cs | 8 ++++---- src/Resources/Header.scriban | 4 +--- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Samples/LICENSE.md b/Samples/LICENSE.md index 2b5eaac..4f60874 100755 --- a/Samples/LICENSE.md +++ b/Samples/LICENSE.md @@ -1,5 +1,5 @@ --- -date: 2023-07-13T05:44:46.048Z +date: 2023-07-13T05:44:46:00.048Z description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, yadda, yadda, yadda... keywords: - IP @@ -13,10 +13,10 @@ permissions: - private-use conditions: - include-copyright -liimitations: +limitations: - liability - warranty -lastmod: 2023-08-29T17:13:51.216Z +lastmod: 2023-08-29T17:13:51:00.216Z license: MIT slug: mit-license title: MIT License diff --git a/samples/Fuck.cs b/samples/Fuck.cs index e7bee01..a186e23 100644 --- a/samples/Fuck.cs +++ b/samples/Fuck.cs @@ -15,7 +15,7 @@ public partial record class Baz /// This is an enumeration demonstration /// This should show up as an XML comment for the enumeration class too! -[GenerateEnumerationRecordClass("Fuck")] +[GenerateEnumerationRecordClass("Fuck", baseType: typeof(Baz))] public enum FuckEnum { [Display(Name = "Baz", Description = "This is the first value")] diff --git a/samples/YesNoIdc.cs b/samples/YesNoIdc.cs index a765310..bee46f6 100644 --- a/samples/YesNoIdc.cs +++ b/samples/YesNoIdc.cs @@ -49,7 +49,7 @@ public enum YesNoEnum public partial record class YesNo { // public YesNo() : this((YesNoEnum)No.Id) { } - public static implicit operator YesNo(YesNoEnum value) => FromValue(value) as YesNo; + public static implicit operator YesNo?(YesNoEnum value) => FromValue(value) as YesNo; // public static implicit operator YesNo(YesNoIdc yesNoIdc) => yesNoIdc. } diff --git a/src/Dgmjr.Enumerations.CodeGenerator.csproj b/src/Dgmjr.Enumerations.CodeGenerator.csproj index ec53a96..1aed6cf 100644 --- a/src/Dgmjr.Enumerations.CodeGenerator.csproj +++ b/src/Dgmjr.Enumerations.CodeGenerator.csproj @@ -30,12 +30,12 @@ - + diff --git a/src/LICENSE.md b/src/LICENSE.md index 2b5eaac..4f60874 100755 --- a/src/LICENSE.md +++ b/src/LICENSE.md @@ -1,5 +1,5 @@ --- -date: 2023-07-13T05:44:46.048Z +date: 2023-07-13T05:44:46:00.048Z description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, yadda, yadda, yadda... keywords: - IP @@ -13,10 +13,10 @@ permissions: - private-use conditions: - include-copyright -liimitations: +limitations: - liability - warranty -lastmod: 2023-08-29T17:13:51.216Z +lastmod: 2023-08-29T17:13:51:00.216Z license: MIT slug: mit-license title: MIT License diff --git a/src/Resources/Enumeration.scriban b/src/Resources/Enumeration.scriban index b5151f7..3a4d157 100644 --- a/src/Resources/Enumeration.scriban +++ b/src/Resources/Enumeration.scriban @@ -24,14 +24,14 @@ public {{ if base_type == "" || base_type == null }} static {{ end }} partial { /// Parses the to an object of type . /// if no matching item was found public static I{{ dto_type_name }} Parse(string value) - => Parse(e => e.Name == value || e.DisplayName == value || e.GuidString == value || e.UriString == value || e.ShortName == value); + => Parse(e => e.Name == value || e.DisplayName == value || e.GuidString == value || e.UriString == value || e.ShortName == value)!; /// Uses the predicate the to find an object of type . /// if no matching item was found - public static I{{ dto_type_name }} Parse(Func matchPredicate) + public static I{{ dto_type_name }}? Parse(Func matchPredicate) => Parse(matchPredicate, true); - private static I{{ dto_type_name }} Parse(Func matchPredicate, bool throwOnNotFound) + private static I{{ dto_type_name }}? Parse(Func matchPredicate, bool throwOnNotFound = true) => GetAll().Where(matchPredicate).SingleOrDefault() ?? (!throwOnNotFound ? default : throw new InvalidCastException($"There was no matching {{ dto_type_name }} found.")); diff --git a/src/Resources/GenerateEnumerationTypeAttributeDeclarations.cs b/src/Resources/GenerateEnumerationTypeAttributeDeclarations.cs index 376c03d..bc4a626 100644 --- a/src/Resources/GenerateEnumerationTypeAttributeDeclarations.cs +++ b/src/Resources/GenerateEnumerationTypeAttributeDeclarations.cs @@ -35,18 +35,18 @@ internal sealed class GenerateEnumerationStructAttribute( internal sealed class GenerateEnumerationRecordClassAttribute( string? typeName = default, string? @namespace = default, - type? baseType = default + Type? baseType = default ) : GenerateEnumerationTypeAttribute(typeName, @namespace) { - public type? BaseType { get; } = baseType; + public Type? BaseType { get; } = baseType; } [AttributeUsage(Class | Struct | ATargets.Enum)] internal sealed class GenerateEnumerationClassAttribute( string? typeName = default, string? @namespace = default, - type? baseType = default + Type? baseType = default ) : GenerateEnumerationTypeAttribute(typeName, @namespace) { - public type? BaseType { get; } = baseType; + public Type? BaseType { get; } = baseType; } diff --git a/src/Resources/Header.scriban b/src/Resources/Header.scriban index aa2d412..6672d9f 100644 --- a/src/Resources/Header.scriban +++ b/src/Resources/Header.scriban @@ -22,7 +22,5 @@ using System.Text.RegularExpressions; using System.Text.Json.Serialization; using System.Text.Json; using System.Xml.Serialization; -#if NET7_0_OR_GREATER -using StringSyntax = System.Diagnostics.CodeAnalysis.StringSyntaxAttribute; -#endif +using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute; #nullable enable