diff options
author | Daniel Grunwald <daniel@danielgrunwald.de> | 2015-05-30 20:30:12 +0300 |
---|---|---|
committer | Daniel Grunwald <daniel@danielgrunwald.de> | 2015-05-30 20:30:12 +0300 |
commit | 3af570c381d98b9560f38058c728e0a97d918b07 (patch) | |
tree | a4855138d00cc1f29076ed03fb2e0110c8b33664 /ICSharpCode.NRefactory.Tests | |
parent | 4637c1f67229a51b97e1f7fa4c02fd76180ad38d (diff) |
Fix accessibility of properties overriding just one accessor.
Diffstat (limited to 'ICSharpCode.NRefactory.Tests')
-rw-r--r-- | ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs | 14 | ||||
-rw-r--r-- | ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs | 16 |
2 files changed, 28 insertions, 2 deletions
diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs index f8813f22..e612a732 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs @@ -251,11 +251,21 @@ namespace ICSharpCode.NRefactory.TypeSystem.TestCase } public class ClassWithVirtualProperty { - public virtual int Prop { get; set; } + public virtual int Prop { get; protected set; } } public class ClassThatOverridesAndSealsVirtualProperty : ClassWithVirtualProperty { - public sealed override int Prop { get; set; } + public sealed override int Prop { get; protected set; } + } + + public class ClassThatOverridesGetterOnly : ClassWithVirtualProperty + { + public override int Prop { get { return 1; } } + } + + public class ClassThatOverridesSetterOnly : ClassThatOverridesGetterOnly + { + public override int Prop { protected set { } } } public class ClassThatImplementsProperty : IInterfaceWithProperty { diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs index bf50ccbd..6135dc96 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs @@ -1048,6 +1048,22 @@ namespace ICSharpCode.NRefactory.TypeSystem } [Test] + public void ClassThatOverridesGetterOnly() { + ITypeDefinition type = GetTypeDefinition(typeof(ClassThatOverridesGetterOnly)); + var prop = type.Properties.Single(p => p.Name == "Prop"); + Assert.AreEqual(Accessibility.Public, prop.Accessibility); + Assert.AreEqual(Accessibility.Public, prop.Getter.Accessibility); + } + + [Test] + public void ClassThatOverridesSetterOnly() { + ITypeDefinition type = GetTypeDefinition(typeof(ClassThatOverridesSetterOnly)); + var prop = type.Properties.Single(p => p.Name == "Prop"); + Assert.AreEqual(Accessibility.Public, prop.Accessibility); + Assert.AreEqual(Accessibility.Protected, prop.Setter.Accessibility); + } + + [Test] public void PropertyAccessorsShouldBeReportedAsImplementingInterfaceAccessors() { ITypeDefinition type = GetTypeDefinition(typeof(ClassThatImplementsProperty)); var prop = type.Properties.Single(p => p.Name == "Prop"); |