Skip to content

Commit

Permalink
'tworks!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmjr committed Oct 18, 2023
1 parent dfeeaa6 commit 6e31d45
Show file tree
Hide file tree
Showing 20 changed files with 571 additions and 309 deletions.
31 changes: 31 additions & 0 deletions Samples/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Constants.cs
*
* Created: 2023-10-10-02:59:41
* Modified: 2023-10-10-02:59:41
*
* Author: David G. Moore, Jr. <david@dgmjr.io>
*
* Copyright © 2022 - 2023 David G. Moore, Jr., All Rights Reserved
* License: MIT (https://opensource.org/licenses/MIT)
*/

namespace Dgmjr.Mime;

public static class Constants
{
/// <value>https://www.iana.org/assignments/media-types/</value>
public const string IanaMediaTypeUrlBase = "https://www.iana.org/assignments/media-types/";

/// <value>https://www.rfc-editor.org/rfc/</value>
public const string RfcUrlBase = "https://www.rfc-editor.org/rfc/";

/// <value>urn:ietf:rfc</value>
public const string IetfRfcUrnBase = "urn:ietf:rfc";

/// <value>urn:iana:mime</value>
public const string MimeUrnBase = "urn:iana:mime";

/// <value>media-types.xhtml</value>
public const string MediaTypes_xhtml = "media-types.xhtml";
}
3 changes: 3 additions & 0 deletions Samples/Dgmjr.Enumerations.CodeGenerator.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<IncludeInSolutionFile>true</IncludeInSolutionFile>
<WarningsAsErrors>$(WarningsAsErrors);CS8785</WarningsAsErrors>
<CopyLocalLockFileAssembples>true</CopyLocalLockFileAssembples>
<NoWarn>$(NoWarn);CS0105;CS9113</NoWarn>
<IsNuGetized>false</IsNuGetized>
<Description>Samples for the DGMJR Enumeration data structure generator</Description>
</PropertyGroup>
<ItemGroup>
<SourceGeneratorPackageReference Include="Dgmjr.Enumerations.CodeGenerator" />
Expand Down
26 changes: 13 additions & 13 deletions Samples/Dgmjr.Enumerations.CodeGenerator.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.Enumerations.CodeGenerator.Samples", "Dgmjr.Enumerations.CodeGenerator.Samples.csproj", "{FBF29047-8547-471A-A7D3-327A061651F9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.Enumerations.CodeGenerator.Samples", "Dgmjr.Enumerations.CodeGenerator.Samples.csproj", "{166E5F60-3449-4A11-AA22-092E10E19564}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -20,18 +20,18 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FBF29047-8547-471A-A7D3-327A061651F9}.Local|Any CPU.ActiveCfg = Local|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Local|Any CPU.Build.0 = Local|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Testing|Any CPU.Build.0 = Testing|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Staging|Any CPU.Build.0 = Staging|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Production|Any CPU.ActiveCfg = Local|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Production|Any CPU.Build.0 = Local|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBF29047-8547-471A-A7D3-327A061651F9}.Release|Any CPU.Build.0 = Release|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Local|Any CPU.ActiveCfg = Local|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Local|Any CPU.Build.0 = Local|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Debug|Any CPU.Build.0 = Debug|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Testing|Any CPU.Build.0 = Testing|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Staging|Any CPU.Build.0 = Staging|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Production|Any CPU.ActiveCfg = Local|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Production|Any CPU.Build.0 = Local|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Release|Any CPU.ActiveCfg = Release|Any CPU
{166E5F60-3449-4A11-AA22-092E10E19564}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion Samples/HttpMethodsEnum.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace System.Net.Http.Enums;

