Skip to content

Commit

Permalink
UPDATED: RegexDtoGenerator Changes
Browse files Browse the repository at this point in the history
- Updated Dgmjr.RegexDtoGenerator.csproj: Updated PackageReference for Dgmjr.RegexDtoGenerator SourceCodePackageReference for System Dgmjr.RegexDto to Dgmjr.RegexOptions parameter.

- Updated USPostalAddresssexDtoGenerator.
  -jr.RegexGenerator.

 Updated RegexDtoTypeDeclarationModel.cs:
  - Updated regexOptions property type to RegexOptions.

- Updated RegexDtoGenerator to RegexOptions.
  - Updated return type for Regex() method to Regex.
  - Updated _regex field type to Regex.
  • Loading branch information
dgmjr committed Nov 23, 2023
1 parent 59fa55c commit e8df7ee
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Samples/Dgmjr.RegexDtoGenerator.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<PackageReference Include="System.Threading.Tasks.Extensions" VersionOverride="[4.5.4,)" />
<PackageReference Include="System.Text.Json" />
<!-- <ProjectReference Include="../src/Dgmjr.RegexDtoGenerator.csproj" Targets="Restore;Build;Pack" ReferenceOutputAssembly="true" OutputItemType="Analyzer" IncludeAssets="build; analyzers" ExcludeAssets="ContentFiles; Lib; Source; Native;" PrivateAssets="all" VersionOverride="0.0.1-Local" /> -->
<SourceGeneratorPackageReference Include="Dgmjr.RegexDtoGenerator" />
<SourceCodePackageReference Include="System.Private.CoreLib.Polyfills" />
<PackageReference Include="Dgmjr.RegexDtoGenerator" IncludeAssets="Analyzers;Build" ExcludeAssets="Native;BuildTransitive;BuildMultitargeting;ContentFiles;Compile;Runtime" PrivateAssets="All" />
<SourceCode Include="System.Private.CoreLib.Polyfills" />
</ItemGroup>
<Target Name="Clean">
<RemoveDir Directories="$(BaseIntermediateOutputPath);$(IntermediateOutputPath)" />
Expand Down
26 changes: 13 additions & 13 deletions Samples/Dgmjr.RegexDtoGenerator.Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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", "{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.RegexDtoGenerator.Samples", "Dgmjr.RegexDtoGenerator.Samples.csproj", "{C135F894-58C1-41DC-8FC4-FEB2A6B0D9A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -20,18 +20,18 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Local|Any CPU.ActiveCfg = Local|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Local|Any CPU.Build.0 = Local|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Testing|Any CPU.Build.0 = Testing|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Staging|Any CPU.Build.0 = Staging|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Production|Any CPU.ActiveCfg = Local|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Production|Any CPU.Build.0 = Local|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6B96F0E-8325-4A5E-BFED-1AE0A23530AA}.Release|Any CPU.Build.0 = Release|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion Samples/RegexDtoAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
// public class RegexDtoAttribute(
// string regex,
// type? baseType = default,
// Rxo regexOptions = Rxo.Compiled | Rxo.IgnoreCase | Rxo.Multiline
// RegexOptions regexOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline
// ) : Attribute { }
10 changes: 5 additions & 5 deletions Samples/USPostalAddresss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public partial record class USPostalAddressBase
| RegexOptions.RightToLeft
| RegexOptions.Singleline
)]
public static partial Regx Regex();
public static partial Regex Regex();
#else
private static readonly Regx _regex = new(RegexString);
private static readonly Regex _regex = new(RegexString);

public static Regx Regex() => _regex;
public static Regex Regex() => _regex;
#endif

public static USPostalAddress Parse(string s)
Expand Down Expand Up @@ -109,9 +109,9 @@ public partial record class USPostalAddress : USPostalAddressBase
)]
public static partial System.Text.RegularExpressions.Regex Regex();
#else
private static readonly Regx _regex = new(RegexString);
private static readonly Regex _regex = new(RegexString);

public static new Regx Regex() => _regex;
public static new Regex Regex() => _regex;
#endif

