-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce IsDirty boolean property from 2.3
With the change to ThisAssembly.Constants, we introduced a bug that caused IsDirty to be a string contant, instead of the boolean it was up to 2.3. Closes #243
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
[Generator(LanguageNames.CSharp)] | ||
class GitInfoGenerator : IIncrementalGenerator | ||
{ | ||
public void Initialize(IncrementalGeneratorInitializationContext context) | ||
{ | ||
context.RegisterSourceOutput( | ||
context.AdditionalTextsProvider | ||
.Combine(context.AnalyzerConfigOptionsProvider) | ||
.Combine(context.ParseOptionsProvider) | ||
.Collect(), | ||
(c, _) => | ||
{ | ||
c.AddSource("ThisAssembly.Git.IsDirty.g", | ||
$$""" | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// GitInfo: {{ThisAssembly.Info.InformationalVersion}} | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
partial class ThisAssembly | ||
{ | ||
partial class Git | ||
{ | ||
/// <summary> | ||
/// Gets whether the current repository is dirty. | ||
/// </summary> | ||
public static bool IsDirty => bool.TryParse(IsDirtyString, out var dirty) && dirty; | ||
} | ||
} | ||
"""); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters