Skip to content

Commit

Permalink
Zu vielen Changes!
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmjr committed Dec 27, 2023
1 parent 62c55b3 commit 44681cf
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Samples/LICENSE.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/Fuck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial record class Baz

/// <summary>This is an enumeration demonstration</summary>
/// <remarks>This should show up as an XML comment for the enumeration class too!</remarks>
[GenerateEnumerationRecordClass("Fuck")]
[GenerateEnumerationRecordClass("Fuck", baseType: typeof(Baz))]
public enum FuckEnum
{
[Display(Name = "Baz", Description = "This is the first value")]
Expand Down
2 changes: 1 addition & 1 deletion samples/YesNoIdc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dgmjr.Enumerations.CodeGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.Extensions.Logging." />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Scriban.Signed" Aliases="Scrib" />
<PackageReference Include="ThisAssembly.AssemblyInfo" />
<PackageReference Include="ThisAssembly.Project" />
<PackageReference Include="System.Text.Json.Usings" IncludeAssets="Build;BuildTransitive;BuildMultitargeting;Runtime;Compile" ExcludeAssets="ContentFiles;Native;Analyzers" PrivateAssets="None" />
<PackageReference Include="System.Private.CoreLib.Polyfills" IncludeAssets="ContentFiles;Build;BuildTransitive;BuildMultitargeting" ExcludeAssets="Analyzers;Runtime;Native" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/LICENSE.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Enumeration.scriban
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public {{ if base_type == "" || base_type == null }} static {{ end }} partial {
/// <summary>Parses the <paramref name="value"/> to an object of type <see cref="I{{ dto_type_name }}"/>.</summary>
/// <exception cref="InvalidCastException">if no matching item was found</exception>
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)!;

/// <summary>Uses the predicate the <paramref name="matchPredicate"/> to find an object of type <see cref="I{{ dto_type_name }}"/>.</summary>
/// <exception cref="InvalidCastException">if no matching item was found</exception>
public static I{{ dto_type_name }} Parse(Func<I{{ dto_type_name }}, bool> matchPredicate)
public static I{{ dto_type_name }}? Parse(Func<I{{ dto_type_name }}, bool> matchPredicate)
=> Parse(matchPredicate, true);

private static I{{ dto_type_name }} Parse(Func<I{{ dto_type_name }}, bool> matchPredicate, bool throwOnNotFound)
private static I{{ dto_type_name }}? Parse(Func<I{{ dto_type_name }}, bool> matchPredicate, bool throwOnNotFound = true)
=> GetAll().Where(matchPredicate).SingleOrDefault() ??
(!throwOnNotFound ? default :
throw new InvalidCastException($"There was no matching {{ dto_type_name }} found."));
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/GenerateEnumerationTypeAttributeDeclarations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 1 addition & 3 deletions src/Resources/Header.scriban
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 44681cf

Please sign in to comment.