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

Logging source generator reruns code generation phase on keypress. #93309

Open
Tracked by #97522
ericstj opened this issue Oct 10, 2023 · 3 comments
Open
Tracked by #97522

Logging source generator reruns code generation phase on keypress. #93309

ericstj opened this issue Oct 10, 2023 · 3 comments
Labels
area-Extensions-Logging source-generator Indicates an issue with a source generator feature
Milestone

Comments

@ericstj
Copy link
Member

ericstj commented Oct 10, 2023

Description

See more detail in #92914.

Reproduction Steps

Create a project that uses Logging source generator. Observe it's execution pattern - either in the debugger or through ETW.

Expected behavior

Changes unrelated to the logging code and it's type closure should not trigger regeneration of the logging source.

Actual behavior

Every change causes the entire pipeline to rerun.

Regression?

No

Known Workarounds

We haven't had reports of the performance here being a blocker, but that could be due to lack of use. The amount of work done on keypress will depend on whether or not the generator has work to do. If it has a lot of work to do, then it will be doing that work on every change.
 
Disable the logging generator from design-time builds (this will result in errors where the generator is used, which are design time only errors).
Workaround:

  <Target Name="_disableLoggingGeneratorInDesignTime" BeforeTargets="ResolveOffByDefaultAnalyzers">
    <ItemGroup Condition="'$(DesignTimeBuild)' == 'true' OR '$(BuildingProject)' != 'true'">
      <OffByDefaultAnalyzer Include="Microsoft.Extensions.Logging.Generators.dll"
                            IsEnabled="$(EnableLoggingGenerator)"/>
    </ItemGroup>
  </Target>

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 10, 2023
@ghost
Copy link

ghost commented Oct 10, 2023

Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

See more detail in #92914.

Reproduction Steps

Create a project that uses Logging source generator. Observe it's execution pattern - either in the debugger or through ETW.

Expected behavior

Changes unrelated to the logging code and it's type closure should not trigger regeneration of the logging source.

Actual behavior

Every change causes the entire pipeline to rerun.

Regression?

No

Known Workarounds

We haven't had reports of the performance here being a blocker, but that could be due to lack of use. The amount of work done on keypress will depend on whether or not the generator has work to do. If it has a lot of work to do, then it will be doing that work on every change.
 
Disable the logging generator from design-time builds (this will result in errors where the generator is used, which are design time only errors).
Workaround:

  <Target Name="_disableLoggingGeneratorInDesignTime" BeforeTargets="ResolveOffByDefaultAnalyzers">
    <ItemGroup Condition="'$(DesignTimeBuild)' == 'true' OR '$(BuildingProject)' != 'true'">
      <OffByDefaultAnalyzer Include="Microsoft.Extensions.Logging.Generators.dll"
                            IsEnabled="$(EnableLoggingGenerator)"/>
    </ItemGroup>
  </Target>

Configuration

No response

Other information

No response

Author: ericstj
Assignees: -
Labels:

area-Extensions-Logging

Milestone: -

@tarekgh tarekgh added this to the 9.0.0 milestone Oct 10, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Oct 10, 2023
@tarekgh tarekgh added the source-generator Indicates an issue with a source generator feature label Oct 10, 2023
@ericstj
Copy link
Member Author

ericstj commented Aug 6, 2024

We discussed improving the incremental characteristics of the runtime source generators and scoped it out of 9.0

@Youssef1313
Copy link
Member

@ericstj Note: Maybe for design-time builds, the generator could generate minimal code (partial method definitions without implementation), which could be fast and incremental, and fixes IntelliSense. And for actual builds the implementation is generated.

One potential consideration that I'm not sure about is, in what context does a build for EnC/HotReload happens? Is it a design-time build or non-design-time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Extensions-Logging source-generator Indicates an issue with a source generator feature
Projects
None yet
Development

No branches or pull requests

3 participants