Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: icsharpcode/SharpDevelop
...
head fork: icsharpcode/SharpDevelop
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
2  src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj
@@ -91,8 +91,10 @@
<Compile Include="Src\EnvDTE\CodeModel.cs" />
<Compile Include="Src\EnvDTE\CodeModelLanguageConstants.cs" />
<Compile Include="Src\EnvDTE\CodeNamespace.cs" />
+ <Compile Include="Src\EnvDTE\CodeParameter.cs" />
<Compile Include="Src\EnvDTE\CodeProperty.cs" />
<Compile Include="Src\EnvDTE\CodeProperty2.cs" />
+ <Compile Include="Src\EnvDTE\CodePropertyParameters.cs" />
<Compile Include="Src\EnvDTE\CodeStruct.cs" />
<Compile Include="Src\EnvDTE\CodeType.cs" />
<Compile Include="Src\EnvDTE\CodeTypeBaseTypes.cs" />
View
22 src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeParameter.cs
@@ -0,0 +1,22 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.SharpDevelop.Dom;
+
+namespace ICSharpCode.PackageManagement.EnvDTE
+{
+ public class CodeParameter : CodeElement
+ {
+ IParameter parameter;
+
+ public CodeParameter(IParameter parameter)
+ {
+ this.parameter = parameter;
+ }
+
+ public override string Name {
+ get { return parameter.Name; }
+ }
+ }
+}
View
9 src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty.cs
@@ -8,7 +8,6 @@ namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeProperty : CodeElement
{
- IProperty property;
CodeElements attributes;
public CodeProperty()
@@ -18,22 +17,24 @@ public CodeProperty()
public CodeProperty(IProperty property)
: base(property)
{
- this.property = property;
+ this.Property = property;
}
+ protected IProperty Property { get; private set; }
+
public virtual vsCMAccess Access {
get { return GetAccess(); }
set { }
}
public virtual CodeClass Parent {
- get { return new CodeClass(property.ProjectContent, property.DeclaringType); }
+ get { return new CodeClass(Property.ProjectContent, Property.DeclaringType); }
}
public virtual CodeElements Attributes {
get {
if (attributes == null) {
- attributes = new CodeAttributes(property);
+ attributes = new CodeAttributes(Property);
}
return attributes;
}
View
16 src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty2.cs
@@ -17,16 +17,22 @@ public CodeProperty2(IProperty property)
{
}
- public CodeElements Members {
- get { throw new NotImplementedException(); }
+ public vsCMPropertyKind ReadWrite {
+ get { return GetPropertyKind(); }
}
- public vsCMPropertyKind ReadWrite {
- get { throw new NotImplementedException(); }
+ vsCMPropertyKind GetPropertyKind()
+ {
+ if (Property.CanSet && Property.CanGet) {
+ return vsCMPropertyKind.vsCMPropertyKindReadWrite;
+ } else if (Property.CanSet) {
+ return vsCMPropertyKind.vsCMPropertyKindWriteOnly;
+ }
+ return vsCMPropertyKind.vsCMPropertyKindReadOnly;
}
public CodeElements Parameters {
- get { throw new NotImplementedException(); }
+ get { return new CodePropertyParameters(Property); }
}
}
}
View
31 src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodePropertyParameters.cs
@@ -0,0 +1,31 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.SharpDevelop.Dom;
+
+namespace ICSharpCode.PackageManagement.EnvDTE
+{
+ public class CodePropertyParameters : CodeElementsList
+ {
+ IProperty property;
+
+ public CodePropertyParameters(IProperty property)
+ {
+ this.property = property;
+ AddParameters();
+ }
+
+ void AddParameters()
+ {
+ foreach (IParameter parameter in property.Parameters) {
+ AddParameters(parameter);
+ }
+ }
+
+ void AddParameters(IParameter parameter)
+ {
+ AddCodeElement(new CodeParameter(parameter));
+ }
+ }
+}
View
3  src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/vsCMPropertyKind.cs
@@ -7,7 +7,8 @@ namespace ICSharpCode.PackageManagement.EnvDTE
{
public enum vsCMPropertyKind
{
+ vsCMPropertyKindReadWrite = 0,
vsCMPropertyKindReadOnly = 1,
- vsCMPropertyKindWriteOnly = 2
+ vsCMPropertyKindWriteOnly = 2,
}
}
View
36 src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeProperty2Tests.cs
@@ -84,5 +84,41 @@ public void Access_PrivateProperty_AccessIsPrivate()
Assert.AreEqual(vsCMAccess.vsCMAccessPrivate, access);
}
+
+ [Test]
+ public void ReadWrite_PropertyHasGetterAndSetter_ReturnsReadWriteProperty()
+ {
+ helper.CreatePublicProperty("MyProperty");
+ helper.HasGetterAndSetter();
+ CreateCodeProperty2();
+
+ vsCMPropertyKind kind = property.ReadWrite;
+
+ Assert.AreEqual(vsCMPropertyKind.vsCMPropertyKindReadWrite, kind);
+ }
+
+ [Test]
+ public void ReadWrite_PropertyHasGetterOnly_ReturnsReadOnlyProperty()
+ {
+ helper.CreatePublicProperty("MyProperty");
+ helper.HasGetterOnly();
+ CreateCodeProperty2();
+
+ vsCMPropertyKind kind = property.ReadWrite;
+
+ Assert.AreEqual(vsCMPropertyKind.vsCMPropertyKindReadOnly, kind);
+ }
+
+ [Test]
+ public void ReadWrite_PropertyHasSetterOnly_ReturnsWriteOnlyProperty()
+ {
+ helper.CreatePublicProperty("MyProperty");
+ helper.HasSetterOnly();
+ CreateCodeProperty2();
+
+ vsCMPropertyKind kind = property.ReadWrite;
+
+ Assert.AreEqual(vsCMPropertyKind.vsCMPropertyKindWriteOnly, kind);
+ }
}
}
View
82 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/CodeElementsExtensions.cs
@@ -0,0 +1,82 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using ICSharpCode.PackageManagement.EnvDTE;
+
+namespace PackageManagement.Tests.Helpers
+{
+ public static class CodeElementsExtensions
+ {
+ public static List<CodeElement> ToList(this CodeElements codeElements)
+ {
+ var list = new List<CodeElement>();
+ foreach (CodeElement codeElement in codeElements) {
+ list.Add(codeElement);
+ }
+ return list;
+ }
+
+ public static CodeElement FirstOrDefault(this CodeElements codeElements)
+ {
+ return ToList(codeElements).FirstOrDefault();
+ }
+
+ public static CodeFunction FirstCodeFunctionOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeFunction;
+ }
+
+ public static CodeClass2 FirstCodeClass2OrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeClass2;
+ }
+
+ public static CodeInterface FirstCodeInterfaceOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeInterface;
+ }
+
+ public static CodeAttributeArgument FirstCodeAttributeArgumentOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeAttributeArgument;
+ }
+
+ public static CodeNamespace FirstCodeNamespaceOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeNamespace;
+ }
+
+ public static CodeNamespace LastCodeNamespaceOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.LastOrDefault() as CodeNamespace;
+ }
+
+ public static CodeElement LastOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.ToList().LastOrDefault();
+ }
+
+ public static CodeAttribute2 FirstCodeAttribute2OrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeAttribute2;
+ }
+
+ public static CodeProperty2 FirstCodeProperty2OrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeProperty2;
+ }
+
+ public static CodeVariable FirstCodeVariableOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeVariable;
+ }
+
+ public static CodeParameter FirstCodeParameterOrDefault(this CodeElements codeElements)
+ {
+ return codeElements.FirstOrDefault() as CodeParameter;
+ }
+ }
+}
View
26 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/PropertyHelper.cs
@@ -50,5 +50,31 @@ public void CreatePrivateProperty(string name)
Property.Stub(p => p.IsPublic).Return(false);
Property.Stub(p => p.IsPrivate).Return(true);
}
+
+ public void HasGetterAndSetter()
+ {
+ HasGetter = true;
+ HasSetter = true;
+ }
+
+ public bool HasSetter {
+ set { Property.Stub(p => p.CanSet).Return(value); }
+ }
+
+ public bool HasGetter {
+ set { Property.Stub(p => p.CanGet).Return(value); }
+ }
+
+ public void HasGetterOnly()
+ {
+ HasGetter = true;
+ HasSetter = false;
+ }
+
+ public void HasSetterOnly()
+ {
+ HasGetter = false;
+ HasSetter = true;
+ }
}
}

No commit comments for this range

Something went wrong with that request. Please try again.