Avoid SubType fighting in multi-target projects#6567
Merged
1 commit merged intodotnet:masterfrom Sep 1, 2020
Merged
Conversation
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
commented
Sep 1, 2020
...rojectSystem.Managed/ProjectSystem/LanguageServices/Handlers/ProjectPropertiesItemHandler.cs
Show resolved
Hide resolved
davkean
commented
Sep 1, 2020
...ctSystem/LanguageServices/WorkspaceProjectContextHost.WorkspaceProjectContextHostInstance.cs
Show resolved
Hide resolved
drewnoakes
approved these changes
Sep 1, 2020
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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":
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