Skip to content

Commit

Permalink
sprucing up and making look/work nice
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmjr committed Dec 27, 2023
1 parent e8df7ee commit 8935ec8
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 27 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"BDAY",
"ffffzzz",
"VCARD"
]
],
"sonarlint.connectedMode.project": {
"connectionId": "dgmjr-io",
"projectKey": "dgmjr-io_RegexDtoGenerator"
}
}
8 changes: 4 additions & 4 deletions Samples/Dgmjr.RegexDtoGenerator.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<Project Sdk="Microsoft.NET.Sdk" InitialTargets="Clean">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">obj/</IntermediateOutputPath>
<SlnGenSolutionFolder>codegen</SlnGenSolutionFolder>
<IsNuGetized>false</IsNuGetized>
Expand All @@ -22,9 +22,9 @@
<ItemGroup>
<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" /> -->
<PackageReference Include="Dgmjr.RegexDtoGenerator" IncludeAssets="Analyzers;Build" ExcludeAssets="Native;BuildTransitive;BuildMultitargeting;ContentFiles;Compile;Runtime" PrivateAssets="All" />
<SourceCode Include="System.Private.CoreLib.Polyfills" />

<PackageReference Include="Dgmjr.RegexDtoGenerator" IncludeAssets="Analyzers;Build" ExcludeAssets="Native;BuildTransitive;BuildMultitargeting;ContentFiles;Compile;Runtime" PrivateAssets="All" />
<PackageReference Include="System.Private.CoreLib.Polyfills" IncludeAssets="ContentFiles;Build;BuildTransitive;BuildMultitargeting" ExcludeAssets="Analyzers;Runtime;Native" PrivateAssets="All" />
</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", "{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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Samples/EmailAddressWithDisplayName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Contacts;

/// <summary>A DTO with an email address and a display name</summary>
[RegexDto(
@"^(?<FirstName:string?>\w+)?\s*?(?<LastName:string?>\w+)?\s*?\<(?<Username>\w+)@(?<Domain>((?:\w+\.))(?<Tld>\w+)))\>$"
)]
Expand Down
1 change: 1 addition & 0 deletions Samples/RoomBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ namespace Us.Zoom;

public abstract record class RoomBase : IRoom
{
[@StringSyntax(StringSyntax.Uri)]
public virtual Uri? Url { get; }
}
12 changes: 6 additions & 6 deletions src/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
"""";

Expand All @@ -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 }}";
Expand Down Expand Up @@ -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
/// <summary>The regex string that will be used to validate and recognize the DTO</summary>
public const string RegexString = @"{{ regex }}";
Expand Down
5 changes: 5 additions & 0 deletions src/Dgmjr.RegexDtoGenerator.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<Using Include="System.Diagnostics.CodeAnalysis.StringSyntaxAttribute" Alias="@StringSyntax" />
</ItemGroup>
</Project>
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

0 comments on commit 8935ec8

Please sign in to comment.