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

Move more code down to shared layer #74539

Merged

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Jul 24, 2024

Allows 'implement abstract class' to be a code fixer in the code-style layer.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 24, 2024
@CyrusNajmabadi CyrusNajmabadi changed the title WIP Move more code down to shared layer Jul 24, 2024
@CyrusNajmabadi CyrusNajmabadi requested a review from tmat July 24, 2024 19:57
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review July 24, 2024 20:02
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner July 24, 2024 20:02

namespace Microsoft.CodeAnalysis.ImplementInterface;

internal interface IImplementInterfaceInfo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was in a file related to implement-interface, which itself hasn't moved to this layer yet. that will be in followup pr.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought implement interface required a VS UI dialog - is that necessary to move to the code style layer? Is there any SDK tool that could use it?

@@ -61,7 +61,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)

protected override async Task<ISymbol> GenerateMemberAsync(ISymbol member, INamedTypeSymbol containingType, Document document, CompletionItem item, CancellationToken cancellationToken)
{
var syntaxFactory = document.GetLanguageService<SyntaxGenerator>();
var syntaxFactory = document.GetRequiredLanguageService<SyntaxGenerator>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ended up getting NRT warnings. not sure how htat started happening.

@@ -54,129 +54,6 @@ public static bool CompatibleSignatureToDelegate(this IMethodSymbol method, INam
return true;
}

public static IMethodSymbol RenameTypeParameters(this IMethodSymbol method, ImmutableArray<string> newNames)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helper extensions that moved to shared location

@@ -10,21 +10,6 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions;

internal static partial class IParameterSymbolExtensions
{
public static IParameterSymbol RenameParameter(this IParameterSymbol parameter, string parameterName)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helper extensions that moved to shared location

@@ -208,28 +208,6 @@ where SymbolEquivalenceComparer.Instance.Equals(explicitInterfaceMethod, constru
return type?.Accept(new UnnamedErrorTypeRemover(compilation));
}

[return: NotNullIfNotNull(parameterName: nameof(type))]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helper extensions that moved to shared location

/// Generates a call to a method *through* an existing field or property symbol.
/// </summary>
/// <returns></returns>
public static SyntaxNode GenerateDelegateThroughMemberStatement(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helper extensions that moved to shared location


internal static class CodeCleanupOptionsProviders
{
#if !CODE_STYLE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to shared location. was able to remove this IFDEF

@@ -63,40 +63,3 @@ internal static CodeAndImportGenerationOptions GetDefault(LanguageServices langu
};
#endif
}

internal static class CodeGenerationOptionsProviders
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to shared location. was able to remove this IFDEF

@@ -21,10 +21,8 @@ public static bool AllowImportsInHiddenRegions(this Document document)
=> document.Services.GetService<Host.ISpanMappingService>()?.SupportsMappingImportDirectives == true;
#endif

#if !CODE_STYLE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happyhapppy.


internal static class CodeCleanupOptionsProviders
{
public static CodeCleanupOptions GetCodeCleanupOptions(this IOptionsReader options, LanguageServices languageServices, bool? allowImportsInHiddenRegions = null)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a move.


internal static class CodeGenerationOptionsProviders
{
public static CodeGenerationOptions GetCodeGenerationOptions(this IOptionsReader options, LanguageServices languageServices)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a move.

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell is this impacted by the stuff you were looking at about code fixes in the SDK?

Should we be adding more shared code here if we still have issues with API changes between an older SDK and newer VS?

Reference #72811

Answered offline - this is tangential, moving to the code style layer still needs to happen to run code fixes in SDK tools like dotnet format.

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks fine - didn't take a close look at everything since it looks like mainly moves.


namespace Microsoft.CodeAnalysis.ImplementInterface;

internal interface IImplementInterfaceInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought implement interface required a VS UI dialog - is that necessary to move to the code style layer? Is there any SDK tool that could use it?


internal static partial class IMethodSymbolExtensions
{
public static IMethodSymbol EnsureNonConflictingNames(
Copy link
Member

@tmat tmat Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are odd methods to be extension methods for a very general interface in a non-specific namespace. Why not move these to CodeGenerationSymbolFactory or some other code-generation related type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't care for now. :)

@CyrusNajmabadi CyrusNajmabadi merged commit ed5fa5e into dotnet:main Jul 25, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the moveImplementAbstractClassToShared branch July 25, 2024 03:49
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 25, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 P1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants