Browse Source

[CodeAction] Fixed bug in implement interface action.

newNRvisualizers
Mike Krüger 13 years ago
parent
commit
191c33d7b1
  1. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceAction.cs
  2. 89
      ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ImplementInterfaceTests.cs

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceAction.cs

@ -120,7 +120,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -120,7 +120,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
bool alreadyImplemented;
// Stub out non-implemented events defined by @iface
foreach (var evGroup in interfaceType.GetEvents (e => !e.IsSynthetic && e.DeclaringTypeDefinition.ReflectionName == def.ReflectionName).GroupBy (m => m.DeclaringType).Reverse ())
foreach (var evGroup in interfaceType.GetEvents (e => !e.IsSynthetic).GroupBy (m => m.DeclaringType).Reverse ())
foreach (var ev in evGroup) {
bool needsExplicitly = explicitly;
alreadyImplemented = implementingType.GetAllBaseTypeDefinitions().Any(
@ -153,7 +153,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -153,7 +153,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
}
// Stub out non-implemented properties defined by @iface
foreach (var propGroup in interfaceType.GetProperties (p => !p.IsSynthetic && p.DeclaringTypeDefinition.ReflectionName == def.ReflectionName).GroupBy (m => m.DeclaringType).Reverse ())
foreach (var propGroup in interfaceType.GetProperties (p => !p.IsSynthetic).GroupBy (m => m.DeclaringType).Reverse ())
foreach (var prop in propGroup) {
bool needsExplicitly = explicitly;
alreadyImplemented = false;

89
ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ImplementInterfaceTests.cs

@ -287,6 +287,95 @@ interface ITest { @@ -287,6 +287,95 @@ interface ITest {
void OnScenesAdded (params ITest[] scenes);
}
class Foo : $ITest
{
#region ITest implementation
public void OnScenesAdded (params ITest[] scenes)
{
throw new NotImplementedException ();
}
#endregion
}
");
}
/// <summary>
/// Bug 9117 - [3.0.5] C#: Implementing interfaces inheriting from other interfaces
/// </summary>
[Test()]
public void TestBug9117()
{
Test<ImplementInterfaceAction>(@"using System;
public interface IAncestor
{
string X { get; set; }
void DoThings();
}
public interface IDescendant: IAncestor
{
string Y { get; set; }
string Z { get; set; }
}
class Foo : $IDescendant
{
}
", @"using System;
public interface IAncestor
{
string X { get; set; }
void DoThings();
}
public interface IDescendant: IAncestor
{
string Y { get; set; }
string Z { get; set; }
}
class Foo : IDescendant
{
#region IAncestor implementation
public void DoThings ()
{
throw new NotImplementedException ();
}
public string X {
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
#endregion
#region IDescendant implementation
public string Y {
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
public string Z {
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
#endregion
}
");
TestWrongContext<ImplementInterfaceAction>(@"using System;
interface ITest {
void OnScenesAdded (params ITest[] scenes);
}
class Foo : $ITest
{
#region ITest implementation

Loading…
Cancel
Save