From 8935ec8cb8e1de531a0139eef86dd47738ebec02 Mon Sep 17 00:00:00 2001 From: "David G. Moore, Jr." Date: Wed, 27 Dec 2023 05:16:14 -0500 Subject: [PATCH] sprucing up and making look/work nice --- .vscode/settings.json | 6 ++++- .../Dgmjr.RegexDtoGenerator.Samples.csproj | 8 +++--- Samples/Dgmjr.RegexDtoGenerator.Samples.sln | 26 +++++++++---------- Samples/EmailAddressWithDisplayName.cs | 1 + Samples/RoomBase.cs | 1 + src/Constants.cs | 12 ++++----- src/Dgmjr.RegexDtoGenerator.props | 5 ++++ src/LICENSE.md | 6 ++--- 8 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 src/Dgmjr.RegexDtoGenerator.props diff --git a/.vscode/settings.json b/.vscode/settings.json index a5b385f..6f5f9d5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,9 @@ "BDAY", "ffffzzz", "VCARD" - ] + ], + "sonarlint.connectedMode.project": { + "connectionId": "dgmjr-io", + "projectKey": "dgmjr-io_RegexDtoGenerator" + } } diff --git a/Samples/Dgmjr.RegexDtoGenerator.Samples.csproj b/Samples/Dgmjr.RegexDtoGenerator.Samples.csproj index 608924a..3b41aee 100644 --- a/Samples/Dgmjr.RegexDtoGenerator.Samples.csproj +++ b/Samples/Dgmjr.RegexDtoGenerator.Samples.csproj @@ -12,7 +12,7 @@ - netstandard2.0 + netstandard2.0;net6.0;net8.0 obj/ codegen false @@ -22,9 +22,9 @@ - - - + + + diff --git a/Samples/Dgmjr.RegexDtoGenerator.Samples.sln b/Samples/Dgmjr.RegexDtoGenerator.Samples.sln index 129f4ae..723a402 100644 --- a/Samples/Dgmjr.RegexDtoGenerator.Samples.sln +++ b/Samples/Dgmjr.RegexDtoGenerator.Samples.sln @@ -8,7 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\..\..\..\Packages\Versions.Local.props = ..\..\..\..\Packages\Versions.Local.props EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.RegexDtoGenerator.Samples", "Dgmjr.RegexDtoGenerator.Samples.csproj", "{C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.RegexDtoGenerator.Samples", "Dgmjr.RegexDtoGenerator.Samples.csproj", "{7E71351A-1E5D-423F-A0B9-2E0B2817C58E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -20,18 +20,18 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Local|Any CPU.ActiveCfg = Local|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Local|Any CPU.Build.0 = Local|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Testing|Any CPU.ActiveCfg = Testing|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Testing|Any CPU.Build.0 = Testing|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Staging|Any CPU.ActiveCfg = Staging|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Staging|Any CPU.Build.0 = Staging|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Production|Any CPU.ActiveCfg = Local|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Production|Any CPU.Build.0 = Local|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}.Release|Any CPU.Build.0 = Release|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Local|Any CPU.ActiveCfg = Local|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Local|Any CPU.Build.0 = Local|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Testing|Any CPU.Build.0 = Testing|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Staging|Any CPU.Build.0 = Staging|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Production|Any CPU.ActiveCfg = Local|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Production|Any CPU.Build.0 = Local|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E71351A-1E5D-423F-A0B9-2E0B2817C58E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Samples/EmailAddressWithDisplayName.cs b/Samples/EmailAddressWithDisplayName.cs index 666a4dd..fd598c9 100644 --- a/Samples/EmailAddressWithDisplayName.cs +++ b/Samples/EmailAddressWithDisplayName.cs @@ -12,6 +12,7 @@ namespace Contacts; +/// A DTO with an email address and a display name [RegexDto( @"^(?\w+)?\s*?(?\w+)?\s*?\<(?\w+)@(?((?:\w+\.))(?\w+)))\>$" )] diff --git a/Samples/RoomBase.cs b/Samples/RoomBase.cs index f22d3bc..59c4f8c 100644 --- a/Samples/RoomBase.cs +++ b/Samples/RoomBase.cs @@ -2,5 +2,6 @@ namespace Us.Zoom; public abstract record class RoomBase : IRoom { + [@StringSyntax(StringSyntax.Uri)] public virtual Uri? Url { get; } } diff --git a/src/Constants.cs b/src/Constants.cs index 7472555..1e07548 100644 --- a/src/Constants.cs +++ b/src/Constants.cs @@ -55,9 +55,6 @@ internal static partial class Constants using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; - #if NET7_0_OR_GREATER - using SS = System.Diagnostics.CodeAnalysis.StringSyntaxAttribute; - #endif #nullable enable @@ -71,10 +68,13 @@ internal static partial class Constants {{{GeneratedCodeAttributesList}}} internal sealed class RegexDtoAttribute( #if NET7_0_OR_GREATER - [StringSyntax(SS.Regex)] + [@StringSyntax(StringSyntax.Regex)] #endif string Regex, System.Type? BaseType = null, RegexOptions RegexOptions = Compiled | CultureInvariant | ExplicitCapture | IgnoreCase | IgnorePatternWhitespace | Singleline) : System.Attribute { + public string Regex { get; } = Regex; + public System.Type? BaseType { get; } = BaseType; + public RegexOptions RegexOptions { get; } = RegexOptions; } """"; @@ -89,7 +89,7 @@ namespace {{ namespace_name }} const RegexOptions RegexOptions = (RegexOptions)({{ regex_options | string.replace "," " | " }}); #if NET7_0_OR_GREATER - [StringSyntax(SS.Regex)] + [@StringSyntax(StringSyntax.Regex)] #endif public const string RegexString = @"{{ regex }}"; @@ -122,7 +122,7 @@ namespace {{ namespace_name }} const RegexOptions RegexOptions = (RegexOptions)({{ regex_options | string.replace "," " | " }}); #if NET7_0_OR_GREATER - [StringSyntax(SS.Regex)] + [@StringSyntax(StringSyntax.Regex)] #endif /// The regex string that will be used to validate and recognize the DTO public const string RegexString = @"{{ regex }}"; diff --git a/src/Dgmjr.RegexDtoGenerator.props b/src/Dgmjr.RegexDtoGenerator.props new file mode 100644 index 0000000..a376645 --- /dev/null +++ b/src/Dgmjr.RegexDtoGenerator.props @@ -0,0 +1,5 @@ + + + + + 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