diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty.cs b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty.cs
index efcc8fb2ef..2cdc1b6d33 100644
--- a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty.cs
+++ b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty.cs
@@ -2,15 +2,24 @@
// 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 CodeProperty : CodeElement
{
+ IProperty property;
+ CodeElements attributes;
+
public CodeProperty()
{
}
+ public CodeProperty(IProperty property)
+ {
+ this.property = property;
+ }
+
public virtual vsCMAccess Access { get; set; }
public virtual CodeClass Parent {
@@ -18,7 +27,12 @@ namespace ICSharpCode.PackageManagement.EnvDTE
}
public virtual CodeElements Attributes {
- get { throw new NotImplementedException(); }
+ get {
+ if (attributes == null) {
+ attributes = new CodeAttributes(property);
+ }
+ return attributes;
+ }
}
public virtual CodeTypeRef Type {
diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty2.cs b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty2.cs
index abee151198..a455d73744 100644
--- a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty2.cs
+++ b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty2.cs
@@ -2,12 +2,14 @@
// 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 CodeProperty2 : CodeProperty
{
- public CodeProperty2()
+ public CodeProperty2(IProperty property)
+ : base(property)
{
}
diff --git a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
index aa70e15478..eecadffca6 100644
--- a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
+++ b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
@@ -78,6 +78,7 @@
+
@@ -89,6 +90,7 @@
+
diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeProperty2Tests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeProperty2Tests.cs
new file mode 100644
index 0000000000..f2daa59cf4
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeProperty2Tests.cs
@@ -0,0 +1,43 @@
+// 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.PackageManagement.EnvDTE;
+using NUnit.Framework;
+using PackageManagement.Tests.Helpers;
+
+namespace PackageManagement.Tests.EnvDTE
+{
+ [TestFixture]
+ public class CodeProperty2Tests
+ {
+ CodeProperty2 property;
+ PropertyHelper helper;
+
+ [SetUp]
+ public void Init()
+ {
+ helper = new PropertyHelper();
+ }
+
+ void CreateCodeProperty2()
+ {
+ property = new CodeProperty2(helper.Property);
+ }
+
+ [Test]
+ public void Attributes_PropertyHasOneAttribute_ReturnsOneAttribute()
+ {
+ helper.CreateProperty("MyProperty");
+ helper.AddAttribute("Tests.TestAttribute", "TestAttribute");
+ CreateCodeProperty2();
+
+ CodeElements attributes = property.Attributes;
+
+ CodeAttribute2 attribute = attributes.Item(1) as CodeAttribute2;
+
+ Assert.AreEqual(1, attributes.Count);
+ Assert.AreEqual("Tests.TestAttribute", attribute.FullName);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/PropertyHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/PropertyHelper.cs
new file mode 100644
index 0000000000..5f61a883a4
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/PropertyHelper.cs
@@ -0,0 +1,29 @@
+// 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 ICSharpCode.SharpDevelop.Dom;
+using Rhino.Mocks;
+
+namespace PackageManagement.Tests.Helpers
+{
+ public class PropertyHelper
+ {
+ public IProperty Property;
+ public List Attributes = new List();
+
+ public void CreateProperty(string name)
+ {
+ Property = MockRepository.GenerateMock();
+ Property.Stub(p => p.Attributes).Return(Attributes);
+ }
+
+ public void AddAttribute(string fullName, string shortName)
+ {
+ var attributeHelper = new AttributeHelper();
+ attributeHelper.CreateAttribute(fullName, shortName);
+ Attributes.Add(attributeHelper.Attribute);
+ }
+ }
+}