diff options
25 files changed, 246 insertions, 48 deletions
diff --git a/Mono.Addins/ChangeLog b/Mono.Addins/ChangeLog index 119c163..1e76484 100644 --- a/Mono.Addins/ChangeLog +++ b/Mono.Addins/ChangeLog @@ -1,3 +1,24 @@ +2010-05-21 Lluis Sanchez Gual <lluis@novell.com> + + * Mono.Addins/ExtensionNode.cs: + * Mono.Addins/ExtensionTree.cs: Data extension points bound to + an attribute now generate nodes of type + ExtensionNode<TheAttribute> + + * Mono.Addins/Addin.cs: Added some docs. + + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins/ExtensionNodeAttribute.cs: + * Mono.Addins.Database/AddinUpdateData.cs: + * Mono.Addins.Description/ExtensionNodeType.cs: Changed name + of property (for consistency) + + * Mono.Addins/ExtensionPointAttribute.cs: Don't set a default + node name. The default name is assigned while scanning. + + * Mono.Addins.Database/DefaultAssemblyReflector.cs: This class + should not be public. + 2010-05-20 Lluis Sanchez Gual <lluis@novell.com> * Makefile.am: diff --git a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs index 9164ec1..a66f398 100644 --- a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs +++ b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs @@ -821,7 +821,7 @@ namespace Mono.Addins.Database ep.Description = ext.Description; ep.Name = ext.Name; ExtensionNodeType nt = ep.AddExtensionNode (ext.NodeName, ext.NodeTypeName); - nt.CustomAttributeTypeName = ext.ExtensionAttributeTypeName; + nt.ExtensionAttributeTypeName = ext.ExtensionAttributeTypeName; } } @@ -917,7 +917,7 @@ namespace Mono.Addins.Database } nt.Id = epa.NodeName; nt.TypeName = epa.NodeType.FullName; - nt.CustomAttributeTypeName = epa.ExtensionAttributeTypeName; + nt.ExtensionAttributeTypeName = epa.ExtensionAttributeTypeName; ep.NodeSet.NodeTypes.Add (nt); ep.Description = epa.Description; ep.Name = epa.Name; @@ -959,8 +959,8 @@ namespace Mono.Addins.Database nt.Id = nodeAtt.NodeName; if (nt.Description.Length == 0 && nodeAtt.Description.Length > 0) nt.Description = nodeAtt.Description; - if (nt.CustomAttributeTypeName.Length == 0 && nodeAtt.CustomAttributeTypeName.Length > 0) - nt.CustomAttributeTypeName = nodeAtt.CustomAttributeTypeName; + if (nt.ExtensionAttributeTypeName.Length == 0 && nodeAtt.ExtensionAttributeTypeName.Length > 0) + nt.ExtensionAttributeTypeName = nodeAtt.ExtensionAttributeTypeName; } else { // Use the node type name as default name if (nt.Id.Length == 0) diff --git a/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs b/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs index 20b674c..ce4272d 100644 --- a/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs +++ b/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs @@ -132,11 +132,11 @@ namespace Mono.Addins.Database } list.Add (ep); } - if (nt.CustomAttributeTypeName.Length > 0) { + if (nt.ExtensionAttributeTypeName.Length > 0) { List<ExtensionNodeType> list; - if (!customAttributeTypeExtensions.TryGetValue (nt.CustomAttributeTypeName, out list)) { + if (!customAttributeTypeExtensions.TryGetValue (nt.ExtensionAttributeTypeName, out list)) { list = new List<ExtensionNodeType> (); - customAttributeTypeExtensions [nt.CustomAttributeTypeName] = list; + customAttributeTypeExtensions [nt.ExtensionAttributeTypeName] = list; } list.Add (nt); } diff --git a/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs b/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs index 9cf7bfe..b835f8a 100644 --- a/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs +++ b/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs @@ -32,9 +32,7 @@ using System.Collections.Generic; namespace Mono.Addins.Database { - - - public class DefaultAssemblyReflector: IAssemblyReflector + class DefaultAssemblyReflector: IAssemblyReflector { public void Initialize (IAssemblyLocator locator) { diff --git a/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs b/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs index 7a886b6..3fb48e9 100644 --- a/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs +++ b/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs @@ -37,6 +37,9 @@ using Mono.Addins.Serialization; namespace Mono.Addins.Description { + /// <summary> + /// An extension node type definition. + /// </summary> public sealed class ExtensionNodeType: ExtensionNodeSet { string typeName; @@ -87,35 +90,49 @@ namespace Mono.Addins.Description set { addinId = value; } } - // Type of the extension node + /// <summary> + /// Type of the extension node. + /// </summary> public string TypeName { get { return typeName != null ? typeName : string.Empty; } set { typeName = value; } } + /// <summary> + /// Element name to be used when defining an extension in an XML manifest. The default name is "Type". + /// </summary> public string NodeName { get { return Id; } set { Id = value; } } - // Type of the object that the extension creates (only valid for TypeNodeExtension). + /// <summary> + /// Type of the object that the extension creates (only valid for TypeNodeExtension). + /// </summary> public string ObjectTypeName { get { return objectTypeName != null ? objectTypeName : string.Empty; } set { objectTypeName = value; } } - // Name of the custom attribute that can be used to declare nodes of this type - public string CustomAttributeTypeName { + /// <summary> + /// Name of the custom attribute that can be used to declare nodes of this type + /// </summary> + public string ExtensionAttributeTypeName { get { return customAttributeTypeName ?? string.Empty; } set { customAttributeTypeName = value; } } - // The description + /// <summary> + /// Long description of the node type + /// </summary> public string Description { get { return description != null ? description : string.Empty; } set { description = value; } } + /// <summary> + /// Attributes supported by the extension node type. + /// </summary> public NodeTypeAttributeCollection Attributes { get { if (attributes == null) { @@ -205,8 +222,8 @@ namespace Mono.Addins.Description else Element.RemoveAttribute ("objectType"); - if (CustomAttributeTypeName.Length > 0) - Element.SetAttribute ("customAttributeType", CustomAttributeTypeName); + if (ExtensionAttributeTypeName.Length > 0) + Element.SetAttribute ("customAttributeType", ExtensionAttributeTypeName); else Element.RemoveAttribute ("customAttributeType"); diff --git a/Mono.Addins/Mono.Addins/Addin.cs b/Mono.Addins/Mono.Addins/Addin.cs index 47c62e1..d11c30d 100644 --- a/Mono.Addins/Mono.Addins/Addin.cs +++ b/Mono.Addins/Mono.Addins/Addin.cs @@ -37,6 +37,9 @@ using Mono.Addins.Database; namespace Mono.Addins { + /// <summary> + /// An add-in. + /// </summary> public class Addin { AddinInfo addin; @@ -51,6 +54,9 @@ namespace Mono.Addins configFile = file; } + /// <summary> + /// Full identifier of the add-in, including namespace and version. + /// </summary> public string Id { get { if (configFile != null) @@ -59,14 +65,23 @@ namespace Mono.Addins } } + /// <summary> + /// Namespace of the add-in. + /// </summary> public string Namespace { get { return this.AddinInfo.Namespace; } } + /// <summary> + /// Identifier of the add-in (without namespace) + /// </summary> public string LocalId { get { return this.AddinInfo.LocalId; } } + /// <summary> + /// Version of the add-in + /// </summary> public string Version { get { return this.AddinInfo.Version; } } @@ -79,6 +94,18 @@ namespace Mono.Addins get { return Path.Combine (database.AddinPrivateDataPath, Path.GetFileNameWithoutExtension (Description.FileName)); } } + /// <summary> + /// Checks version compatibility. + /// </summary> + /// <param name="version"> + /// An add-in version. + /// </param> + /// <returns> + /// True if the provided version is compatible with this add-in. + /// </returns> + /// <remarks> + /// This method checks the CompatVersion property to know if the provided version is compatible with the version of this add-in. + /// </remarks> public bool SupportsVersion (string version) { return AddinInfo.SupportsVersion (version); @@ -102,6 +129,17 @@ namespace Mono.Addins } } + /// <summary> + /// Gets or sets the enabled status of the add-in. + /// </summary> + /// <remarks> + /// This property can be used to enable or disable an add-in. + /// The enabled status of an add-in is stored in the add-in registry, + /// so when an add-in is disabled, it will be disabled for all applications + /// sharing the same registry. + /// When an add-in is enabled or disabled, the extension points currently loaded + /// in memory will be properly updated to include or exclude extensions from the add-in. + /// </remarks> public bool Enabled { get { return AddinInfo.IsRoot ? true : database.IsAddinEnabled (Description.Domain, AddinInfo.Id, true); } set { @@ -112,10 +150,16 @@ namespace Mono.Addins } } + /// <summary> + /// Returns 'true' if the add-in is installed in the user's personal folder + /// </summary> public bool IsUserAddin { get { return configFile.StartsWith (Environment.GetFolderPath (Environment.SpecialFolder.Personal)); } } + /// <summary> + /// Path to the add-in file (it can be an assembly or a standalone XML manifest) + /// </summary> public string AddinFile { get { if (sourceFile == null && addin == null) @@ -137,6 +181,9 @@ namespace Mono.Addins } } + /// <summary> + /// Description of the add-in + /// </summary> public AddinDescription Description { get { if (desc != null) { diff --git a/Mono.Addins/Mono.Addins/ExtensionNode.cs b/Mono.Addins/Mono.Addins/ExtensionNode.cs index 39b93a9..a51fb2f 100644 --- a/Mono.Addins/Mono.Addins/ExtensionNode.cs +++ b/Mono.Addins/Mono.Addins/ExtensionNode.cs @@ -352,8 +352,14 @@ namespace Mono.Addins } } -/* public class ExtensionNode<T>: ExtensionNode where T:CustomExtensionAttribute + public class ExtensionNode<T>: ExtensionNode where T:CustomExtensionAttribute { - public T Data { get; internal set; } - }*/ + T data; + + [NodeAttribute] + public T Data { + get { return data; } + internal set { data = value; } + } + } } diff --git a/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs b/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs index eb24376..bf089a3 100644 --- a/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs +++ b/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs @@ -64,12 +64,12 @@ namespace Mono.Addins set { description = value; } } - public Type CustomAttributeType { + public Type ExtensionAttributeType { get { return customAttributeType; } set { customAttributeType = value; customAttributeTypeName = value.FullName; } } - internal string CustomAttributeTypeName { + internal string ExtensionAttributeTypeName { get { return customAttributeTypeName ?? string.Empty; } set { customAttributeTypeName = value; } } diff --git a/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs b/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs index 215548f..a4bd4b5 100644 --- a/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs +++ b/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs @@ -98,7 +98,7 @@ namespace Mono.Addins } public string NodeName { - get { return nodeName != null && nodeName.Length > 0 ? nodeName : "Type"; } + get { return nodeName != null && nodeName.Length > 0 ? nodeName : string.Empty; } set { nodeName = value; } } diff --git a/Mono.Addins/Mono.Addins/ExtensionTree.cs b/Mono.Addins/Mono.Addins/ExtensionTree.cs index 4bf0c34..45a2ecf 100644 --- a/Mono.Addins/Mono.Addins/ExtensionTree.cs +++ b/Mono.Addins/Mono.Addins/ExtensionTree.cs @@ -206,13 +206,16 @@ namespace Mono.Addins // If no type name is provided, use TypeExtensionNode by default if (ntype.TypeName == null || ntype.TypeName.Length == 0 || ntype.TypeName == typeof(TypeExtensionNode).FullName) { // If it has a custom attribute, use the generic version of TypeExtensionNode - if (ntype.CustomAttributeTypeName.Length > 0) { - Type attType = p.GetType (ntype.CustomAttributeTypeName, false); + if (ntype.ExtensionAttributeTypeName.Length > 0) { + Type attType = p.GetType (ntype.ExtensionAttributeTypeName, false); if (attType == null) { - addinEngine.ReportError ("Custom attribute type '" + ntype.CustomAttributeTypeName + "' not found.", ntype.AddinId, null, false); + addinEngine.ReportError ("Custom attribute type '" + ntype.ExtensionAttributeTypeName + "' not found.", ntype.AddinId, null, false); return false; } - ntype.Type = typeof(TypeExtensionNode<>).MakeGenericType (attType); + if (ntype.ObjectTypeName.Length > 0) + ntype.Type = typeof(TypeExtensionNode<>).MakeGenericType (attType); + else + ntype.Type = typeof(ExtensionNode<>).MakeGenericType (attType); } else { ntype.Type = typeof(TypeExtensionNode); return true; @@ -237,10 +240,10 @@ namespace Mono.Addins // get the member map for the attribute. if (boundAttributeType != null) { - if (ntype.CustomAttributeTypeName.Length == 0) + if (ntype.ExtensionAttributeTypeName.Length == 0) throw new InvalidOperationException ("Extension node not bound to a custom attribute."); - if (ntype.CustomAttributeTypeName != boundAttributeType.MemberType.FullName) - throw new InvalidOperationException ("Incorrect custom attribute type declaration in " + ntype.Type + ". Expected '" + ntype.CustomAttributeTypeName + "' found '" + boundAttributeType.MemberType.FullName + "'"); + if (ntype.ExtensionAttributeTypeName != boundAttributeType.MemberType.FullName) + throw new InvalidOperationException ("Incorrect custom attribute type declaration in " + ntype.Type + ". Expected '" + ntype.ExtensionAttributeTypeName + "' found '" + boundAttributeType.MemberType.FullName + "'"); fields = GetMembersMap (boundAttributeType.MemberType, out boundAttributeType); if (fields.Count > 0) diff --git a/Test/HelloWorldExtension/AttributeExtensions.cs b/Test/HelloWorldExtension/AttributeExtensions.cs index 2a32691..d211c12 100644 --- a/Test/HelloWorldExtension/AttributeExtensions.cs +++ b/Test/HelloWorldExtension/AttributeExtensions.cs @@ -30,3 +30,5 @@ using UnitTests; [assembly:TestNode ("test1", true, Id="t1")] [assembly:TestNode (Name="test2", Value=true, InsertAfter="t1")] +[assembly:SimpleExtension ("test3", true)] +[assembly:SimpleExtension ("test4", false)] diff --git a/Test/HelloWorldExtension/ChangeLog b/Test/HelloWorldExtension/ChangeLog index a045655..2161eb3 100644 --- a/Test/HelloWorldExtension/ChangeLog +++ b/Test/HelloWorldExtension/ChangeLog @@ -1,3 +1,7 @@ +2010-05-21 Lluis Sanchez Gual <lluis@novell.com> + + * AttributeExtensions.cs: Reorganized tests. + 2010-03-26 Lluis Sanchez Gual <lluis@novell.com> * Makefile.am: diff --git a/Test/UnitTests/ChangeLog b/Test/UnitTests/ChangeLog index 4de227f..d283599 100644 --- a/Test/UnitTests/ChangeLog +++ b/Test/UnitTests/ChangeLog @@ -1,3 +1,27 @@ +2010-05-21 Lluis Sanchez Gual <lluis@novell.com> + + * IWriter.cs: + * Makefile.am: + * TestEvents.cs: + * ExtensionModel: + * ComplexNode.cs: + * UnitTests.csproj: + * TestExtensions.cs: + * ISampleExtender.cs: + * NodeWithAttribute.cs: + * GlobalInfoCondition.cs: + * IWriterWithMetadata.cs: + * ParameterInfoCondition.cs: + * ExtensionModel/IWriter.cs: + * ExtensionModel/ComplexNode.cs: + * ExtensionModel/ISampleExtender.cs: + * ExtensionModel/NodeWithAttribute.cs: + * ExtensionModel/IWriterWithMetadata.cs: + * ExtensionModel/GlobalInfoCondition.cs: + * ExtensionModel/ParameterInfoCondition.cs: + * ExtensionModel/SimpleExtensionAttribute.cs: Reorganized + tests. + 2010-03-26 Lluis Sanchez Gual <lluis@novell.com> * IWriter.cs: diff --git a/Test/UnitTests/ComplexNode.cs b/Test/UnitTests/ExtensionModel/ComplexNode.cs index 10ae9c2..10ae9c2 100644 --- a/Test/UnitTests/ComplexNode.cs +++ b/Test/UnitTests/ExtensionModel/ComplexNode.cs diff --git a/Test/UnitTests/GlobalInfoCondition.cs b/Test/UnitTests/ExtensionModel/GlobalInfoCondition.cs index d80e637..d80e637 100644 --- a/Test/UnitTests/GlobalInfoCondition.cs +++ b/Test/UnitTests/ExtensionModel/GlobalInfoCondition.cs diff --git a/Test/UnitTests/ISampleExtender.cs b/Test/UnitTests/ExtensionModel/ISampleExtender.cs index bea0596..bea0596 100644 --- a/Test/UnitTests/ISampleExtender.cs +++ b/Test/UnitTests/ExtensionModel/ISampleExtender.cs diff --git a/Test/UnitTests/IWriter.cs b/Test/UnitTests/ExtensionModel/IWriter.cs index 22544cb..22544cb 100644 --- a/Test/UnitTests/IWriter.cs +++ b/Test/UnitTests/ExtensionModel/IWriter.cs diff --git a/Test/UnitTests/IWriterWithMetadata.cs b/Test/UnitTests/ExtensionModel/IWriterWithMetadata.cs index 786dc39..e525b48 100644 --- a/Test/UnitTests/IWriterWithMetadata.cs +++ b/Test/UnitTests/ExtensionModel/IWriterWithMetadata.cs @@ -29,7 +29,7 @@ using Mono.Addins; namespace SimpleApp { - [TypeExtensionPoint (CustomAttributeType=typeof(WriterWithMetadataAttribute))] + [TypeExtensionPoint (ExtensionAttributeType=typeof(WriterWithMetadataAttribute))] public interface IWriterWithMetadata { string Write (); diff --git a/Test/UnitTests/NodeWithAttribute.cs b/Test/UnitTests/ExtensionModel/NodeWithAttribute.cs index 716e3db..5c86dd1 100644 --- a/Test/UnitTests/NodeWithAttribute.cs +++ b/Test/UnitTests/ExtensionModel/NodeWithAttribute.cs @@ -29,7 +29,7 @@ using Mono.Addins; namespace UnitTests { - [ExtensionNode (CustomAttributeType=typeof(TestNodeAttribute))] + [ExtensionNode (ExtensionAttributeType=typeof(TestNodeAttribute))] public class NodeWithAttribute: ExtensionNode { [NodeAttribute] diff --git a/Test/UnitTests/ParameterInfoCondition.cs b/Test/UnitTests/ExtensionModel/ParameterInfoCondition.cs index cd5b3dd..cd5b3dd 100644 --- a/Test/UnitTests/ParameterInfoCondition.cs +++ b/Test/UnitTests/ExtensionModel/ParameterInfoCondition.cs diff --git a/Test/UnitTests/ExtensionModel/SimpleExtensionAttribute.cs b/Test/UnitTests/ExtensionModel/SimpleExtensionAttribute.cs new file mode 100644 index 0000000..ea947b2 --- /dev/null +++ b/Test/UnitTests/ExtensionModel/SimpleExtensionAttribute.cs @@ -0,0 +1,54 @@ +// +// SimpleExtensionAttribute.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Mono.Addins; + +[assembly:ExtensionPoint ("/SimpleApp/DataExtensionWithAttribute", ExtensionAttributeType=typeof(UnitTests.SimpleExtensionAttribute))] + +namespace UnitTests +{ + [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=true)] + public class SimpleExtensionAttribute: CustomExtensionAttribute + { + public SimpleExtensionAttribute () + { + } + + public SimpleExtensionAttribute (string name, [NodeAttribute("value")] bool val) + { + Name = name; + Value = val; + } + + [NodeAttribute ("name")] + public string Name { get; set; } + + [NodeAttribute ("value")] + public bool Value; + } +} + diff --git a/Test/UnitTests/Makefile.am b/Test/UnitTests/Makefile.am index 44f25a5..ff92dcc 100644 --- a/Test/UnitTests/Makefile.am +++ b/Test/UnitTests/Makefile.am @@ -16,13 +16,14 @@ endif FILES = \ AddinInformationTests.cs \ - ComplexNode.cs \ - GlobalInfoCondition.cs \ - ISampleExtender.cs \ - IWriter.cs \ - IWriterWithMetadata.cs \ - NodeWithAttribute.cs \ - ParameterInfoCondition.cs \ + ExtensionModel/ComplexNode.cs \ + ExtensionModel/GlobalInfoCondition.cs \ + ExtensionModel/ISampleExtender.cs \ + ExtensionModel/IWriter.cs \ + ExtensionModel/IWriterWithMetadata.cs \ + ExtensionModel/NodeWithAttribute.cs \ + ExtensionModel/ParameterInfoCondition.cs \ + ExtensionModel/SimpleExtensionAttribute.cs \ TestBase.cs \ TestConditions.cs \ TestEvents.cs \ diff --git a/Test/UnitTests/TestEvents.cs b/Test/UnitTests/TestEvents.cs index e7ec8db..d744072 100644 --- a/Test/UnitTests/TestEvents.cs +++ b/Test/UnitTests/TestEvents.cs @@ -75,7 +75,8 @@ namespace UnitTests "/SimpleApp/Writers", "/SimpleApp.Core/TypeExtensions/SimpleApp.ISampleExtender", "/SimpleApp.Core/TypeExtensions/SimpleApp.IWriterWithMetadata", - "/SimpleApp/NodesWithAttribute" + "/SimpleApp/NodesWithAttribute", + "/SimpleApp/DataExtensionWithAttribute", }; InitChangedExtensionEvent (addinExtensions); @@ -174,7 +175,8 @@ namespace UnitTests "/SimpleApp/Writers", "/SimpleApp.Core/TypeExtensions/SimpleApp.ISampleExtender", "/SimpleApp.Core/TypeExtensions/SimpleApp.IWriterWithMetadata", - "/SimpleApp/NodesWithAttribute" + "/SimpleApp/NodesWithAttribute", + "/SimpleApp/DataExtensionWithAttribute", }; InitChangedExtensionEvent (addinExtensions); diff --git a/Test/UnitTests/TestExtensions.cs b/Test/UnitTests/TestExtensions.cs index da8fba5..0f97921 100644 --- a/Test/UnitTests/TestExtensions.cs +++ b/Test/UnitTests/TestExtensions.cs @@ -165,5 +165,20 @@ namespace UnitTests Assert.AreEqual ("meta2", n2.Data.Name, "t3"); Assert.AreEqual (2, n2.Data.Version, "t4"); } + + [Test()] + public void TestDataExtensionWithAttribute () + { + ExtensionNodeList nodes = AddinManager.GetExtensionNodes ("/SimpleApp/DataExtensionWithAttribute"); + Assert.AreEqual (2, nodes.Count, "Node count"); + ExtensionNode<SimpleExtensionAttribute> n1 = nodes [0] as ExtensionNode<SimpleExtensionAttribute>; + ExtensionNode<SimpleExtensionAttribute> n2 = nodes [1] as ExtensionNode<SimpleExtensionAttribute>; + Assert.IsNotNull (n1); + Assert.IsNotNull (n2); + Assert.AreEqual ("test3", n1.Data.Name, "t1"); + Assert.AreEqual (true, n1.Data.Value, "t2"); + Assert.AreEqual ("test4", n2.Data.Name, "t1"); + Assert.AreEqual (false, n2.Data.Value, "t2"); + } } } diff --git a/Test/UnitTests/UnitTests.csproj b/Test/UnitTests/UnitTests.csproj index 8601380..731ef33 100644 --- a/Test/UnitTests/UnitTests.csproj +++ b/Test/UnitTests/UnitTests.csproj @@ -49,17 +49,18 @@ <Compile Include="TestBase.cs" /> <Compile Include="TestEvents.cs" /> <Compile Include="TestLoadUnload.cs" /> - <Compile Include="GlobalInfoCondition.cs" /> - <Compile Include="ParameterInfoCondition.cs" /> <Compile Include="TestConditions.cs" /> <Compile Include="TestSetup.cs" /> - <Compile Include="ISampleExtender.cs" /> - <Compile Include="ComplexNode.cs" /> - <Compile Include="IWriter.cs" /> <Compile Include="TestLocalization.cs" /> <Compile Include="AddinInformationTests.cs" /> - <Compile Include="NodeWithAttribute.cs" /> - <Compile Include="IWriterWithMetadata.cs" /> + <Compile Include="ExtensionModel\ComplexNode.cs" /> + <Compile Include="ExtensionModel\GlobalInfoCondition.cs" /> + <Compile Include="ExtensionModel\ISampleExtender.cs" /> + <Compile Include="ExtensionModel\IWriter.cs" /> + <Compile Include="ExtensionModel\IWriterWithMetadata.cs" /> + <Compile Include="ExtensionModel\NodeWithAttribute.cs" /> + <Compile Include="ExtensionModel\ParameterInfoCondition.cs" /> + <Compile Include="ExtensionModel\SimpleExtensionAttribute.cs" /> </ItemGroup> <ItemGroup> <Content Include="SimpleApp.addin.xml"> @@ -89,4 +90,7 @@ </Properties> </MonoDevelop> </ProjectExtensions> + <ItemGroup> + <Folder Include="ExtensionModel\" /> + </ItemGroup> </Project>
\ No newline at end of file |