Browse Source

Fixed SD2-1169: Implementing an interface containing an event produces invalid code

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2033 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
4ba9c28c71
  1. 18
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs
  2. 7
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs

18
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs

@ -169,6 +169,15 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
/// <summary>
/// Gets if events explicitly implementing an interface require add {} remove {} regions.
/// </summary>
public virtual bool RequiresAddRemoveRegionInExplicitInterfaceImplementation {
get {
return false;
}
}
/// <summary> /// <summary>
/// Gets the token that denotes a possible beginning of an indexer expression. /// Gets the token that denotes a possible beginning of an indexer expression.
/// </summary> /// </summary>
@ -241,6 +250,15 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
/// <summary>
/// Gets if events explicitly implementing an interface require add {} remove {} regions.
/// </summary>
public override bool RequiresAddRemoveRegionInExplicitInterfaceImplementation {
get {
return true;
}
}
public override string ToString() public override string ToString()
{ {
return "[LanguageProperties: C#]"; return "[LanguageProperties: C#]";

7
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs

@ -453,6 +453,13 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
EventDeclaration ed = ConvertMember(e, context); EventDeclaration ed = ConvertMember(e, context);
if (explicitImpl) { if (explicitImpl) {
ed.InterfaceImplementations.Add(new InterfaceImplementation(interfaceReference, ed.Name)); ed.InterfaceImplementations.Add(new InterfaceImplementation(interfaceReference, ed.Name));
if (context.ProjectContent.Language.RequiresAddRemoveRegionInExplicitInterfaceImplementation) {
ed.AddRegion = new EventAddRegion(null);
ed.AddRegion.Block = CreateNotImplementedBlock();
ed.RemoveRegion = new EventRemoveRegion(null);
ed.RemoveRegion.Block = CreateNotImplementedBlock();
}
} }
ed.Modifier = modifier; ed.Modifier = modifier;
nodes.Add(ed); nodes.Add(ed);

Loading…
Cancel
Save