Skip to content

Commit 664c7d9

Browse files
committed
Correct default public interface extraction
1 parent e8fd573 commit 664c7d9

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Rubberduck.Core/UI/Refactorings/ExtractInterface/ExtractInterfaceViewModel.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Rubberduck.Parsing.Symbols;
88
using Rubberduck.Refactorings.ExtractInterface;
99
using Rubberduck.UI.Command;
10-
using System.Windows.Data;
1110

1211
namespace Rubberduck.UI.Refactorings
1312
{
@@ -70,8 +69,6 @@ public bool IsPrivateInterfaceEnabled
7069
}
7170
}
7271

73-
private readonly IValueConverter classInstancingConverter = new Converters.ClassInstancingToBooleanConverter();
74-
7572
private bool isPublicInterfaceChecked = true;
7673
public bool IsPublicInterfaceChecked
7774
{
@@ -83,7 +80,9 @@ public bool IsPublicInterfaceChecked
8380
return;
8481
}
8582

86-
Model.ImplementingClassInstancing = (ClassInstancing)classInstancingConverter.ConvertBack(value, null, null, null);
83+
Model.InterfaceInstancing = value
84+
? ClassInstancing.PublicNotCreatable
85+
: ClassInstancing.Private;
8786
isPublicInterfaceChecked = value;
8887
OnPropertyChanged();
8988
}

Rubberduck.Refactorings/ExtractInterface/ExtractInterfaceModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ public class ExtractInterfaceModel : IRefactoringModel
2020
public string InterfaceName { get; set; }
2121
public ObservableCollection<InterfaceMember> Members { get; set; } = new ObservableCollection<InterfaceMember>();
2222
public IEnumerable<InterfaceMember> SelectedMembers => Members.Where(m => m.IsSelected);
23-
public ClassInstancing ImplementingClassInstancing { get; set; }
23+
public ClassInstancing ImplementingClassInstancing => System.Convert.ToBoolean(TargetDeclaration.Attributes.ExposedAttribute.Values.First())
24+
? ClassInstancing.PublicNotCreatable
25+
: ClassInstancing.Private;
26+
public ClassInstancing InterfaceInstancing { get; set; } = ClassInstancing.PublicNotCreatable;
2427

2528
public static readonly DeclarationType[] MemberTypes =
2629
{
@@ -35,9 +38,6 @@ public ExtractInterfaceModel(IDeclarationFinderProvider declarationFinderProvide
3538
{
3639
TargetDeclaration = target;
3740
DeclarationFinderProvider = declarationFinderProvider;
38-
ImplementingClassInstancing = System.Convert.ToBoolean(target.Attributes.ExposedAttribute.Values.First())
39-
? ClassInstancing.PublicNotCreatable
40-
: ClassInstancing.Private;
4141

4242
if (TargetDeclaration == null)
4343
{

Rubberduck.Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private void AddInterface(ExtractInterfaceModel model)
9898
return; //The target project is not available.
9999
}
100100

101-
AddInterfaceClass(model.TargetDeclaration, model.InterfaceName, GetInterfaceModuleBody(model), model.ImplementingClassInstancing);
101+
AddInterfaceClass(model.TargetDeclaration, model.InterfaceName, GetInterfaceModuleBody(model), model.InterfaceInstancing);
102102

103103
var rewriteSession = RewritingManager.CheckOutCodePaneSession();
104104
var rewriter = rewriteSession.CheckOutModuleRewriter(model.TargetDeclaration.QualifiedModuleName);

0 commit comments

Comments
 (0)