[GenerateEnumerationRecordStructAttribute("HttpMethods", "System.Net.Http"), Flags]
public enum HttpMethod : byte
public enum HttpMethod : sbyte
{
None = 0,
Get = 1,
Expand Down
81 changes: 81 additions & 0 deletions Samples/VideoMediaTypeEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* VideoMediaType.cs
*
* Created: 2023-03-18-07:00:15
* Modified: 2023-03-18-07:00:15
*
* Author: David G. Moore, Jr. <david@dgmjr.io>
*
* Copyright © 2022-2023 David G. Moore, Jr., All Rights Reserved
* License: MIT (https://opensource.org/licenses/MIT)
*/

namespace Dgmjr.Mime.Enums;

using static Dgmjr.Mime.Constants;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

[GenerateEnumerationRecordStruct("Video", "Dgmjr.Mime")]
public enum VideoMediaTypes : int
{
[Display(Name = VideoMediaTypeNames.Any, Description = nameof(Any))]
[Uri(IanaMediaTypeUrlBase + "#video")]
Any = int.MaxValue,

[Display(Name = VideoMediaTypeNames.Base, Description = nameof(Base))]
[Uri(IanaMediaTypeUrlBase + "#video-*")]
Base = 0,

[Display(Name = VideoMediaTypeNames.Mpeg, Description = nameof(Mpeg))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Mpeg)]
Mpeg,

[Display(Name = VideoMediaTypeNames.Mpeg4, Description = nameof(Mpeg4))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Mpeg4)]
Mpeg4,

[Display(Name = VideoMediaTypeNames.Mpeg4Generic, Description = nameof(Mpeg4Generic))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Mpeg4Generic)]
Mpeg4Generic,

[Display(Name = VideoMediaTypeNames.Mp4, Description = nameof(Mp4))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Mp4)]
Mp4,

[Display(Name = VideoMediaTypeNames.Ogg, Description = nameof(Ogg))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Ogg)]
Ogg,

[Display(Name = VideoMediaTypeNames.QuickTime, Description = nameof(QuickTime))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.QuickTime)]
QuickTime,

[Display(Name = VideoMediaTypeNames.WebM, Description = nameof(WebM))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.WebM)]
WebM,

[Display(Name = VideoMediaTypeNames.H264, Description = nameof(H264))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.H264)]
H264,

[Display(Name = VideoMediaTypeNames.H265, Description = nameof(H265))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.H265)]
H265,

[Display(Name = VideoMediaTypeNames.Theora, Description = nameof(Theora))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Theora)]
Theora,

[Display(Name = VideoMediaTypeNames.Vp8, Description = nameof(Vp8))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Vp8)]
Vp8,

[Display(Name = VideoMediaTypeNames.Vp9, Description = nameof(Vp9))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Vp9)]
Vp9,

