From 3f191651af79fadbe7d8d834b97791e2ecd99635 Mon Sep 17 00:00:00 2001 From: Tom Walker Date: Sat, 15 Jul 2023 07:35:48 -0400 Subject: [PATCH 1/2] Address code inspection items --- CodePointEnumGenerator.Tests/AdditionalFile.cs | 2 +- CodePointEnumGenerator.Tests/GeneratorTestFactory.cs | 2 +- CodePointEnumGenerator.Tests/Helpers/ToEnumEntryTests.cs | 1 + CodePointEnumGenerator/CodePointEnumGenerator.cs | 1 + CodePointEnumGenerator/Helpers/AdditionalTextExtensions.cs | 1 - 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CodePointEnumGenerator.Tests/AdditionalFile.cs b/CodePointEnumGenerator.Tests/AdditionalFile.cs index ba8fbdd..8c9354d 100644 --- a/CodePointEnumGenerator.Tests/AdditionalFile.cs +++ b/CodePointEnumGenerator.Tests/AdditionalFile.cs @@ -15,7 +15,7 @@ public AdditionalFile(string path, string contents) _sourceText = SourceText.From(contents, Encoding.UTF8); } - public override SourceText? GetText(CancellationToken cancellationToken = new()) => + public override SourceText GetText(CancellationToken cancellationToken = new()) => _sourceText; public override string Path { get; } diff --git a/CodePointEnumGenerator.Tests/GeneratorTestFactory.cs b/CodePointEnumGenerator.Tests/GeneratorTestFactory.cs index b10a16c..c7f0b91 100644 --- a/CodePointEnumGenerator.Tests/GeneratorTestFactory.cs +++ b/CodePointEnumGenerator.Tests/GeneratorTestFactory.cs @@ -36,7 +36,7 @@ public static (Compilation? Compilation, var references = new MetadataReference[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location), - MetadataReference.CreateFromFile(typeof(CodePointEnumGenerator).Assembly.Location), + MetadataReference.CreateFromFile(typeof(CodePointEnumGenerator).Assembly.Location) }; var compilation = CSharpCompilation.Create( diff --git a/CodePointEnumGenerator.Tests/Helpers/ToEnumEntryTests.cs b/CodePointEnumGenerator.Tests/Helpers/ToEnumEntryTests.cs index b6064a8..e386430 100644 --- a/CodePointEnumGenerator.Tests/Helpers/ToEnumEntryTests.cs +++ b/CodePointEnumGenerator.Tests/Helpers/ToEnumEntryTests.cs @@ -8,6 +8,7 @@ public class ToEnumEntryTests [Theory] [InlineData("add_comment", "AddComment")] [InlineData("add", "Add")] + // ReSharper disable twice StringLiteralTypo [InlineData("addcomment", "Addcomment")] [InlineData("1k_plus", "OneKPlus")] [InlineData("2k_plus", "TwoKPlus")] diff --git a/CodePointEnumGenerator/CodePointEnumGenerator.cs b/CodePointEnumGenerator/CodePointEnumGenerator.cs index b45fac0..0c1cbed 100644 --- a/CodePointEnumGenerator/CodePointEnumGenerator.cs +++ b/CodePointEnumGenerator/CodePointEnumGenerator.cs @@ -26,6 +26,7 @@ public void Execute(GeneratorExecutionContext context) context.ReportDiagnostic( Diagnostic.Create( new DiagnosticDescriptor( + // ReSharper disable once StringLiteralTypo "NOFILES", "No Codepoint files found", "", diff --git a/CodePointEnumGenerator/Helpers/AdditionalTextExtensions.cs b/CodePointEnumGenerator/Helpers/AdditionalTextExtensions.cs index b5a6b2e..bdb51fa 100644 --- a/CodePointEnumGenerator/Helpers/AdditionalTextExtensions.cs +++ b/CodePointEnumGenerator/Helpers/AdditionalTextExtensions.cs @@ -1,5 +1,4 @@ using Microsoft.CodeAnalysis; -using System; using System.IO; namespace CodePointEnumGenerator.Helpers; From 9088622ed53d109f8aeead72201d19603b62a144 Mon Sep 17 00:00:00 2001 From: Tom Walker Date: Sat, 15 Jul 2023 07:36:02 -0400 Subject: [PATCH 2/2] Add info about pipeline to readme --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 286ac15..cf2ff62 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,16 @@ -# CodePointEnumGenerator +CodePointEnumGenerator +====================== A C# source generator that generates enums for all font codepoint files are contained in the project as Additional Files. Each resulting enum can be used for strongly-typed references to the byte value of specific glyphs in the associated font. -## Links +# Links [![Build status](https://ci.appveyor.com/api/projects/status/2lgs7mbehdvls38q?svg=true)](https://ci.appveyor.com/project/tpwalke2/codepointenumgenerator) [![NuGet](https://img.shields.io/nuget/v/CodePointEnumGenerator.svg)](https://www.nuget.org/packages/CodePointEnumGenerator/) -## To Use +# To Use 1. Reference the Generator package as an analyzer: ```xml @@ -23,10 +24,14 @@ Each resulting enum can be used for strongly-typed references to the byte value 1. Include codepoints files for fonts with a build action of `AddtionalFiles`. 2. Rebuild the solution. -## Troubleshooting +# Troubleshooting The `Source Generators` folder should appear under `Dependencies\.NET 6.0` for the project that references the generator. There should also be a separate generated C# file that contains the enum for each `codepoints` file in the project. If either or both of these are not the case: - Verify that the generator project is referenced as an `Analyzer`. - Verify that the `codepoints` files have a build action of `AdditionalFiles`. - Clean the solution and then rebuild. -- Close the solution, delete the bin and obj folders for the project, then reopen the solution and rebuild. \ No newline at end of file +- Close the solution, delete the bin and obj folders for the project, then reopen the solution and rebuild. + +# Build Pipeline +- Requires a Github personal access token with read/write on Contents +- Requires a Nuget API key \ No newline at end of file