Skip to content

Commit

Permalink
Added some docs for the generators
Browse files Browse the repository at this point in the history
They help links now jump to github
  • Loading branch information
ByronMayne committed Mar 10, 2024
1 parent 5baf6be commit ab55c99
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ You can embed any assemblies you want by adding them to `<SGF_EmbeddedAssembly I
Included with this package is a code analyzer that will be used to catch common mistakes when working with this library.


### `SGF1001` SGFGeneratorAttributeApplied
### `SGF1001`
**Has SgfGenerator Attribute**

Any class that inherits from `IncrementalGenerator` is required to have the `SgfGenerator` attribute applied to it.

Expand All @@ -155,7 +156,9 @@ public class MyGenerator : IncrementalGenerator
}
```

### `SGF1002` ProhibitGeneratorAttribute
### `SGF1002`

**Prohibit Generator Attribute**

If an `IncrementalGenerator` has the `Generator` attribute applied it will cause a compiler error. The reason being that the `Generator` attribute is used on classes that implement `IIncrementalGenerator` which `IncrementalGenerator` does not. SGF has it's own attribute to not confuse roslyn. SGFs `IncrementalGenerator` is run from within a wrapper to help capture exceptions and handle runtime type resolving.

Expand All @@ -180,7 +183,8 @@ public class MyGenerator : IncrementalGenerator
}
```

### `SGF1003` HasDefaultConstructor
### `SGF1003`
**Has Default Constructor**

`IncrementalGenerator` require a default constructor so they can be instantiated at runtime. If no constructor is defined the generator will never be run.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private static DiagnosticDescriptor CreateDescriptor()
"SourceGeneration",
DiagnosticSeverity.Error,
true,
$"Incremental Generators should not have the {nameof(GeneratorAttribute)} applied to them.");
$"Incremental Generators should not have the {nameof(GeneratorAttribute)} applied to them.",
"https://github.com/ByronMayne/SourceGenerator.Foundations?tab=readme-ov-file#sgf1002");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ private static DiagnosticDescriptor CreateDescriptor()
"SourceGeneration",
DiagnosticSeverity.Error,
true,
"SGF Incremental Generators must have a default constructor otherwise they will not be run");
"SGF Incremental Generators must have a default constructor otherwise they will not be run",
"https://github.com/ByronMayne/SourceGenerator.Foundations?tab=readme-ov-file#sgf1003");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private static DiagnosticDescriptor CreateDescriptor()
"SourceGeneration",
DiagnosticSeverity.Error,
true,
$"Source generators are required to have the attribute {nameof(SgfGeneratorAttribute)} applied to them otherwise the compiler won't invoke them");
$"Source generators are required to have the attribute {nameof(SgfGeneratorAttribute)} applied to them otherwise the compiler won't invoke them",
"https://github.com/ByronMayne/SourceGenerator.Foundations?tab=readme-ov-file#sgf1001");
}
}

0 comments on commit ab55c99

Please sign in to comment.