2.0.10
Replaced SgfGeneratorAttribute with IncrementalGeneratorAttribute
Both attributes will work and be backwards compatible but previous version will now show a warning. This was down just to clear up the ambiguous nature of the old attribute
using Sgf
// From
[SgfGenerator]
public class MyGenerator : IncrementalGenerator
{}
// To:
[IncrementalGenerator]
public class MyGenerator : IncrementalGenerator
{}Exposed ExceptionHandler in IncrementalGenerator
Exposed new event in the base generator task for handling exceptions. This was done to support better unit testing by allowing for handling of any exception.
public void Processs(IncrementalGenerator generator)
{
generator.ExceptionHandler += OnException;
}
public void OnException(Exception exception)
{}New Context Interfaces
I created ISgfInitializationContext which is implemented by SgfInitializationContext and ISgfSourceProductionContext which is implemented by SgfSourceProductionContext. This was done to allow for writing more unit tests and was a request from the community. In addition for advanced uses cases you can cast the structs as their respective interface and get access to their backing fields. This should only need to be done in advanced use cases.
using SGF;
[IncrementalGenerator]
public class MyGenerator : IncrementalGenerator
{
public override void OnInitialize(SgfInitializationContext context)
{
// Get access to the original context that the SGF wraps.
ISgfInitializationContext sgfContext = (ISgfInitializationContext)context;
IncrementalGeneratorInitializationContext originalContext = sgfContext.OriginalContext;
}
}What's Changed
- Exposed new interfaces for the Context types and exposed access to the wrapped types by @ByronMayne in #38
- Changed the class attribute for marking generators by @ByronMayne in #39
- Exposed 'ExceptionHandler' event in IncrementalGenerator to write simpler unit tests by @ByronMayne in #40
Full Changelog: 2.0.9...2.1.0