public USPostalAddress() { }
Expand Down
6 changes: 3 additions & 3 deletions src/Dgmjr.RegexDtoGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<PackageReference Include="System.Text.Json" />
<PackageReference Include="ThisAssembly.AssemblyInfo" />
<PackageReference Include="ThisAssembly.Project" />
<UsingsPackageReference Include="System.Text.RegularExpressions.Usings" />
<UsingsPackageReference Include="System.Usings" />
<SourceCodePackageReference Include="System.Private.CoreLib.Polyfills" />
<PackageReference Include="System.Text.RegularExpressions.Usings" IncludeAssets="Build;BuildTransitive;BuildMultitargeting;Runtime;Compile" ExcludeAssets="ContentFiles;Native;Analyzers" PrivateAssets="None" />
<PackageReference Include="System.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
26 changes: 13 additions & 13 deletions src/Dgmjr.RegexDtoGenerator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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", "Dgmjr.RegexDtoGenerator.csproj", "{77F2F4E2-D289-4467-A600-51BC4FA945FB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.RegexDtoGenerator", "Dgmjr.RegexDtoGenerator.csproj", "{976286D4-51C6-471D-BF44-9E1D1DAD040D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -20,18 +20,18 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Local|Any CPU.ActiveCfg = Local|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Local|Any CPU.Build.0 = Local|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Testing|Any CPU.Build.0 = Testing|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Staging|Any CPU.Build.0 = Staging|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Production|Any CPU.ActiveCfg = Local|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Production|Any CPU.Build.0 = Local|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77F2F4E2-D289-4467-A600-51BC4FA945FB}.Release|Any CPU.Build.0 = Release|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Local|Any CPU.ActiveCfg = Local|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Local|Any CPU.Build.0 = Local|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Testing|Any CPU.Build.0 = Testing|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Staging|Any CPU.Build.0 = Staging|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Production|Any CPU.ActiveCfg = Local|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Production|Any CPU.Build.0 = Local|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{976286D4-51C6-471D-BF44-9E1D1DAD040D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 4 additions & 4 deletions src/Models/RegexDtoTypeDeclarationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public RegexDtoDeclarationModel(
RegexDtoConstructorDeclarationModel constructor,
IEnumerable<RegexDtoPropertyDeclarationModel> properties,
string baseType = "",
Rxo regexOptions = Compiled | IgnoreCase | ExplicitCapture
RegexOptions regexOptions = Compiled | IgnoreCase | ExplicitCapture
)
{
TypeName = typeName;
Expand Down Expand Up @@ -56,7 +56,7 @@ public RegexDtoDeclarationModel Initialize()
}

public const string Visibility = "public";
public readonly Rxo RegexOptions { get; init; }
public readonly RegexOptions RegexOptions { get; init; }
public readonly string NamespaceName { get; init; }
public readonly string Regex { get; init; }
public readonly string TypeName { get; init; }
Expand All @@ -81,7 +81,7 @@ public RegexDtoBaseTypeDeclarationModel(
RegexDtoConstructorDeclarationModel constructor,
IEnumerable<RegexDtoPropertyDeclarationModel> properties,
string baseType = "",
Rxo regexOptions = Compiled | IgnoreCase | ExplicitCapture
RegexOptions regexOptions = Compiled | IgnoreCase | ExplicitCapture
)
{
TypeName = typeName;
Expand Down Expand Up @@ -111,7 +111,7 @@ public RegexDtoBaseTypeDeclarationModel Initialize()
}

public const string Visibility = "public";
public readonly Rxo RegexOptions { get; init; }
public readonly RegexOptions RegexOptions { get; init; }
public readonly string NamespaceName { get; init; }
public readonly string Regex { get; init; }
public readonly string TypeName { get; init; }
Expand Down
8 changes: 4 additions & 4 deletions src/RegexDtoGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public partial class RegexDtoGenerator : IIncrementalGenerator
private const string RegexString =
@"\(\?\<(?<Name>[a-zA-Z0-9]+)(?:\:(?<Type>[a-zA-Z0-9]+\??))?\>.*?\)";

private const Rxo RegexOptions = Compiled | IgnoreCase | Multiline;
private const RegexOptions RegexOptions = Compiled | IgnoreCase | Multiline;

#if NET7_0_OR_GREATER
[GeneratedRegex(RegexString, RegexOptions)]
private static partial Regx Regex();
private static partial Regex Regex();
#else
private static Regx Regex() => _regex;
private static Regex Regex() => _regex;

private static readonly Regx _regex = new(RegexString, RegexOptions);
private static readonly Regex _regex = new(RegexString, RegexOptions);
#endif

/// <summary>
Expand Down

0 comments on commit e8df7ee

Please sign in to comment.