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

LFT-1285 - Allow users to suppress the sync generator #951

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

j3parker
Copy link
Member

This will allow .NET core projects to not generate sync stuff (which will often not want to support sync)

j3parker added 2 commits July 31, 2024 14:53
This will allow .NET core projects to not generate sync stuff (which will often not want to support sync)
@j3parker j3parker marked this pull request as ready for review July 31, 2024 19:43
@j3parker j3parker requested a review from omsmith as a code owner July 31, 2024 19:43
@j3parker
Copy link
Member Author

The first place I'd like to use this is D2L.Security.OAuth2, to remove sync from the .NET Core build.

It's not so much about the implementation of the sync stuff, but the fact that the public interfaces gain sync methods and thus we're forcing users of the library to maintain sync implementations (which may not be feasible in .NET core)

Comment on lines 178 to 181
// TODO: can we read options earlier and not spend time generating?
if( options.SuppressSyncGenerator ) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the easiest spot you could do is methodsToGenerate.Combine( options ).Select( GenerateSyncMethod ) and update GenerateSyncMethod to take (MethodDeclarationSyntax MethodDeclaration, Compilation Compilation, SyncGeneratorOptions options)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah whoops meant to deal with this before opening the PR.

Ya haha I was writing this in github.dev without IDE support and figured the exact signature for GenerateSyncMethod would be nasty so dodged it.

I also wanted to see if I could make it happen earlier, like before IsInterestingLookingMethod/ExtractSyntax etc. but even with the IDE it wasn't clear, oh well.

@j3parker j3parker force-pushed the supress-sync-generator branch from 82567dd to ec1d048 Compare August 1, 2024 16:14
@@ -20,7 +24,8 @@ internal sealed partial class SyncGenerator : IIncrementalGenerator {
// Do the generation per method
IncrementalValuesProvider<MethodGenerationResult> generatedMethods =
methodsToGenerate
.Select( GenerateSyncMethod )
.Combine( options )
.Select( (x, ct) => GenerateSyncMethod( x.Left.Item1, x.Left.Item2, x.Right, ct ) )
Copy link
Member Author

Choose a reason for hiding this comment

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

x.Left.Item1, x.Left.Item2, x.Right pretty ugly lol

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I thought Combine magiced that. And you can't destructure into lambda variables yet so that's also sad

@@ -46,4 +46,8 @@
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<CompilerVisibleProperty Include="SuppressSyncGenerator" />
</ItemGroup>
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically not necessary but I believe putting this here will mean that users will not have to do it.

Users will configure it like this:

<PropertyGroup>
  <SuppressSyncGenerator>true</SupressSyncGenerator>
</PropertyGroup>

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we prefix that with D2LCodeStyle or something then?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤷‍♂️ I've seen microsoft not prefix as long as its unambiguous, but I have no strong feelings.

Copy link
Member Author

Choose a reason for hiding this comment

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

@j3parker j3parker merged commit 7e86084 into main Aug 1, 2024
1 check passed
@j3parker j3parker deleted the supress-sync-generator branch August 1, 2024 17:34
@j3parker j3parker changed the title Allow users to suppress the sync generator LFT-1285 - Allow users to suppress the sync generator Aug 1, 2024
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.

2 participants