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)));