From c1021f13937de0f395766696837b621f8f69f795 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 3 Oct 2006 17:20:29 +0000 Subject: [PATCH] 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 --- .../NRefactoryASTGenerator/AST/TypeLevel.cs | 2 +- .../NRefactory/Project/Src/Ast/Generated.cs | 4 ++-- .../Test/Output/CSharp/CSharpOutputTest.cs | 6 ++++++ .../Project/Src/Refactoring/CodeGenerator.cs | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs index 2fa3ccec79..c41956b4f9 100644 --- a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs @@ -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 attributes) : this(modifier, attributes, name, null) + internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List attributes) : this(modifier, attributes, name, null) { this.TypeReference = typeReference; if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) { diff --git a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs index 40895e6fbd..28beb0eff5 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // 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 { } - public PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List attributes) : this(modifier, attributes, name, null) + internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List attributes) : this(modifier, attributes, name, null) { this.TypeReference = typeReference; if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) { diff --git a/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs b/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs index 5a2c5949ca..00c461105c 100644 --- a/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs +++ b/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs @@ -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() { diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs index e48d3e0de5..e901b3dd04 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs @@ -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 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)));