Uh oh!
There was an error while loading. Please reload this page.
Don't generate a nearly empty file - #76835
Conversation
ghost
commented
Oct 10, 2022
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsWhen generators are running in the Visual Studio IDE, there's some overhead to having to manage a project that actually has generated output. It requires us to maintain two Roslyn Compilation objects, each which have their own symbol information. These interop generators are producing a file that's effectively empty (just an comment on the top), and since they're installed in all .NET 7.0 applications, they are the reason we'll be having to manage more memory than before. Since the fix is simple enough to only generate the output if necessary, we should do so. This also will help with telemetry, since we have telemetry that lets us tracking in the wild which generators are producing how many files; if we're always producing exactly one file we won't know how many sessions out there are actually using this generator in a meaningful way.
|
AaronRobinsonMSFT
commented
Oct 10, 2022
@pavelsavara I think we might also need a fix in the JavaScript interop source generator, right? |
jasonmalinowski
commented
Oct 10, 2022
@AaronRobinsonMSFT: as far as I can tell, this is a common helper used for everything, but unless there's another copy somewhere else I don't know about? |
jasonmalinowski
commented
Oct 10, 2022
Marking as draft since I presume this broke some tests, but I don't know where they are yet. |
jkoritzinsky
left a comment
There was a problem hiding this comment.
LGTM. I believe the JS generator uses the same extension methods to build out the generated sources, so this should cover the JS generators as well.
jasonmalinowski
commented
Oct 11, 2022
@jkoritzinsky@AaronRobinsonMSFT I assumed this would have broken a test somewhere but I guess there's no negative test asserting no files are produced if nothing is needed. Where should one be added? |
AaronRobinsonMSFT
commented
Oct 13, 2022
Likely not. I think the most appropriate place would be after the following tests or integrated into them. These are confirming we compile even though |
elinor-fung
commented
Oct 13, 2022
I think integrating with the one Aaron pointed at makes sense. I would:
|
When generators are running in the Visual Studio IDE, there's some overhead to having to manage a project that actually has generated output. It requires us to maintain two Roslyn Compilation objects, each which have their own symbol information. These interop generators are producing a file that's effectively empty (just an <auto-generated> comment on the top), and since they're installed in all .NET 7.0 applications, they are the reason we'll be having to manage more memory than before. Since the fix is simple enough to only generate the output if necessary, we should do so. This also will help with telemetry, since we have telemetry that lets us tracking in the wild which generators are producing how many files; if we're always producing exactly one file we won't know how many sessions out there are actually using this generator in a meaningful way.
9ec995c to
7518228Comparejasonmalinowski
commented
Oct 17, 2022
@jkoritzinsky@AaronRobinsonMSFT@elinor-fung Test added, so this would need a small re-review. Otherwise I think it's ready to go? |
AaronRobinsonMSFT
commented
Oct 18, 2022
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3277608142 |
When generators are running in the Visual Studio IDE, there's some overhead to having to manage a project that actually has generated output. It requires us to maintain two Roslyn Compilation objects, each which have their own symbol information. These interop generators are producing a file that's effectively empty (just an comment on the top), and since they're installed in all .NET 7.0 applications, they are the reason we'll be having to manage more memory than before. Since the fix is simple enough to only generate the output if necessary, we should do so.
This also will help with telemetry, since we have telemetry that lets us tracking in the wild which generators are producing how many files; if we're always producing exactly one file we won't know how many sessions out there are actually using this generator in a meaningful way.
Fixes#76298