GithubHelp home page GithubHelp logo

alexrosenfeld10 / h.generators.extensions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from havendv/h.generators.extensions

0.0 0.0 0.0 203 KB

A set of extensions to simplify the code of generators

License: MIT License

C# 100.00%

h.generators.extensions's Introduction

H.Generators.Extensions

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.

Install

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.

Extensions

AnalyzerConfigOptionsProviderExtensions

  • 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>

SourceProductionContextExtensions

  • context.AddTextSource(string hintName, string text)
  • context.ReportException(string id, Exception)

StringExtensions

  • name.ToPropertyName()
  • name.ToParameterName()
  • text.RemoveBlankLinesWhereOnlyWhitespaces()
  • text.NormalizeLineEndings(string? newLine = null)
  • fullTypeName.ExtractNamespace()
  • fullTypeName.ExtractSimpleName()
  • fullTypeName.WithGlobalPrefix()

EnumerableExtensions

  • values.Inject()

H.Generators.Tests.Extensions

  • DictionaryAnalyzerConfigOptions
  • DictionaryAnalyzerConfigOptionsProvider
  • MemoryAdditionalText
  • ImmutableArrayExtensions.NormalizeLocations

Support

You can get answers to your questions in my discord support channel:
https://discord.gg/g8u2t9dKgE

h.generators.extensions's People

Contributors

havendv avatar alexrosenfeld10 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.