A set of extensions to simplify the test code of generators. ⭐ Last 10 features: - feat: Updated to net9 2024-11-13 - feat: Added Net9 to LatestReferenceAssemblies. 2024-11-13 - feat: Added extensions from DependencyPropertyGenerator. 2023-12-01 - feat: Updated to net8.0. 2023-11-30 - feat: Added net8.0 support for ReferenceAssemblies. 2023-11-08 - feat: Updated Uno version in FrameworkReferenceAssemblies. 2023-09-22 - feat: Added GeneratorDriverExtensions. 2023-08-31 - feat: Added net7.0 reference assemblies. 2023-08-30 - feat: Added SelectAndReportDiagnostics. 2023-08-16 - feat: Added IncrementalValuesProvider.CollectAsEquatableArray. 2023-03-10 🐞 Last 10 bug fixes: - fix: Fixed version of Microsoft.CodeAnalysis.CSharp. 2025-02-26 - fix: Fixed ToParameterName for C# keywords. 2025-01-12 - fix: Updated Uno and WinAppSdk versions. 2023-12-01 - fix: Fixed Avalonia ReferenceAssemblies. 2023-08-31 - fix: Fixed warnings. 2023-08-30 - fix: Added ability to add/remove _SystemLibs. 2023-04-08 - fix: Added missing IncrementalValueProvider SelectAndReportExceptions without cancellation token. 2023-03-09 - fix: Added IncrementalValueProvider SelectAndReportExceptions. 2023-03-09 - fix: Added missing useful overloads. 2023-03-09 - fix: Added IncrementalValuesProviderExtensions.WhereNotNull. 2023-03-09
$ dotnet add package H.Generators.Tests.ExtensionsA 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.TryRecognizeFramework(string prefix)options.RecognizeFramework(string prefix)
To recognize the framework, 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.ReportException(string id, Exception)name.ToPropertyName()name.ToParameterName()text.RemoveBlankLinesWhereOnlyWhitespaces()text.NormalizeLineEndings(string? newLine = null)fullTypeName.ExtractNamespace()fullTypeName.ExtractSimpleName()fullTypeName.WithGlobalPrefix()values.Inject()DictionaryAnalyzerConfigOptionsDictionaryAnalyzerConfigOptionsProviderMemoryAdditionalTextImmutableArrayExtensions.NormalizeLocationsYou can get answers to your questions in my discord support channel:
https://discord.gg/g8u2t9dKgE