[Display(Name = VideoMediaTypeNames.Vorbis, Description = nameof(Vorbis))]
[Uri(IanaMediaTypeUrlBase + VideoMediaTypeNames.Vorbis)]
Vorbis
}
42 changes: 42 additions & 0 deletions Samples/VideoMediaTypeNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* VideoMediaTypeNames.cs
*
* Created: 2022-12-31-01:35:40
* Modified: 2022-12-31-01:35:40
*
* Author: David G. Moore, Jr, <david@dgmjr.io>
*
* Copyright © 2022-2023 David G. Moore, Jr,, All Rights Reserved
* License: MIT (https://opensource.org/licenses/MIT)
*/

namespace Dgmjr.Mime;

using System.Runtime.Serialization;

public class Foo
{
public static void Go()
{
var mp4 = Mime.Video.Mp4.Instance;
}
}

public static class VideoMediaTypeNames
{
public const string Base = "video";
public const string Any = Base + "/" + "*";
public const string Mpeg = Base + "/" + "mpeg";
public const string Mpeg4 = Base + "/" + "mp4";
public const string Mpeg4Generic = Base + "/" + "mp4; codecs=avc1.42E01E, mp4a.40.2";
public const string Mp4 = Base + "/" + "mp4";
public const string Ogg = Base + "/" + "ogg";
public const string QuickTime = Base + "/" + "quicktime";
public const string WebM = Base + "/" + "webm";
public const string H264 = Base + "/" + "H264";
public const string H265 = Base + "/" + "H265";
public const string Theora = Base + "/" + "Theora";
public const string Vp8 = Base + "/" + "VP8";
public const string Vp9 = Base + "/" + "VP9";
public const string Vorbis = Base + "/" + "Vorbis";
}
2 changes: 1 addition & 1 deletion Tests/Dgmjr.Enumerations.CodeGenerator.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="XUnit.Usings" />
<PackageReference Include="xunit" />

<ProjectReference Include="../src/Dgmjr.Enumerations.CodeGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" IncludeAssets="Analyzers;Build" ExcludeAssets="Native;BuildTransitive;ContentFiles" PrivateAssets="All" />
<ProjectReference Include="../src/Dgmjr.Enumerations.CodeGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" IncludeAssets="Analyzers;Build;Compile;Runtime" ExcludeAssets="Native;BuildTransitive;ContentFiles" PrivateAssets="All" />

<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
<UsingsPackageReference Include="MSBuild.Usings" />
Expand Down
52 changes: 26 additions & 26 deletions Tests/Dgmjr.Enumerations.CodeGenerator.Tests.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ 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.Enumerations.CodeGenerator", "..\src\Dgmjr.Enumerations.CodeGenerator.csproj", "{9CD14C76-08D6-43D0-B817-9F896FD41657}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.Enumerations.CodeGenerator", "..\src\Dgmjr.Enumerations.CodeGenerator.csproj", "{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.Enumerations.CodeGenerator.Tests", "Dgmjr.Enumerations.CodeGenerator.Tests.csproj", "{D47CED42-09CA-4C9B-877C-8BB58D613230}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.Enumerations.CodeGenerator.Tests", "Dgmjr.Enumerations.CodeGenerator.Tests.csproj", "{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,30 +21,30 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Local|Any CPU.ActiveCfg = Local|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Local|Any CPU.Build.0 = Local|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Testing|Any CPU.Build.0 = Testing|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Staging|Any CPU.Build.0 = Staging|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Production|Any CPU.ActiveCfg = Local|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Production|Any CPU.Build.0 = Local|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CD14C76-08D6-43D0-B817-9F896FD41657}.Release|Any CPU.Build.0 = Release|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Local|Any CPU.ActiveCfg = Local|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Local|Any CPU.Build.0 = Local|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Testing|Any CPU.Build.0 = Testing|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Staging|Any CPU.Build.0 = Staging|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Production|Any CPU.ActiveCfg = Local|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Production|Any CPU.Build.0 = Local|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D47CED42-09CA-4C9B-877C-8BB58D613230}.Release|Any CPU.Build.0 = Release|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Local|Any CPU.ActiveCfg = Local|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Local|Any CPU.Build.0 = Local|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Testing|Any CPU.Build.0 = Testing|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Staging|Any CPU.Build.0 = Staging|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Production|Any CPU.ActiveCfg = Local|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Production|Any CPU.Build.0 = Local|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4622771-2A7B-42E6-9B3C-8F71CDD7E65B}.Release|Any CPU.Build.0 = Release|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Local|Any CPU.ActiveCfg = Local|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Local|Any CPU.Build.0 = Local|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Testing|Any CPU.Build.0 = Testing|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Staging|Any CPU.ActiveCfg = Staging|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Staging|Any CPU.Build.0 = Staging|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Production|Any CPU.ActiveCfg = Local|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Production|Any CPU.Build.0 = Local|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8037C3AA-FC4B-4379-8C4E-0517FC90E94E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
20 changes: 10 additions & 10 deletions Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
namespace Dgmjr.Enumerations.CodeGenerator.Tests;

using Dgmjr.CodeGeneration.Testing;
using System;
using System.Collections.Immutable;
using System.Reflection;

using Microsoft.Build.Locator;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Testing.Verifiers;

using Microsoft.CodeAnalysis;
using System.Collections.Immutable;
using System;
using System.Reflection;
using Microsoft.Build.Locator;
using Microsoft.CodeAnalysis.MSBuild;
using Dgmjr.CodeGeneration.Testing;

namespace Dgmjr.Enumerations.CodeGenerator.Tests;

public abstract class CSharpSourceGeneratorVerifier<TSourceGenerator>
where TSourceGenerator : IIncrementalGenerator, new()
Expand Down Expand Up @@ -76,4 +76,4 @@ public void RunTest()
);
}

public class EnumSourceGeneratorTest : CSharpSourceGeneratorVerifier<EnumDataStructureGenerator> { }
public class EnumSourceGeneratorTest : CSharpSourceGeneratorVerifier<EnumerationGenerator> { }
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./clean.ps1
dotnet build ./src/*.csproj;
dotnet build ./src/*.csproj;
dotnet build ./Samples/*.csproj;
2 changes: 2 additions & 0 deletions clean.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rm -rf **/obj
rm -rf **/bin
Loading

0 comments on commit 6e31d45

Please sign in to comment.