A set of extensions to simplify the code of generators. In addition to extensions, this library also adds a .props file to automatically add your generation-time dependencies to the NuGet package and Integration tests.
The usage is pretty simple:
<PackageReference Include="H.Generators.Extensions" Version="1.4.2" PrivateAssets="all" />
I want to note that PrivateAssets="all" is required to rule out some issues.
options.GetGlobalOption(string name)
options.GetOption(AdditionalText, string name)
options.GetRequiredGlobalOption(string name)
options.GetRequiredOption(AdditionalText, string name)
options.TryRecognizePlatform(string prefix)
options.RecognizePlatform(string prefix)
To recognize the platform, you will need to add the following code to your %PackageId%.props(In this case, the passed prefix will be equal to %PackageId%):
<Project>
<ItemGroup>
<CompilerVisibleProperty Include="%PackageId%_DefineConstants"/>
<CompilerVisibleProperty Include="UseWPF"/>
<CompilerVisibleProperty Include="UseWinUI"/>
<CompilerVisibleProperty Include="UseMaui"/>
</ItemGroup>
<Target Name="CreateDefineConstants" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun;GenerateMSBuildEditorConfigFileCore">
<PropertyGroup>
<%PackageId%_DefineConstants>$(DefineConstants.Replace(';',','))</%PackageId%_DefineConstants>
</PropertyGroup>
</Target>
</Project>
context.AddTextSource(string hintName, string text)
context.ReportException(string id, Exception)
name.ToPropertyName()
name.ToParameterName()
text.RemoveBlankLinesWhereOnlyWhitespaces()
text.NormalizeLineEndings(string? newLine = null)
fullTypeName.ExtractNamespace()
fullTypeName.ExtractSimpleName()
fullTypeName.WithGlobalPrefix()
values.Inject()
DictionaryAnalyzerConfigOptions
DictionaryAnalyzerConfigOptionsProvider
MemoryAdditionalText
ImmutableArrayExtensions.NormalizeLocations
You can get answers to your questions in my discord support channel:
https://discord.gg/g8u2t9dKgE