Skip to content

Commit

Permalink
Add Breaking changes section to SG cookbook (#47336)
Browse files Browse the repository at this point in the history
* Add Breaking changes section to SG cookbook
  • Loading branch information
chsienki authored Sep 2, 2020
1 parent 2b7b1e9 commit 4602d5d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/features/source-generators.cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,32 @@ specialized exactly to what was written in the user class.

TODO:

## Breaking Changes:

Between preview and release the following breaking changes were introduced:

**Rename `SourceGeneratorContext` to `GeneratorExecutionContext`**
**Rename `IntializationContext` to `GeneratorInitializationContext`**

This affects user-authored generators, as it means the base interface has changed to:

```csharp
public interface ISourceGenerator
{
void Initialize(GeneratorInitializationContext context);
void Execute(GeneratorExecutionContext context);
}
```

The required action from the user is to rename the parameter types of the `Initialize` and `Execute` methods to match.

**Rename `RunFullGeneration` to `RunGeneratorsAndUpdateCompilation`**
**Add `Create()` static methods to `CSharpGeneratorDriver` and obsolete the constructor.**

This affects any generator authors who have written unit tests using the `CSharpGeneratorDriver`. To create a new instance
of the generator driver, the user should no longer call `new` but use one of the `CSharpGeneratorDriver.Create()` overloads.
The user should no longer use the `RunFullGeneration` method, and instead call `RunGeneratorsAndUpdateCompilation` with the same arguments.

## Open Issues

This section track other miscellaneous TODO items:
Expand All @@ -870,4 +896,4 @@ This section track other miscellaneous TODO items:
- Control of name. The developer can control the name of the member
- Generation is optional/depending on other state. Based on other information, generator might decide that the method isn't needed.

**Feature detection**: Show how to create a generator that relies on specific target framework features, without depending on the TargetFramework property.
**Feature detection**: Show how to create a generator that relies on specific target framework features, without depending on the TargetFramework property.

0 comments on commit 4602d5d

Please sign in to comment.