Skip to content

Avoid SubType fighting in multi-target projects#6567

Merged
1 commit merged intodotnet:masterfrom
davkean:ActiveProject
Sep 1, 2020
Merged

Avoid SubType fighting in multi-target projects#6567
1 commit merged intodotnet:masterfrom
davkean:ActiveProject

Conversation

@davkean
Copy link
Member

@davkean davkean commented Sep 1, 2020

Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/961596

Roslyn is responsible for applying SubType to Forms, Components and other types. In multi-targeted projects, the same file can have conflicting "sub types":

#if NET45
    class MyComponent : Form
#else
    class MyComponent : Component
#endif

This results Roslyn pushing "Form" when it encounters scans the first definition and "Component" when it encounters the second definition.
There is no guaranteed order to which one of these get scanned first, so this can result in the same source file having a different sub type every time Roslyn does analysis. Sub Type affects the designer and icon that a type gets, so this results in tree flickering between two different icons.

This was worse before #5880 as we'd see the sub type change and go back to Roslyn to add/remove the file, resulting in a constant churn. This longer occurs, but we still have the fighting sub type dance whenver the file content changes.

To fix this, Roslyn will now only scan the the primary context: dotnet/roslyn#44270.

This change plumbs through this property by finding the context that lives in the "active configuration" and passing this through to Roslyn.

Microsoft Reviewers: Open in CodeFlow

Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/961596

Roslyn is responsible for applying SubType to Forms, Components and other types. In multi-targeted projects, the same file can have conflicting "sub types":

#if NET45
    class MyComponent : Form
#else
    class MyComponent : Component
#endif

This results Roslyn pushing "Form" when it encounters scans the first definition and "Component" when it encounters the second definition.
There is no guaranteed order to which one of these get scanned first, so this can result in the same time having a different sub type every time Roslyn does analysis. Sub Type affects the designer and icon that a type gets, so this results in a type that flickers between two different icons.

This was worse before dotnet#5880 as we'd see the sub type change and go back to Roslyn to add/remove the file, resulting in a constant churn. This longer occurs, but we still have the fighting sub type dance whenver the file content changes.

To fix this, Roslyn will now only scan the the primary context: dotnet/roslyn#44270.

This change plumbs through this property by finding the context that lives in the "active configuration" and passing this through to Roslyn.
@davkean davkean requested a review from a team as a code owner September 1, 2020 07:03
@davkean davkean added the auto-merge Set on a PR to have msftbot merge once requirements are met. label Sep 1, 2020
@ghost ghost merged commit 2a88875 into dotnet:master Sep 1, 2020
@ghost ghost added this to the 16.8 milestone Sep 1, 2020
@davkean davkean deleted the ActiveProject branch September 1, 2020 08:34
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Set on a PR to have msftbot merge once requirements are met.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants