Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Generated source files end in .g.cs #19

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

jhartmann123
Copy link
Contributor

Fixes #18

@@ -59,7 +61,11 @@ private static void Execute(GeneratorExecutionContext context, IEnumerable<Metho

foreach (var (path, source) in replacedTypes)
{
context.AddSource(Path.GetFileNameWithoutExtension(path)+$"_expressionify_{i++}.cs", SourceText.From(source.ToFullString(), Encoding.UTF8));
var sourceCode = NullableDirective + source.ToFullString();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I'm adding #nullable enable to all generated sources, as otherwise the generated code won't compile with the error CS8669: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. (which is a warning, but we have WarningsAsErrors enabled)

Not sure, if this is fine for "legacy" projects where nullable is disabled, as I don't have any bigger old project to test it in, where we also use Expressionify...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not fully sure about old projects, but from all I could find it seemed fine.

@@ -73,7 +84,49 @@ public partial class Nested
private static System.Linq.Expressions.Expression<System.Func<int, int>> Foo_Expressionify_0 { get; } = (int x) => 8;
}
}
}", TestName = "File scoped namespace")]
}", TestName = "Nested class")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find these test cases a bit hard to read, but that's not specifically something introduced here. Tried a bit with TestCaseSource, but never got to anything I was happy with.

@slashP slashP merged commit 6ae459e into ClaveConsulting:master Nov 4, 2022
@jhartmann123 jhartmann123 deleted the g-dot-cs branch November 7, 2022 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated source files should end with .g.cs to mark them as autogenerated
2 participants