public MoveStaticMembersOptions GetMoveMembersToTypeOptions(Document document, INamedTypeSymbol selectedType, ImmutableArray <ISymbol> selectedNodeSymbols) { if (!ExpectedPrecheckedMembers.IsEmpty) { // if we expect to have prechecked members and don't have the correct ones, error var actualPrecheckedMembers = selectedNodeSymbols.SelectAsArray(n => n.Name).Sort(); if (!ExpectedPrecheckedMembers.Sort().SequenceEqual(actualPrecheckedMembers)) { System.Diagnostics.Debug.Fail("Expected Prechecked members did not match recieved members"); var errMsg = string.Format("Expected: {0} \n Actual: {1}", ExpectedPrecheckedMembers, actualPrecheckedMembers); System.Diagnostics.Debug.Fail(errMsg); throw new InvalidOperationException(errMsg); } } 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)); }
public MoveStaticMembersOptions GetMoveMembersToTypeOptions(Document document, INamedTypeSymbol selectedType, ISymbol?selectedNodeSymbol) { var selectedMembers = selectedType.GetMembers().WhereAsArray(symbol => SelectedMembers.Contains(symbol.Name)); 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)); }