-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce lazy-init of sponsoring status, simplify diagnostics
Incremental generators can run before CompilationStart actions, so we cannot solely rely on that having run first. In order to guarantee set up for incremental generators too, we instead switch to a lazy-init approach, so that regardless of analyzer/generator ordering, the proper status will be set regardless.
- Loading branch information
Showing
7 changed files
with
163 additions
and
104 deletions.
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
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,20 @@ | ||
using Devlooped.Sponsors; | ||
using Microsoft.CodeAnalysis; | ||
using static Devlooped.Sponsors.SponsorLink; | ||
|
||
namespace Analyzer; | ||
|
||
[Generator] | ||
public class StatusReportingGenerator : IIncrementalGenerator | ||
{ | ||
public void Initialize(IncrementalGeneratorInitializationContext context) | ||
{ | ||
context.RegisterSourceOutput( | ||
context.GetSponsorManifests(), | ||
(spc, source) => | ||
{ | ||
var status = Diagnostics.GetOrSetStatus(source); | ||
spc.AddSource("StatusReporting.cs", $"// Status: {status}"); | ||
}); | ||
} | ||
} |
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
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
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
Oops, something went wrong.