Browse Source

Fixed SD2-982: Autogenerated interface code adds property setter when only getter defined

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1873 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
c1021f1393
  1. 2
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs
  2. 4
      src/Libraries/NRefactory/Project/Src/Ast/Generated.cs
  3. 6
      src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs
  4. 18
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs

2
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs

@ -185,7 +185,7 @@ namespace NRefactoryASTGenerator.Ast @@ -185,7 +185,7 @@ namespace NRefactoryASTGenerator.Ast
[IncludeBoolProperty("IsReadOnly", "return HasGetRegion && !HasSetRegion;")]
[IncludeBoolProperty("IsWriteOnly", "return !HasGetRegion && HasSetRegion;")]
[IncludeMember(@"
public PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List<AttributeSection> attributes) : this(modifier, attributes, name, null)
internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List<AttributeSection> attributes) : this(modifier, attributes, name, null)
{
this.TypeReference = typeReference;
if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) {

4
src/Libraries/NRefactory/Project/Src/Ast/Generated.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.88
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -3206,7 +3206,7 @@ namespace ICSharpCode.NRefactory.Ast { @@ -3206,7 +3206,7 @@ namespace ICSharpCode.NRefactory.Ast {
}
public PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List<AttributeSection> attributes) : this(modifier, attributes, name, null)
internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List<AttributeSection> attributes) : this(modifier, attributes, name, null)
{
this.TypeReference = typeReference;
if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) {

6
src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs

@ -313,6 +313,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -313,6 +313,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestTypeMember("public abstract bool ExpectsValue { set; }");
}
[Test]
public void SetOnlyProperty()
{
TestTypeMember("public bool ExpectsValue { set { DoSomething(value); } }");
}
[Test]
public void AbstractMethod()
{

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

@ -209,11 +209,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring @@ -209,11 +209,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
return md;
} else {
PropertyDeclaration md;
md = new PropertyDeclaration(p.Name,
ConvertType(p.ReturnType, targetContext),
ConvertModifier(p.Modifiers),
ConvertAttributes(p.Attributes, targetContext));
md.Parameters = ConvertParameters(p.Parameters, targetContext);
md = new PropertyDeclaration(ConvertModifier(p.Modifiers),
ConvertAttributes(p.Attributes, targetContext),
p.Name,
ConvertParameters(p.Parameters, targetContext));
md.TypeReference = ConvertType(p.ReturnType, targetContext);
if (p.CanGet) md.GetRegion = new PropertyGetRegion(CreateNotImplementedBlock(), null);
if (p.CanSet) md.SetRegion = new PropertySetRegion(CreateNotImplementedBlock(), null);
return md;
@ -325,9 +325,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring @@ -325,9 +325,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
public virtual PropertyDeclaration CreateProperty(IField field, bool createGetter, bool createSetter)
{
string name = GetPropertyName(field.Name);
PropertyDeclaration property = new PropertyDeclaration(name,
ConvertType(field.ReturnType, new ClassFinder(field)),
ConvertModifier(field.Modifiers), null);
PropertyDeclaration property = new PropertyDeclaration(ConvertModifier(field.Modifiers),
null,
name,
null);
property.TypeReference = ConvertType(field.ReturnType, new ClassFinder(field));
if (createGetter) {
BlockStatement block = new BlockStatement();
block.AddChild(new ReturnStatement(new IdentifierExpression(field.Name)));

Loading…
Cancel
Save