Skip to content

Commit

Permalink
Revert "Add Move Static Member To Existing Type (#61519)"
Browse files Browse the repository at this point in the history
This reverts commit 74c3abe.
  • Loading branch information
ryzngard committed Jun 8, 2022
1 parent eec626d commit 6e46737
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 1,576 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

using System.Collections.Immutable;
using System.Composition;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.MoveStaticMembers;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.Test.Utilities.MoveStaticMembers
{
Expand All @@ -23,31 +20,23 @@ public TestMoveStaticMembersService()
{
}

public string? DestinationName { get; set; }
public string? DestinationType { get; set; }

public ImmutableArray<string> SelectedMembers { get; set; }

public string? Filename { get; set; }

public bool CreateNew { get; set; } = true;

public MoveStaticMembersOptions GetMoveMembersToTypeOptions(Document document, INamedTypeSymbol selectedType, ISymbol? selectedNodeSymbol)
{
var selectedMembers = selectedType.GetMembers().WhereAsArray(symbol => SelectedMembers.Contains(symbol.Name));
if (CreateNew)
{
var namespaceDisplay = selectedType.ContainingNamespace.IsGlobalNamespace
? string.Empty
: selectedType.ContainingNamespace.ToDisplayString();
// just return all the selected members
return new MoveStaticMembersOptions(
Filename!,
string.Join(".", namespaceDisplay, DestinationName!),
selectedMembers);
}

var destination = selectedType.ContainingNamespace.GetAllTypes(CancellationToken.None).First(t => t.ToDisplayString() == DestinationName);
return new MoveStaticMembersOptions(destination, selectedMembers);
var namespaceDisplay = selectedType.ContainingNamespace.IsGlobalNamespace
? string.Empty
: selectedType.ContainingNamespace.ToDisplayString();
// just return all the selected members
return new MoveStaticMembersOptions(
Filename!,
string.Join(".", namespaceDisplay, DestinationType!),
selectedMembers);
}
}
}
Loading

0 comments on commit 6e46737

Please sign in to comment.