-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Refactor extensions and utilities in Workspaces layer into shared pro… #41510
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
Conversation
…jects Extracts out the changes to core Workspace changes from dotnet#41363.
|
@CyrusNajmabadi I believe this PR should be much easier to review. Even though large number of files are touched, most of them are moves or file splits. Breaking it down further is just too much pain and needs almost to redo the entire work step by step from scratch, which is not worth. |
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skipping this file. i will leave to mef people to look at :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is most likely a temporary approach for discovering language services in CodeStyle layer. #41462 tracks removal of MEF, and likely would need @jasonmalinowski or @sharwell to figure out a good non-MEF based solution to implement it.
...Workspace/Core/LanguageServices/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs
Show resolved
Hide resolved
...ensions/Workspace/VisualBasic/LanguageServices/VisualBasicRemoveUnnecessaryImportsService.vb
Show resolved
Hide resolved
src/CodeStyle/CSharp/Analyzers/Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj
Show resolved
Hide resolved
src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.MefHostExportProvider.cs
Outdated
Show resolved
Hide resolved
|
Will try to review this tonight (unless you'd like me to hold off). LMK what your pref is. |
| <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\Debug.cs" Link="Formatting\Debug.cs" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these linked files moved into shared project now.
| <Compile Include="..\..\..\Workspaces\Core\Portable\Shared\Collections\IIntervalIntrospector.cs" Link="Formatting\Context\IIntervalIntrospector.cs" /> | ||
| <Compile Include="..\..\..\Workspaces\Core\Portable\Shared\Collections\IntervalTree`1.cs" Link="Formatting\Context\IntervalTree`1.cs" /> | ||
| <Compile Include="..\..\..\Workspaces\Core\Portable\Shared\Collections\IntervalTree`1.Node.cs" Link="Formatting\Context\IntervalTree`1.Node.cs" /> | ||
| <Compile Include="..\..\..\Workspaces\Core\Portable\Shared\Collections\SimpleIntervalTree.cs" Link="Formatting\SimpleIntervalTree.cs" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is scope to move more utilities down to the shared layer in future.
|
|
||
| var solution = await fixAllService.GetFixAllChangedSolutionAsync( | ||
| fixCollection.FixAllState.CreateFixAllContext(progressTracker, cancellationToken)).ConfigureAwait(false); | ||
| new FixAllContext(fixCollection.FixAllState, progressTracker, cancellationToken)).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateFixAllContext was inlined here as the FixAllState.cs has been moved to the shared layer, but creating a new FixAllContext is only required from IDE code fix service engine and test layer.
src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs
Show resolved
Hide resolved
| Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions | ||
| Partial Friend Module SemanticModelExtensions | ||
|
|
||
| Private Const s_defaultParameterName = "p" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All existing code that was just moved as is.
| End Get | ||
| End Property | ||
|
|
||
| Public Overrides Async Function RemoveUnnecessaryImportsAsync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing code that was just moved.
| Imports Microsoft.CodeAnalysis.VisualBasic.Syntax | ||
|
|
||
| Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification | ||
| Friend Module VisualBasicSimplificationHelpers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing code extracted out into a shared module.
| Imports Microsoft.CodeAnalysis.VisualBasic.Syntax | ||
|
|
||
| Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions | ||
| Partial Friend Module SyntaxNodeExtensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into shared layer in existing extension method file
| @@ -61,29 +61,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification | |||
| End Using | |||
| End Function | |||
|
|
|||
| Public Shared Function TryEscapeIdentifierToken(identifierToken As SyntaxToken) As SyntaxToken | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into extension method file.
Thanks, that would be great! I will try my best to see what all pieces can be threaded out. Hoping that once this PR merged in, it allows further refactoring like your PRs to move further code down and reduces chances of merge conflicts. |
| } | ||
|
|
||
| #if WORKSPACE | ||
| #if CODE_STYLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dotnet/roslyn-compiler The only changes to compiler layer are in 3 files: this one and the 2 that follow. The changes are just adding a new #if CODE_STYLE for these utility types that are now also included in the CodeStyle layer.
jaredpar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
|
Approved the three changes to the Compiler layer |
tmat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this is just a subset of he original PR, which LGTM.
Yes, it just extracts out the Workspace related pieces from that PR. |
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ICompilationExtensions.cs
Show resolved
Hide resolved
...es/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems
Outdated
Show resolved
Hide resolved
...ndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs
Show resolved
Hide resolved
src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs
Show resolved
Hide resolved
...e/Portable/Completion/Providers/ImportCompletionProvider/AbstractImportCompletionProvider.cs
Show resolved
Hide resolved
...iesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs
Show resolved
Hide resolved
...CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
Show resolved
Hide resolved
src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs
Show resolved
Hide resolved
...Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
Outdated
Show resolved
Hide resolved
...Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
Outdated
Show resolved
Hide resolved
| Protected Overrides Function MergeImports(unnecessaryImports As ImmutableArray(Of SyntaxNode)) As ImmutableArray(Of SyntaxNode) | ||
| Dim result = ArrayBuilder(Of SyntaxNode).GetInstance() | ||
| Dim importsClauses = unnecessaryImports.CastArray(Of ImportsClauseSyntax) | ||
| Dim importsClauses = unnecessaryImports.ToImmutableHashSet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo if not necessary.
src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs
Outdated
Show resolved
Hide resolved
...tilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicAddImportsService.vb
Show resolved
Hide resolved
|
So overall i skimmed. files that were pure-add/pure-delete were skipped as i assume those represent the extension-method moves. I'm a littel wary of how much i had to skip as there might have been relevant code in there tat i just didn't see. However, overall, this seems like a very safe, very reasonable change to make. i highly doubt anything bad is sneaking in. And, if there is any issues hwere, i think we're likely to discover it immediately. I would ask that we file some issues to ensure proper cleanup happens in future PRs coming in the next couple of weeks. Also, i left a few final comments on things we might want to look into in this PR. |
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is good enough that i feel ok taking as is.
My personal feedback though is that in the future we should try harder up front to break up these changes into more manageable pieces. There are still several changes here that i think would have been better to break out just to build confidence and assurance that the big changes weren't potentially doing anything that required review with a fine-toothed comb.
Thanks!
|
Sync'ed with @sharwell offline, and he is fine with going ahead with this merge. Lets get to the follow-up items soon. |
…jects
Extracts out the changes to core Workspace layer from #41363.
Changes that were undone from #41363 for easier review: