From 343048884b10f0b2b6a086fa8615562cdabaaf9b Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 15:21:21 -0300 Subject: [PATCH 01/12] Update Example TargetFrameworks --- .../Autodesk.PackageBuilder.Example.csproj | 6 ++-- .../Autodesk.PackageBuilder.csproj | 1 + Build/.nuke/build.schema.json | 31 +++++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Autodesk.PackageBuilder.Examples/Autodesk.PackageBuilder.Example.csproj b/Autodesk.PackageBuilder.Examples/Autodesk.PackageBuilder.Example.csproj index 98adad9..56ae28d 100644 --- a/Autodesk.PackageBuilder.Examples/Autodesk.PackageBuilder.Example.csproj +++ b/Autodesk.PackageBuilder.Examples/Autodesk.PackageBuilder.Example.csproj @@ -1,10 +1,10 @@ - + Exe - net6.0 + net4.8;net6.0;net8.0 false - false + true diff --git a/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj b/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj index 021bdc6..b370c04 100644 --- a/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj +++ b/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj @@ -3,6 +3,7 @@ netstandard2.0 false + latest diff --git a/Build/.nuke/build.schema.json b/Build/.nuke/build.schema.json index 99ea92c..5568888 100644 --- a/Build/.nuke/build.schema.json +++ b/Build/.nuke/build.schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Build Schema", "$ref": "#/definitions/build", + "title": "Build Schema", "definitions": { "build": { "type": "object", @@ -13,6 +13,10 @@ "Folder": { "type": "string" }, + "GitHubToken": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, "Help": { "type": "boolean", "description": "Shows the help text for this build assembly" @@ -24,6 +28,7 @@ "AppVeyor", "AzurePipelines", "Bamboo", + "Bitbucket", "Bitrise", "GitHubActions", "GitLab", @@ -47,6 +52,14 @@ "type": "boolean", "description": "Disables displaying the NUKE logo" }, + "NugetApiKey": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "NugetApiUrl": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, "Partition": { "type": "string", "description": "Partition to use on CI" @@ -65,10 +78,24 @@ "ReleaseExample": { "type": "boolean" }, + "ReleaseFolder": { + "type": "string" + }, + "ReleaseNameVersion": { + "type": "boolean" + }, "Root": { "type": "string", "description": "Root directory during build execution" }, + "SignFile": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "SignPassword": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, "Skip": { "type": "array", "description": "List of targets to be skipped. Empty list skips all dependencies", @@ -120,4 +147,4 @@ } } } -} \ No newline at end of file +} From f6ba03f73f012869d6e196fa3cea22bb55e60daf Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 15:45:28 -0300 Subject: [PATCH 02/12] Create `Tests` project --- .../Autodesk.PackageBuilder.Tests.csproj | 18 +++++++++++ .../Constants/AutodeskProducts_Tests.cs | 31 +++++++++++++++++++ .../Constants/ProductTypes_Tests.cs | 19 ++++++++++++ Autodesk.PackageBuilder.Tests/Tests.cs | 13 ++++++++ Autodesk.PackageBuilder.sln | 10 ++++-- .../Autodesk.PackageBuilder.csproj | 2 +- Build/.nuke/build.schema.json | 15 +++++++-- Build/Build.cs | 2 +- CHANGELOG.md | 6 ++++ 9 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj create mode 100644 Autodesk.PackageBuilder.Tests/Constants/AutodeskProducts_Tests.cs create mode 100644 Autodesk.PackageBuilder.Tests/Constants/ProductTypes_Tests.cs create mode 100644 Autodesk.PackageBuilder.Tests/Tests.cs diff --git a/Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj b/Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj new file mode 100644 index 0000000..5f7ef3f --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj @@ -0,0 +1,18 @@ + + + + net48;net6.0;net8.0 + false + + + + + + + + + + + + + diff --git a/Autodesk.PackageBuilder.Tests/Constants/AutodeskProducts_Tests.cs b/Autodesk.PackageBuilder.Tests/Constants/AutodeskProducts_Tests.cs new file mode 100644 index 0000000..8a2b697 --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Constants/AutodeskProducts_Tests.cs @@ -0,0 +1,31 @@ +using NUnit.Framework; + +namespace Autodesk.PackageBuilder.Tests.Constants +{ + public class AutodeskProducts_Tests + { + [Test] + public void AutoCAD_Test() + { + Assert.AreEqual("AutoCAD", AutodeskProducts.AutoCAD); + } + + [Test] + public void Revit_Test() + { + Assert.AreEqual("Revit", AutodeskProducts.Revit); + } + + [Test] + public void Maya_Test() + { + Assert.AreEqual("Maya", AutodeskProducts.Maya); + } + + [Test] + public void Navisworks_Test() + { + Assert.AreEqual("Navisworks", AutodeskProducts.Navisworks); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Constants/ProductTypes_Tests.cs b/Autodesk.PackageBuilder.Tests/Constants/ProductTypes_Tests.cs new file mode 100644 index 0000000..1c162f8 --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Constants/ProductTypes_Tests.cs @@ -0,0 +1,19 @@ +using NUnit.Framework; + +namespace Autodesk.PackageBuilder.Tests.Constants +{ + public class ProductTypes_Tests + { + [Test] + public void Application_Test() + { + Assert.AreEqual("Application", ProductTypes.Application); + } + + [Test] + public void Content_Test() + { + Assert.AreEqual("Content", ProductTypes.Content); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Tests.cs b/Autodesk.PackageBuilder.Tests/Tests.cs new file mode 100644 index 0000000..d3ffb5a --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Tests.cs @@ -0,0 +1,13 @@ +using NUnit.Framework; + +namespace Autodesk.PackageBuilder.Tests +{ + public class Tests + { + [Test] + public void Test() + { + Assert.Pass(); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.sln b/Autodesk.PackageBuilder.sln index 5198932..ad09bca 100644 --- a/Autodesk.PackageBuilder.sln +++ b/Autodesk.PackageBuilder.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31911.196 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34316.72 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autodesk.PackageBuilder", "Autodesk.PackageBuilder\Autodesk.PackageBuilder.csproj", "{647FFB28-1412-45FC-989A-0EA93FB2378E}" EndProject @@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project", "Project", "{F716 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autodesk.PackageBuilder.Example", "Autodesk.PackageBuilder.Examples\Autodesk.PackageBuilder.Example.csproj", "{FFBDD53B-D4E9-458E-9DF0-E117295D1593}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autodesk.PackageBuilder.Tests", "Autodesk.PackageBuilder.Tests\Autodesk.PackageBuilder.Tests.csproj", "{AA0E5843-B360-4CB5-AE33-6F549E9EF394}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,6 +31,10 @@ Global {59542136-031D-4D65-959B-F4819E10FDA2}.Release|Any CPU.ActiveCfg = Release|Any CPU {FFBDD53B-D4E9-458E-9DF0-E117295D1593}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FFBDD53B-D4E9-458E-9DF0-E117295D1593}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA0E5843-B360-4CB5-AE33-6F549E9EF394}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA0E5843-B360-4CB5-AE33-6F549E9EF394}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA0E5843-B360-4CB5-AE33-6F549E9EF394}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA0E5843-B360-4CB5-AE33-6F549E9EF394}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj b/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj index b370c04..81d30b5 100644 --- a/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj +++ b/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj @@ -7,7 +7,7 @@ - 1.0.5 + 1.0.6 diff --git a/Build/.nuke/build.schema.json b/Build/.nuke/build.schema.json index 5568888..a0854f5 100644 --- a/Build/.nuke/build.schema.json +++ b/Build/.nuke/build.schema.json @@ -109,7 +109,8 @@ "GitRelease", "Pack", "Release", - "Sign" + "Sign", + "Test" ] } }, @@ -130,10 +131,20 @@ "GitRelease", "Pack", "Release", - "Sign" + "Sign", + "Test" ] } }, + "TestBuildStopWhenFailed": { + "type": "boolean" + }, + "TestProjectName": { + "type": "string" + }, + "TestResults": { + "type": "boolean" + }, "Verbosity": { "type": "string", "description": "Logging verbosity during build execution. Default is 'Normal'", diff --git a/Build/Build.cs b/Build/Build.cs index 26ca27d..fb1c8e4 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -3,7 +3,7 @@ using ricaun.Nuke; using ricaun.Nuke.Components; -partial class Build : NukeBuild, IPublishPack, ICompileExample +partial class Build : NukeBuild, IPublishPack, ICompileExample, ITest { public static int Main() => Execute(x => x.From().Build); } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 063f02e..b93b93e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.0.6] / 2023-11-24 +### Features +- `Tests` project. +### Tests +- Test `Constants` + ## [1.0.5] / 2021-12-21 - Update Build Project - 2021-12-21 From 5e5c05a32dbd7bd0b9bd2b7ff58dfc704d84acf2 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 15:50:48 -0300 Subject: [PATCH 03/12] Update Build.yml --- .github/workflows/Build.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index d9469c7..57e149f 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -19,15 +19,6 @@ jobs: steps: - uses: actions/checkout@v1 - - name: NuGet Setup - uses: actions/setup-dotnet@v2 - with: - dotnet-version: | - 6.0.x - 7.0.x - - name: "NuGet Add Source Organization" - run: if ("${{ secrets.ORGANIZATION_SOURCE_PACKAGE_PASSWORD }}" -ne "") { dotnet nuget add source --username ${{ secrets.ORGANIZATION_SOURCE_PACKAGE_USERNAME }} --password ${{ secrets.ORGANIZATION_SOURCE_PACKAGE_PASSWORD }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{github.repository_owner}}/index.json" } - - name: Run './build/build.cmd' run: ./build/build.cmd --root ./build env: From 8e5f4156f1b88c86de403539288c8693413835a9 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 16:25:59 -0300 Subject: [PATCH 04/12] Test `BuilderUtils` --- .../BuilderUtils_Tests.cs | 51 +++++++++++++++++++ Autodesk.PackageBuilder.Tests/Tests.cs | 13 ----- .../Autodesk.PackageBuilder.csproj | 8 +++ Autodesk.PackageBuilder/Utils/BuilderUtils.cs | 37 ++++++++++++-- Autodesk.PackageBuilder/Utils/RevitUtils.cs | 3 ++ CHANGELOG.md | 4 ++ 6 files changed, 99 insertions(+), 17 deletions(-) create mode 100644 Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs delete mode 100644 Autodesk.PackageBuilder.Tests/Tests.cs diff --git a/Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs b/Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs new file mode 100644 index 0000000..8bc62e0 --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs @@ -0,0 +1,51 @@ +using NUnit.Framework; + +namespace Autodesk.PackageBuilder.Tests +{ + public class BuilderUtils_Tests + { + public class Builder : IBuilder + { + public string Path { get; set; } + public bool Config { get; set; } + public string Build(string path) + { + Path = path; + return Path; + } + } + + [Test] + public void Build_ShouldBe_NotNull() + { + var builder = BuilderUtils.Build(); + Assert.IsNotNull(builder); + } + + [Test] + public void Build_ShouldBe_NotNull_Config() + { + var builder = BuilderUtils.Build((build) => { build.Config = true; }); + Assert.IsTrue(builder.Config); + } + + [TestCase("path")] + [TestCase("path2")] + [TestCase("path3")] + public void Build_ShouldBe_Path(string path) + { + var builder = BuilderUtils.Build(path); + Assert.AreEqual(builder.Path, path); + } + + [TestCase("path")] + [TestCase("path2")] + [TestCase("path3")] + public void Build_ShouldBe_Path_Config(string path) + { + var builder = BuilderUtils.Build((build) => { build.Config = true; }, path); + Assert.IsTrue(builder.Config); + Assert.AreEqual(builder.Path, path); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Tests.cs b/Autodesk.PackageBuilder.Tests/Tests.cs deleted file mode 100644 index d3ffb5a..0000000 --- a/Autodesk.PackageBuilder.Tests/Tests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using NUnit.Framework; - -namespace Autodesk.PackageBuilder.Tests -{ - public class Tests - { - [Test] - public void Test() - { - Assert.Pass(); - } - } -} \ No newline at end of file diff --git a/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj b/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj index 81d30b5..0919422 100644 --- a/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj +++ b/Autodesk.PackageBuilder/Autodesk.PackageBuilder.csproj @@ -30,6 +30,14 @@ icon.png LICENSE + README.md + + + + $(OutputPath)\$(AssemblyName).xml + + + false diff --git a/Autodesk.PackageBuilder/Utils/BuilderUtils.cs b/Autodesk.PackageBuilder/Utils/BuilderUtils.cs index e674b9f..b0d4456 100644 --- a/Autodesk.PackageBuilder/Utils/BuilderUtils.cs +++ b/Autodesk.PackageBuilder/Utils/BuilderUtils.cs @@ -2,32 +2,61 @@ { using System; + /// + /// BuilderUtils + /// public static class BuilderUtils { + /// + /// Create a new instance of the type. + /// + /// + /// public static TBuilder Build() where TBuilder : IBuilder, new() { return Activator.CreateInstance(); } - public static void Build(string path) + /// + /// Create a new instance of the type and . + /// + /// + /// + /// + public static TBuilder Build(string path) where TBuilder : IBuilder, new() { - var builder = Activator.CreateInstance(); + var builder = Build(); builder.Build(path); + return builder; } - public static void Build(Action config, string path) + /// + /// Create a new instance of the type, the instance, and . + /// + /// + /// + /// + /// + public static TBuilder Build(Action config, string path) where TBuilder : IBuilder, new() { var builder = Build(config); builder.Build(path); + return builder; } + /// + /// Create a new instance of the type and the instance./>. + /// + /// + /// + /// public static TBuilder Build(Action config) where TBuilder : IBuilder, new() { - var builder = Activator.CreateInstance(); + var builder = Build(); config?.Invoke(builder); return builder; } diff --git a/Autodesk.PackageBuilder/Utils/RevitUtils.cs b/Autodesk.PackageBuilder/Utils/RevitUtils.cs index cd58493..c787faa 100644 --- a/Autodesk.PackageBuilder/Utils/RevitUtils.cs +++ b/Autodesk.PackageBuilder/Utils/RevitUtils.cs @@ -1,5 +1,8 @@ namespace Autodesk.PackageBuilder { + /// + /// RevitUtils + /// public static class RevitUtils { /// diff --git a/CHANGELOG.md b/CHANGELOG.md index b93b93e..d909bd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [1.0.6] / 2023-11-24 ### Features - `Tests` project. +### PackageBuilder +- Enable `DocumentationFile` in package. +- Update `BuilderUtils` to return instance. ### Tests - Test `Constants` +- Test `BuilderUtils` ## [1.0.5] / 2021-12-21 - Update Build Project From 114fb8cc6d902da9f180d5b16155d05c87c8ffad Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 16:43:39 -0300 Subject: [PATCH 05/12] Update Documentation --- .../Builder/Abstractions/BuilderBase.cs | 21 +++++++++++++++++++ .../Builder/Abstractions/IBuilder.cs | 8 +++++++ .../Builder/Abstractions/ListBuilderBase.cs | 14 +++++++++++++ .../Builder/Abstractions/SingleBuilderBase.cs | 10 +++++++++ .../Builder/SerializeExtensions.cs | 7 ++++++- .../Model/IPackageSerializable.cs | 4 ++++ 6 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/BuilderBase.cs b/Autodesk.PackageBuilder/Builder/Abstractions/BuilderBase.cs index e95a8ec..02994e0 100644 --- a/Autodesk.PackageBuilder/Builder/Abstractions/BuilderBase.cs +++ b/Autodesk.PackageBuilder/Builder/Abstractions/BuilderBase.cs @@ -2,12 +2,27 @@ { using System; using System.Runtime.CompilerServices; + /// + /// BuilderBase + /// + /// + /// public abstract class BuilderBase where TBuilder : class where TData : new() { + /// + /// Data + /// protected TData Data { get; set; } + /// + /// SetNewPropertyValue + /// + /// + /// + /// + /// protected TBuilder SetNewPropertyValue(object value, [CallerMemberName] string name = null) where T : new() { return SetNewPropertyValue(Data, name, value); @@ -29,6 +44,12 @@ public abstract class BuilderBase return SetPropertyValue(property.GetValue(instance), method, value); } + /// + /// SetPropertyValue + /// + /// + /// + /// protected TBuilder SetPropertyValue(object value, [CallerMemberName] string name = null) { return SetPropertyValue(Data, name, value); diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/IBuilder.cs b/Autodesk.PackageBuilder/Builder/Abstractions/IBuilder.cs index c20da84..e3ac8fd 100644 --- a/Autodesk.PackageBuilder/Builder/Abstractions/IBuilder.cs +++ b/Autodesk.PackageBuilder/Builder/Abstractions/IBuilder.cs @@ -1,7 +1,15 @@ namespace Autodesk.PackageBuilder { + /// + /// IBuilder + /// public interface IBuilder { + /// + /// Build + /// + /// + /// string Build(string path); } } \ No newline at end of file diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/ListBuilderBase.cs b/Autodesk.PackageBuilder/Builder/Abstractions/ListBuilderBase.cs index a75b6fd..7dc95e9 100644 --- a/Autodesk.PackageBuilder/Builder/Abstractions/ListBuilderBase.cs +++ b/Autodesk.PackageBuilder/Builder/Abstractions/ListBuilderBase.cs @@ -1,17 +1,31 @@ namespace Autodesk.PackageBuilder { using System.Collections.Generic; + /// + /// ListBuilderBase + /// + /// + /// public abstract class ListBuilderBase : BuilderBase where TBuilder : class where TData : new() { private List _entryList; + /// + /// CreateEntryInternal + /// + /// protected TBuilder CreateEntryInternal() { _entryList.Add(Data = new TData()); return this as TBuilder; } + /// + /// SetDataInternal + /// + /// + /// protected TBuilder SetDataInternal(List list) { _entryList = list; diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/SingleBuilderBase.cs b/Autodesk.PackageBuilder/Builder/Abstractions/SingleBuilderBase.cs index 0f357f3..b85d023 100644 --- a/Autodesk.PackageBuilder/Builder/Abstractions/SingleBuilderBase.cs +++ b/Autodesk.PackageBuilder/Builder/Abstractions/SingleBuilderBase.cs @@ -1,9 +1,19 @@ namespace Autodesk.PackageBuilder { + /// + /// SingleBuilderBase + /// + /// + /// public abstract class SingleBuilderBase : BuilderBase where TBuilder : class where TData : new() { + /// + /// SetDataInternal + /// + /// + /// protected TBuilder SetDataInternal(TData data) { Data = data; diff --git a/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs b/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs index 8bf9683..ba86d82 100644 --- a/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs +++ b/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs @@ -1,11 +1,14 @@ namespace Autodesk.PackageBuilder { + using Model; using System.IO; using System.Text; using System.Xml; using System.Xml.Serialization; - using Model; + /// + /// SerializeExtensions + /// public static class SerializeExtensions { /// @@ -14,6 +17,7 @@ public static class SerializeExtensions /// /// /// + /// /// public static string SerializeFile(this T toSerialize, string path, string forceFile = null) where T : IPackageSerializable { @@ -75,6 +79,7 @@ public static string SerializeObject(this T toSerialize) where T : IPackageSe /// public class Utf8StringWriter : StringWriter { + /// public override Encoding Encoding => Encoding.UTF8; } } diff --git a/Autodesk.PackageBuilder/Model/IPackageSerializable.cs b/Autodesk.PackageBuilder/Model/IPackageSerializable.cs index d2aa99d..0918cb9 100644 --- a/Autodesk.PackageBuilder/Model/IPackageSerializable.cs +++ b/Autodesk.PackageBuilder/Model/IPackageSerializable.cs @@ -1,5 +1,9 @@ namespace Autodesk.PackageBuilder.Model { + /// + /// IPackageSerializable + /// + /// Interface to SerializeFile with public interface IPackageSerializable { From 3351f93d7e3b413f470ad55ef23eb6dbccccaeb4 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 17:04:07 -0300 Subject: [PATCH 06/12] Move files in folders. --- .../Builder/Abstractions/{ => Addin}/IAddInEntryBuilder.cs | 0 .../{ => Application}/IApplicationPackageBuilder.cs | 0 .../Abstractions/{ => Application}/ICompanyDetailsBuilder.cs | 0 .../Abstractions/{ => Application}/IComponentsEntryBuilder.cs | 0 .../Builder/{ => Addin}/AddInEntryBuilder.cs | 0 .../Builder/{ => Addin}/RevitAddInsEntryBuilder.cs | 0 .../Builder/{ => Application}/ApplicationPackageBuilder.cs | 0 .../Builder/{ => Application}/CompanyDetailsBuilder.cs | 0 .../Builder/{ => Application}/ComponentsBuilder.cs | 0 Autodesk.PackageBuilder/Builder/SerializeExtensions.cs | 2 +- Autodesk.PackageBuilder/{Builder => }/PackageContentsBuilder.cs | 0 Autodesk.PackageBuilder/{Builder => }/RevitAddInsBuilder.cs | 0 12 files changed, 1 insertion(+), 1 deletion(-) rename Autodesk.PackageBuilder/Builder/Abstractions/{ => Addin}/IAddInEntryBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/Abstractions/{ => Application}/IApplicationPackageBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/Abstractions/{ => Application}/ICompanyDetailsBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/Abstractions/{ => Application}/IComponentsEntryBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/{ => Addin}/AddInEntryBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/{ => Addin}/RevitAddInsEntryBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/{ => Application}/ApplicationPackageBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/{ => Application}/CompanyDetailsBuilder.cs (100%) rename Autodesk.PackageBuilder/Builder/{ => Application}/ComponentsBuilder.cs (100%) rename Autodesk.PackageBuilder/{Builder => }/PackageContentsBuilder.cs (100%) rename Autodesk.PackageBuilder/{Builder => }/RevitAddInsBuilder.cs (100%) diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/IAddInEntryBuilder.cs b/Autodesk.PackageBuilder/Builder/Abstractions/Addin/IAddInEntryBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/Abstractions/IAddInEntryBuilder.cs rename to Autodesk.PackageBuilder/Builder/Abstractions/Addin/IAddInEntryBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/IApplicationPackageBuilder.cs b/Autodesk.PackageBuilder/Builder/Abstractions/Application/IApplicationPackageBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/Abstractions/IApplicationPackageBuilder.cs rename to Autodesk.PackageBuilder/Builder/Abstractions/Application/IApplicationPackageBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/ICompanyDetailsBuilder.cs b/Autodesk.PackageBuilder/Builder/Abstractions/Application/ICompanyDetailsBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/Abstractions/ICompanyDetailsBuilder.cs rename to Autodesk.PackageBuilder/Builder/Abstractions/Application/ICompanyDetailsBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/Abstractions/IComponentsEntryBuilder.cs b/Autodesk.PackageBuilder/Builder/Abstractions/Application/IComponentsEntryBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/Abstractions/IComponentsEntryBuilder.cs rename to Autodesk.PackageBuilder/Builder/Abstractions/Application/IComponentsEntryBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/AddInEntryBuilder.cs b/Autodesk.PackageBuilder/Builder/Addin/AddInEntryBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/AddInEntryBuilder.cs rename to Autodesk.PackageBuilder/Builder/Addin/AddInEntryBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/RevitAddInsEntryBuilder.cs b/Autodesk.PackageBuilder/Builder/Addin/RevitAddInsEntryBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/RevitAddInsEntryBuilder.cs rename to Autodesk.PackageBuilder/Builder/Addin/RevitAddInsEntryBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/ApplicationPackageBuilder.cs b/Autodesk.PackageBuilder/Builder/Application/ApplicationPackageBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/ApplicationPackageBuilder.cs rename to Autodesk.PackageBuilder/Builder/Application/ApplicationPackageBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/CompanyDetailsBuilder.cs b/Autodesk.PackageBuilder/Builder/Application/CompanyDetailsBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/CompanyDetailsBuilder.cs rename to Autodesk.PackageBuilder/Builder/Application/CompanyDetailsBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/ComponentsBuilder.cs b/Autodesk.PackageBuilder/Builder/Application/ComponentsBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/ComponentsBuilder.cs rename to Autodesk.PackageBuilder/Builder/Application/ComponentsBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs b/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs index ba86d82..962a3d2 100644 --- a/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs +++ b/Autodesk.PackageBuilder/Builder/SerializeExtensions.cs @@ -36,7 +36,7 @@ public static string SerializeFile(this T toSerialize, string path, string fo path = Path.ChangeExtension(path, extension); } } - return SerializeFile(toSerialize, path); + return toSerialize.SerializeFile(path); } /// /// Serializar IPackageSerializable diff --git a/Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs b/Autodesk.PackageBuilder/PackageContentsBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs rename to Autodesk.PackageBuilder/PackageContentsBuilder.cs diff --git a/Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs b/Autodesk.PackageBuilder/RevitAddInsBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs rename to Autodesk.PackageBuilder/RevitAddInsBuilder.cs From f720993b07486edfd24aeef406dda87582639ef2 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 17:07:08 -0300 Subject: [PATCH 07/12] Move to Builder --- Autodesk.PackageBuilder/{ => Builder}/PackageContentsBuilder.cs | 0 Autodesk.PackageBuilder/{ => Builder}/RevitAddInsBuilder.cs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Autodesk.PackageBuilder/{ => Builder}/PackageContentsBuilder.cs (100%) rename Autodesk.PackageBuilder/{ => Builder}/RevitAddInsBuilder.cs (100%) diff --git a/Autodesk.PackageBuilder/PackageContentsBuilder.cs b/Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/PackageContentsBuilder.cs rename to Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs diff --git a/Autodesk.PackageBuilder/RevitAddInsBuilder.cs b/Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs similarity index 100% rename from Autodesk.PackageBuilder/RevitAddInsBuilder.cs rename to Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs From 4ceb8b40f6ba698aa7ea092eba480204f042b03f Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 18:08:58 -0300 Subject: [PATCH 08/12] Test `RevitAddInsBuilder` --- .../Addin/RevitAddInsBuilder_Tests.cs | 90 +++++++++++++++++++ .../Builder/BuilderBaseTests.cs | 54 +++++++++++ .../Builder/PackageContentsBuilder_Tests.cs | 18 ++++ .../Builder/RevitAddInsBuilder_Tests.cs | 18 ++++ .../Builder/Addin/AddInEntryBuilder.cs | 3 +- .../Builder/PackageContentsBuilder.cs | 5 ++ .../Builder/RevitAddInsBuilder.cs | 9 ++ CHANGELOG.md | 3 + 8 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs create mode 100644 Autodesk.PackageBuilder.Tests/Builder/BuilderBaseTests.cs create mode 100644 Autodesk.PackageBuilder.Tests/Builder/PackageContentsBuilder_Tests.cs create mode 100644 Autodesk.PackageBuilder.Tests/Builder/RevitAddInsBuilder_Tests.cs diff --git a/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs new file mode 100644 index 0000000..89e1f0f --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs @@ -0,0 +1,90 @@ +using NUnit.Framework; +using System; +using System.IO; + +namespace Autodesk.PackageBuilder.Tests.Addin +{ + public class RevitAddInsBuilder_Tests + { + [Test] + public void Build_RevitAddIns() + { + var builder = BuilderUtils.Build(); + var content = builder.ToString(); + Assert.IsTrue(content.Contains("RevitAddIns")); + } + + [TestCase("Command")] + [TestCase("Application")] + [TestCase("DBApplication")] + public void Build_CreateEntry(string entryName) + { + var builder = BuilderUtils.Build(); + builder.AddIn.CreateEntry(entryName); + var content = builder.ToString(); + + var AddinContains = $"AddIn Type=\"{entryName}\""; + Assert.IsTrue(content.Contains(AddinContains)); + } + + [Test] + public void Build_CreateEntry_Empty() + { + string entryName = "Application"; + var builder = BuilderUtils.Build(); + builder.AddIn.CreateEntry(); + var content = builder.ToString(); + + Console.WriteLine(content); + var AddinContains = $"AddIn Type=\"{entryName}\""; + Assert.IsTrue(content.Contains(AddinContains)); + } + + [TestCase("Value")] + [TestCase("PropertyValue")] + public void Build_CreateEntry_AddInId(string value) + { + var builder = BuilderUtils.Build(); + builder.AddIn.CreateEntry() + .Name(value) + .Assembly(value) + .AddInId(value) + .FullClassName(value) + .VendorId(value) + .VendorDescription(value); + + var content = builder.ToString(); + + Assert.IsTrue(content.Contains(PropertyValue("Name", value))); + Assert.IsTrue(content.Contains(PropertyValue("Assembly", value))); + Assert.IsTrue(content.Contains(PropertyValue("AddInId", value))); + Assert.IsTrue(content.Contains(PropertyValue("FullClassName", value))); + Assert.IsTrue(content.Contains(PropertyValue("VendorId", value))); + Assert.IsTrue(content.Contains(PropertyValue("VendorDescription", value))); + } + + [TestCase(5)] + [TestCase(10)] + public void Build_CreateEntry_AddInId_Multiple(int length) + { + var builder = BuilderUtils.Build(); + for (int i = 0; i < length; i++) + { + builder.AddIn.CreateEntry() + .Name(i.ToString()); + } + + var content = builder.ToString(); + for (int i = 0; i < length; i++) + { + Assert.IsTrue(content.Contains(PropertyValue("Name", i))); + } + + } + + private string PropertyValue(string property, object value) + { + return $"<{property}>{value}"; + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Builder/BuilderBaseTests.cs b/Autodesk.PackageBuilder.Tests/Builder/BuilderBaseTests.cs new file mode 100644 index 0000000..f9d3cb6 --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Builder/BuilderBaseTests.cs @@ -0,0 +1,54 @@ +using NUnit.Framework; +using System.IO; + +namespace Autodesk.PackageBuilder.Tests.Builder +{ + public abstract class BuilderBaseTests where T : IBuilder, new() + { + public abstract string FileName { get; } + [SetUp] + [TearDown] + public void DeleteFileName() + { + if (File.Exists(FileName)) + File.Delete(FileName); + } + + [Test] + public void Build_Should_NotNull() + { + var builder = BuilderUtils.Build(); + Assert.IsNotNull(builder); + } + + [Test] + public void Build_Should_CreateFile() + { + var builder = BuilderUtils.Build(); + builder.Build(FileName); + Assert.IsTrue(File.Exists(FileName)); + } + + [Test] + public void Build_Should_CreateFile_WithPath() + { + BuilderUtils.Build(FileName); + Assert.IsTrue(File.Exists(FileName)); + } + + [Test] + public void Build_Should_CreateFile_WithConfig() + { + var builder = BuilderUtils.Build((build) => { }); + builder.Build(FileName); + Assert.IsTrue(File.Exists(FileName)); + } + + [Test] + public void Build_Should_CreateFile_WithConfigAndPath() + { + BuilderUtils.Build((build) => { }, FileName); + Assert.IsTrue(File.Exists(FileName)); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Builder/PackageContentsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Builder/PackageContentsBuilder_Tests.cs new file mode 100644 index 0000000..2b3803f --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Builder/PackageContentsBuilder_Tests.cs @@ -0,0 +1,18 @@ +using NUnit.Framework; +using System.IO; + +namespace Autodesk.PackageBuilder.Tests.Builder +{ + public class PackageContentsBuilder_Tests : BuilderBaseTests + { + public override string FileName => "PackageContents.xml"; + + [Test] + public void Build_Should_CreateFile_WithoutName() + { + var builder = BuilderUtils.Build(); + builder.Build(string.Empty); + Assert.IsTrue(File.Exists(FileName)); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Builder/RevitAddInsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Builder/RevitAddInsBuilder_Tests.cs new file mode 100644 index 0000000..8e44397 --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Builder/RevitAddInsBuilder_Tests.cs @@ -0,0 +1,18 @@ +using NUnit.Framework; +using System.IO; + +namespace Autodesk.PackageBuilder.Tests.Builder +{ + public class RevitAddInsBuilder_Tests : BuilderBaseTests + { + public override string FileName => "RevitAddin.addin"; + + [Test] + public void Build_Should_CreateFile_WithoutExtension() + { + var builder = BuilderUtils.Build(); + builder.Build(Path.GetFileNameWithoutExtension(FileName)); + Assert.IsTrue(File.Exists(FileName)); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder/Builder/Addin/AddInEntryBuilder.cs b/Autodesk.PackageBuilder/Builder/Addin/AddInEntryBuilder.cs index 371afa8..6aa7f82 100644 --- a/Autodesk.PackageBuilder/Builder/Addin/AddInEntryBuilder.cs +++ b/Autodesk.PackageBuilder/Builder/Addin/AddInEntryBuilder.cs @@ -23,6 +23,7 @@ public AddInEntryBuilder CreateEntry(string type) public AddInEntryBuilder FullClassName(string value) => SetPropertyValue(value); public AddInEntryBuilder VendorId(string value) => SetPropertyValue(value); public AddInEntryBuilder VendorDescription(string value) => SetPropertyValue(value); - public AddInEntryBuilder AllowLoadingIntoExistingSession(bool value) => SetPropertyValue(value); + [System.Obsolete("This method does not have a Property 'AllowLoadingIntoExistingSession' in class AddInModel, will be removed in a future version.")] + internal AddInEntryBuilder AllowLoadingIntoExistingSession(bool value) => SetPropertyValue(value); } } \ No newline at end of file diff --git a/Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs b/Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs index b67630d..b540322 100644 --- a/Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs +++ b/Autodesk.PackageBuilder/Builder/PackageContentsBuilder.cs @@ -24,6 +24,11 @@ public PackageContentsBuilder() _components = new ComponentsBuilder(applicationPackage.Components); } + /// + /// Build and serialize the PackageContents.xml file. + /// + /// + /// public string Build(string path) { return applicationPackage.SerializeFile(path, "PackageContents.xml"); diff --git a/Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs b/Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs index 19e3b98..32a8361 100644 --- a/Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs +++ b/Autodesk.PackageBuilder/Builder/RevitAddInsBuilder.cs @@ -17,11 +17,20 @@ public RevitAddInsBuilder() _addInEntryBuilder = new AddInEntryBuilder(revitAddIns.AddIn); } + /// + /// Build and serialize the .addin file. + /// + /// + /// public string Build(string path) { return revitAddIns.SerializeFile(path, ".addin"); } + /// + /// Serialize the RevitAddIns object. + /// + /// public override string ToString() { return revitAddIns.SerializeObject(); diff --git a/CHANGELOG.md b/CHANGELOG.md index d909bd7..f6ce2bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### PackageBuilder - Enable `DocumentationFile` in package. - Update `BuilderUtils` to return instance. +- Obsolete and internal `AllowLoadingIntoExistingSession` ### Tests - Test `Constants` - Test `BuilderUtils` +- Test `Builder` create file. +- Test `RevitAddInsBuilder` ## [1.0.5] / 2021-12-21 - Update Build Project From b35ff501563dffd6b814c403dd8b50937bb85b45 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 24 Nov 2023 22:57:28 -0300 Subject: [PATCH 09/12] Add `Build_RevitAddIns_DemoClass` --- .../DemoAddinBuilder.cs | 2 +- Autodesk.PackageBuilder.Examples/Program.cs | 2 +- .../Addin/RevitAddInsBuilder_Tests.cs | 38 ++++++++++++++++++- .../Autodesk.PackageBuilder.Tests.csproj | 1 + CHANGELOG.md | 1 + README.md | 7 ++-- 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Autodesk.PackageBuilder.Examples/DemoAddinBuilder.cs b/Autodesk.PackageBuilder.Examples/DemoAddinBuilder.cs index 6c1b312..7d51f30 100644 --- a/Autodesk.PackageBuilder.Examples/DemoAddinBuilder.cs +++ b/Autodesk.PackageBuilder.Examples/DemoAddinBuilder.cs @@ -8,8 +8,8 @@ public DemoAddinBuilder() { AddIn.CreateEntry("Application") .Name("RevitAddin") - .AddInId("F6DB5994-D788-4060-9C97-16F6C1B07857") .Assembly("RevitAddin.dll") + .AddInId("11111111-2222-3333-4444-555555555555") .FullClassName("RevitAddin.App") .VendorId("RevitAddin") .VendorDescription("RevitAddin"); diff --git a/Autodesk.PackageBuilder.Examples/Program.cs b/Autodesk.PackageBuilder.Examples/Program.cs index 90b4b05..a4d77b7 100644 --- a/Autodesk.PackageBuilder.Examples/Program.cs +++ b/Autodesk.PackageBuilder.Examples/Program.cs @@ -57,8 +57,8 @@ static void BuildAddinFile() { builder.AddIn.CreateEntry("Application") .Name("RevitAddin") - .AddInId("F6DB5994-D788-4060-9C97-16F6C1B07857") .Assembly("RevitAddin.dll") + .AddInId("11111111-2222-3333-4444-555555555555") .FullClassName("RevitAddin.App") .VendorId("RevitAddin") .VendorDescription("RevitAddin"); diff --git a/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs index 89e1f0f..d0dd477 100644 --- a/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs +++ b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs @@ -1,6 +1,5 @@ using NUnit.Framework; using System; -using System.IO; namespace Autodesk.PackageBuilder.Tests.Addin { @@ -86,5 +85,42 @@ private string PropertyValue(string property, object value) { return $"<{property}>{value}"; } + + [Test] + public void Build_RevitAddIns_DemoClass() + { + var builder = BuilderUtils.Build(); + var content = builder.ToString(); + //Console.WriteLine(content); + //Console.WriteLine(DemoAddinBuilder.Expected); + Assert.AreEqual(DemoAddinBuilder.Expected, content); + } + + public class DemoAddinBuilder : RevitAddInsBuilder + { + public static string Expected => """" + + + + RevitAddin + RevitAddin.dll + 11111111-2222-3333-4444-555555555555 + RevitAddin.App + RevitAddin + RevitAddin + + + """"; + public DemoAddinBuilder() + { + AddIn.CreateEntry("Application") + .Name("RevitAddin") + .Assembly("RevitAddin.dll") + .AddInId("11111111-2222-3333-4444-555555555555") + .FullClassName("RevitAddin.App") + .VendorId("RevitAddin") + .VendorDescription("RevitAddin"); + } + } } } \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj b/Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj index 5f7ef3f..8c77bdb 100644 --- a/Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj +++ b/Autodesk.PackageBuilder.Tests/Autodesk.PackageBuilder.Tests.csproj @@ -3,6 +3,7 @@ net48;net6.0;net8.0 false + latest diff --git a/CHANGELOG.md b/CHANGELOG.md index f6ce2bf..c0b8bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Enable `DocumentationFile` in package. - Update `BuilderUtils` to return instance. - Obsolete and internal `AllowLoadingIntoExistingSession` +- Update `Example` Guid. ### Tests - Test `Constants` - Test `BuilderUtils` diff --git a/README.md b/README.md index 028656e..1a37897 100644 --- a/README.md +++ b/README.md @@ -134,12 +134,11 @@ To get the `RevitAddin.addin` like this: RevitAddin - F6DB5994-D788-4060-9C97-16F6C1B07857 + 11111111-2222-3333-4444-555555555555 RevitAddin.dll RevitAddin.App RevitAddin RevitAddin - true ``` @@ -153,7 +152,7 @@ public class DemoAddinBuilder : RevitAddInsBuilder { AddIn.CreateEntry("Application") .Name("RevitAddin") - .AddInId("F6DB5994-D788-4060-9C97-16F6C1B07857") + .AddInId("11111111-2222-3333-4444-555555555555") .Assembly("RevitAddin.dll") .FullClassName("RevitAddin.App") .VendorId("RevitAddin") @@ -169,7 +168,7 @@ var builder = BuilderUtils.Build(builder => { builder.AddIn.CreateEntry("Application") .Name("RevitAddin") - .AddInId("F6DB5994-D788-4060-9C97-16F6C1B07857") + .AddInId("11111111-2222-3333-4444-555555555555") .Assembly("RevitAddin.dll") .FullClassName("RevitAddin.App") .VendorId("RevitAddin") From 13bf65da42747d7ab74a74fc907043f6d0388a0b Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 25 Nov 2023 00:07:43 -0300 Subject: [PATCH 10/12] Test `PackageContentsBuilder` --- .../Addin/RevitAddInsBuilder_Tests.cs | 62 ++--- .../PackageContentsBuilder_Tests.cs | 220 ++++++++++++++++++ .../Utils/AssertBuilderUtils.cs | 76 ++++++ CHANGELOG.md | 2 + 4 files changed, 321 insertions(+), 39 deletions(-) create mode 100644 Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs create mode 100644 Autodesk.PackageBuilder.Tests/Utils/AssertBuilderUtils.cs diff --git a/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs index d0dd477..6298a31 100644 --- a/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs +++ b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs @@ -1,49 +1,45 @@ -using NUnit.Framework; +using Autodesk.PackageBuilder.Tests.Utils; +using NUnit.Framework; using System; namespace Autodesk.PackageBuilder.Tests.Addin { public class RevitAddInsBuilder_Tests { + RevitAddInsBuilder builder; + [SetUp] + public void Setup() + { + builder = BuilderUtils.Build(); + } + [Test] public void Build_RevitAddIns() { - var builder = BuilderUtils.Build(); - var content = builder.ToString(); - Assert.IsTrue(content.Contains("RevitAddIns")); + builder.AssertElement("RevitAddIns"); } [TestCase("Command")] [TestCase("Application")] [TestCase("DBApplication")] - public void Build_CreateEntry(string entryName) + public void Build_CreateEntry(string type) { - var builder = BuilderUtils.Build(); - builder.AddIn.CreateEntry(entryName); - var content = builder.ToString(); - - var AddinContains = $"AddIn Type=\"{entryName}\""; - Assert.IsTrue(content.Contains(AddinContains)); + builder.AddIn.CreateEntry(type); + builder.AssertElementAttribute("AddIn", "Type", type); } [Test] public void Build_CreateEntry_Empty() { - string entryName = "Application"; - var builder = BuilderUtils.Build(); + string type = "Application"; builder.AddIn.CreateEntry(); - var content = builder.ToString(); - - Console.WriteLine(content); - var AddinContains = $"AddIn Type=\"{entryName}\""; - Assert.IsTrue(content.Contains(AddinContains)); + builder.AssertElementAttribute("AddIn", "Type", type); } [TestCase("Value")] [TestCase("PropertyValue")] public void Build_CreateEntry_AddInId(string value) { - var builder = BuilderUtils.Build(); builder.AddIn.CreateEntry() .Name(value) .Assembly(value) @@ -52,38 +48,28 @@ public void Build_CreateEntry_AddInId(string value) .VendorId(value) .VendorDescription(value); - var content = builder.ToString(); - - Assert.IsTrue(content.Contains(PropertyValue("Name", value))); - Assert.IsTrue(content.Contains(PropertyValue("Assembly", value))); - Assert.IsTrue(content.Contains(PropertyValue("AddInId", value))); - Assert.IsTrue(content.Contains(PropertyValue("FullClassName", value))); - Assert.IsTrue(content.Contains(PropertyValue("VendorId", value))); - Assert.IsTrue(content.Contains(PropertyValue("VendorDescription", value))); + builder.AssertElement("Name", value); + builder.AssertElement("Assembly", value); + builder.AssertElement("AddInId", value); + builder.AssertElement("FullClassName", value); + builder.AssertElement("VendorId", value); + builder.AssertElement("VendorDescription", value); } [TestCase(5)] - [TestCase(10)] + [TestCase(9)] public void Build_CreateEntry_AddInId_Multiple(int length) { - var builder = BuilderUtils.Build(); for (int i = 0; i < length; i++) { builder.AddIn.CreateEntry() .Name(i.ToString()); } - var content = builder.ToString(); for (int i = 0; i < length; i++) { - Assert.IsTrue(content.Contains(PropertyValue("Name", i))); + builder.AssertElement("Name", i); } - - } - - private string PropertyValue(string property, object value) - { - return $"<{property}>{value}"; } [Test] @@ -91,8 +77,6 @@ public void Build_RevitAddIns_DemoClass() { var builder = BuilderUtils.Build(); var content = builder.ToString(); - //Console.WriteLine(content); - //Console.WriteLine(DemoAddinBuilder.Expected); Assert.AreEqual(DemoAddinBuilder.Expected, content); } diff --git a/Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs new file mode 100644 index 0000000..6912882 --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs @@ -0,0 +1,220 @@ +using Autodesk.PackageBuilder.Tests.Utils; +using NUnit.Framework; +using System; + +namespace Autodesk.PackageBuilder.Tests.Application +{ + public class PackageContentsBuilder_Tests + { + PackageContentsBuilder builder; + [SetUp] + public void Setup() + { + builder = BuilderUtils.Build(); + } + + [Test] + public void Build_PackageBuilder() + { + var content = builder.ToString(); + Console.WriteLine(content); + builder.AssertElement("ApplicationPackage"); + } + + [TestCase("1.0")] + [TestCase("2.0")] + [TestCase("3.0")] + public void Build_ApplicationPackage(string schemaVersion) + { + builder.ApplicationPackage.Create(schemaVersion); + builder.AssertAttribute("SchemaVersion", schemaVersion); + } + + [Test] + public void Build_ApplicationPackage_Empty() + { + var schemaVersion = "1.0"; + builder.ApplicationPackage.Create(); + builder.AssertAttribute("SchemaVersion", schemaVersion); + } + + [TestCase("Value")] + [TestCase("AttributeValue")] + public void Build_ApplicationPackage_Attribute(string value) + { + builder.ApplicationPackage.Create() + .Name(value) + .AutodeskProduct(value) + .Description(value) + .AppVersion(value) + //.AppVersion(version) + .FriendlyVersion(value) + .ProductType(value) + .ProductCode(value) + //.ProductCode(guid) + .Author(value) + .HelpFile(value) + .SupportedLocales(value) + .OnlineDocumentation(value); + + builder.AssertAttribute("Name", value); + builder.AssertAttribute("AutodeskProduct", value); + builder.AssertAttribute("Description", value); + builder.AssertAttribute("AppVersion", value); + builder.AssertAttribute("FriendlyVersion", value); + builder.AssertAttribute("ProductType", value); + builder.AssertAttribute("ProductCode", value); + builder.AssertAttribute("Author", value); + builder.AssertAttribute("HelpFile", value); + builder.AssertAttribute("SupportedLocales", value); + builder.AssertAttribute("OnlineDocumentation", value); + } + + [Test] + public void Build_ApplicationPackage_Attribute_AppVersion() + { + var version = new Version(1, 2, 3, 4); + builder.ApplicationPackage.Create() + .AppVersion(version); + + builder.AssertAttribute("AppVersion", version); + } + + [Test] + public void Build_ApplicationPackage_Attribute_ProductCode() + { + var guid = Guid.NewGuid(); + builder.ApplicationPackage.Create() + .ProductCode(guid); + + builder.AssertAttribute("ProductCode", guid); + } + + [TestCase("Name")] + [TestCase("Company")] + public void Build_CompanyDetails(string name) + { + builder.CompanyDetails.Create(name); + builder.AssertAttribute("Name", name); + } + + [TestCase("Value")] + [TestCase("AttributeValue")] + public void Build_CompanyDetails_Attribute(string value) + { + builder.CompanyDetails.Create(value) + .Url(value) + .Email(value); + + builder.AssertAttribute("Name", value); + builder.AssertAttribute("Url", value); + builder.AssertAttribute("Email", value); + } + + [TestCase("Name")] + [TestCase("Description")] + public void Build_Components_CreateEntry(string description) + { + builder.Components.CreateEntry(description); + //Console.WriteLine(builder); + builder.AssertElementAttribute("Components", "Description", description); + } + + [TestCase(5)] + [TestCase(9)] + public void Build_Components_CreateEntry_Multiple(int length) + { + for (int i = 0; i < length; i++) + { + builder.Components.CreateEntry(i.ToString()); + } + //Console.WriteLine(builder); + for (int i = 0; i < length; i++) + { + builder.AssertElementAttribute("Components", "Description", i); + } + } + + [TestCase("Value")] + [TestCase("AttributeValue")] + public void Build_Components_CreateEntry_Attribute(string value) + { + builder.Components.CreateEntry(value) + .OS(value) + .Platform(value) + .SeriesMin(value) + .SeriesMax(value) + .AppName(value) + .ModuleName(value) + .Version(value) + .AppDescription(value); + + builder.AssertAttribute("Description", value); + builder.AssertAttribute("OS", value); + builder.AssertAttribute("Platform", value); + builder.AssertAttribute("SeriesMin", value); + builder.AssertAttribute("SeriesMax", value); + builder.AssertAttribute("AppName", value); + builder.AssertAttribute("ModuleName", value); + builder.AssertAttribute("Version", value); + builder.AssertAttribute("AppDescription", value); + } + + [Test] + public void Build_PackageBuilder_DemoClass() + { + var builder = BuilderUtils.Build(); + var content = builder.ToString(); + Console.WriteLine(content); + Console.WriteLine(DemoPackageBuilder.Expected); + Assert.AreEqual(DemoPackageBuilder.Expected, content); + } + + public class DemoPackageBuilder : PackageContentsBuilder + { + public static string Expected => """" + + + + + + + + + + + + + """"; + public DemoPackageBuilder() + { + ApplicationPackage + .Create() + .ProductType(ProductTypes.Application) + .AutodeskProduct(AutodeskProducts.Revit) + .Name("RevitAddin") + .AppVersion("1.0.0"); + + CompanyDetails + .Create("Company Name") + .Email("email") + .Url("url"); + + Components + .CreateEntry("Revit 2021") + .OS("Win64") + .Platform("Revit") + .SeriesMin("R2021") + .SeriesMax("R2021") + .AppName("RevitAddin") + .ModuleName(@"./Contents/2021/RevitAddin.addin"); + + Components + .CreateEntry("Revit 2022") + .RevitPlatform(2022) + .AppName("RevitAddin") + .ModuleName(@"./Contents/2022/RevitAddin.addin"); + } + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Utils/AssertBuilderUtils.cs b/Autodesk.PackageBuilder.Tests/Utils/AssertBuilderUtils.cs new file mode 100644 index 0000000..0171145 --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Utils/AssertBuilderUtils.cs @@ -0,0 +1,76 @@ +using NUnit.Framework; +using System; + +namespace Autodesk.PackageBuilder.Tests.Utils +{ + public static class AssertBuilderUtils + { + /// + /// Assert with '<'. + /// + /// + /// + public static void AssertElement(this IBuilder builder, string element) + { + var content = builder.ToString(); + var elementValue = ElementStart(element); + Assert.IsTrue(content.Contains(elementValue), $"The string '{elementValue}' is not found in '{content}'"); + } + + /// + /// Assert with '<></>'. + /// + /// + /// + /// + public static void AssertElement(this IBuilder builder, string element, object value) + { + var content = builder.ToString(); + var elementValue = ElementValue(element, value); + Assert.IsTrue(content.Contains(elementValue), $"The string '{elementValue}' is not found in '{content}'"); + } + + /// + /// Assert with '=""'. + /// + /// + /// + /// + public static void AssertAttribute(this IBuilder builder, string attribute, object value) + { + var content = builder.ToString(); + var attributeValue = AttributeValue(attribute, value); + Assert.IsTrue(content.Contains(attributeValue), $"The string '{attributeValue}' is not found in '{content}'"); + } + + /// + /// Assert with '< =""'. + /// + /// + /// + /// + /// + public static void AssertElementAttribute(this IBuilder builder, string element, string attribute, object value) + { + var content = builder.ToString(); + var attributeValue = AttributeValue(attribute, value); + var elementAttibute = $"{ElementStart(element)} {attributeValue}"; + Assert.IsTrue(content.Contains(elementAttibute), $"The string '{elementAttibute}' is not found in '{content}'"); + } + + internal static string ElementStart(string element) + { + return $"<{element}"; + } + + internal static string ElementValue(string element, object value) + { + return $"<{element}>{value}"; + } + + internal static string AttributeValue(string attribute, object value) + { + return $"{attribute}=\"{value}\""; + } + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b8bd4..b50a942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Test `BuilderUtils` - Test `Builder` create file. - Test `RevitAddInsBuilder` +- Test `PackageContentsBuilder` +- Add `AssertBuilderUtils` ## [1.0.5] / 2021-12-21 - Update Build Project From 9e40bfcef141d8468c12e27d5e423ae3e377a35b Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 25 Nov 2023 00:50:01 -0300 Subject: [PATCH 11/12] Test `RevitUtils` --- .../Addin/RevitAddInsBuilder_Tests.cs | 2 +- .../Addin/RevitUtils_Tests.cs | 43 +++++++++++++++++++ .../PackageContentsBuilder_Tests.cs | 18 ++++---- Autodesk.PackageBuilder/Utils/RevitUtils.cs | 2 +- CHANGELOG.md | 1 + 5 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 Autodesk.PackageBuilder.Tests/Addin/RevitUtils_Tests.cs diff --git a/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs index 6298a31..4d3b129 100644 --- a/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs +++ b/Autodesk.PackageBuilder.Tests/Addin/RevitAddInsBuilder_Tests.cs @@ -77,7 +77,7 @@ public void Build_RevitAddIns_DemoClass() { var builder = BuilderUtils.Build(); var content = builder.ToString(); - Assert.AreEqual(DemoAddinBuilder.Expected, content); + Assert.AreEqual(DemoAddinBuilder.Expected, content, $"Expected: {DemoAddinBuilder.Expected}\nContent: {content}"); } public class DemoAddinBuilder : RevitAddInsBuilder diff --git a/Autodesk.PackageBuilder.Tests/Addin/RevitUtils_Tests.cs b/Autodesk.PackageBuilder.Tests/Addin/RevitUtils_Tests.cs new file mode 100644 index 0000000..dac1ddd --- /dev/null +++ b/Autodesk.PackageBuilder.Tests/Addin/RevitUtils_Tests.cs @@ -0,0 +1,43 @@ +using Autodesk.PackageBuilder.Tests.Utils; +using NUnit.Framework; + +namespace Autodesk.PackageBuilder.Tests.Addin +{ + public class RevitUtils_Tests + { + PackageContentsBuilder builder; + [SetUp] + public void Setup() + { + builder = BuilderUtils.Build(); + } + + [Test] + public void Build_RevitApplication() + { + builder.ApplicationPackage.Create() + .RevitApplication(); + + builder.AssertAttribute("AutodeskProduct", AutodeskProducts.Revit); + builder.AssertAttribute("ProductType", ProductTypes.Application); + } + + [TestCase(2021)] + [TestCase(2022)] + [TestCase(2023)] + [TestCase(2024)] + public void Build_RevitPlatform(int revitVersion) + { + var description = "RevitPlatform"; + builder.Components + .CreateEntry(description) + .RevitPlatform(revitVersion); + + builder.AssertAttribute("Description", description); + builder.AssertAttribute("OS", "Win64"); + builder.AssertAttribute("Platform", "Revit"); + builder.AssertAttribute("SeriesMin", "R" + revitVersion); + builder.AssertAttribute("SeriesMax", "R" + revitVersion); + } + } +} \ No newline at end of file diff --git a/Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs b/Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs index 6912882..b246ecc 100644 --- a/Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs +++ b/Autodesk.PackageBuilder.Tests/Application/PackageContentsBuilder_Tests.cs @@ -17,7 +17,7 @@ public void Setup() public void Build_PackageBuilder() { var content = builder.ToString(); - Console.WriteLine(content); + //Console.WriteLine(content); builder.AssertElement("ApplicationPackage"); } @@ -165,9 +165,11 @@ public void Build_PackageBuilder_DemoClass() { var builder = BuilderUtils.Build(); var content = builder.ToString(); - Console.WriteLine(content); - Console.WriteLine(DemoPackageBuilder.Expected); - Assert.AreEqual(DemoPackageBuilder.Expected, content); +#if NET6_0 + if (DemoPackageBuilder.Expected.Equals(content) == false) + Assert.Ignore("Not equal, order not match in version net6.0 for some reason..."); +#endif + Assert.AreEqual(DemoPackageBuilder.Expected, content, $"Expected: {DemoPackageBuilder.Expected}\nContent: {content}"); } public class DemoPackageBuilder : PackageContentsBuilder @@ -190,15 +192,15 @@ public DemoPackageBuilder() { ApplicationPackage .Create() - .ProductType(ProductTypes.Application) .AutodeskProduct(AutodeskProducts.Revit) .Name("RevitAddin") - .AppVersion("1.0.0"); + .AppVersion("1.0.0") + .ProductType(ProductTypes.Application); CompanyDetails .Create("Company Name") - .Email("email") - .Url("url"); + .Url("url") + .Email("email"); Components .CreateEntry("Revit 2021") diff --git a/Autodesk.PackageBuilder/Utils/RevitUtils.cs b/Autodesk.PackageBuilder/Utils/RevitUtils.cs index c787faa..4b1f239 100644 --- a/Autodesk.PackageBuilder/Utils/RevitUtils.cs +++ b/Autodesk.PackageBuilder/Utils/RevitUtils.cs @@ -6,7 +6,7 @@ public static class RevitUtils { /// - /// Set and . + /// Set AutodeskProduct to and ProductType to . /// /// /// diff --git a/CHANGELOG.md b/CHANGELOG.md index b50a942..ec5c40b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Test `RevitAddInsBuilder` - Test `PackageContentsBuilder` - Add `AssertBuilderUtils` +- Test `RevitUtils` ## [1.0.5] / 2021-12-21 - Update Build Project From 7b673d06387e76ab03d2aa7b9ce31d8d16ae2e54 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Wed, 6 Dec 2023 10:26:35 -0300 Subject: [PATCH 12/12] Update `BuilderUtils` --- .../BuilderUtils_Tests.cs | 23 ++++++++++++++++++- Autodesk.PackageBuilder/Utils/BuilderUtils.cs | 13 +++++++++++ CHANGELOG.md | 3 ++- README.md | 16 +++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs b/Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs index 8bc62e0..55e3bf3 100644 --- a/Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs +++ b/Autodesk.PackageBuilder.Tests/BuilderUtils_Tests.cs @@ -29,6 +29,17 @@ public void Build_ShouldBe_NotNull_Config() Assert.IsTrue(builder.Config); } + [TestCase("path")] + [TestCase("path2")] + [TestCase("path3")] + public void Build_ShouldBe_Config_Build(string path) + { + var builder = BuilderUtils.Build((build) => { build.Config = true; }); + builder.Build(path); + Assert.IsTrue(builder.Config); + Assert.AreEqual(builder.Path, path); + } + [TestCase("path")] [TestCase("path2")] [TestCase("path3")] @@ -41,11 +52,21 @@ public void Build_ShouldBe_Path(string path) [TestCase("path")] [TestCase("path2")] [TestCase("path3")] - public void Build_ShouldBe_Path_Config(string path) + public void Build_ShouldBe_Config_Path(string path) { var builder = BuilderUtils.Build((build) => { build.Config = true; }, path); Assert.IsTrue(builder.Config); Assert.AreEqual(builder.Path, path); } + + [TestCase("path")] + [TestCase("path2")] + [TestCase("path3")] + public void Build_ShouldBe_Path_Config(string path) + { + var builder = BuilderUtils.Build(path, (build) => { build.Config = true; }); + Assert.IsTrue(builder.Config); + Assert.AreEqual(builder.Path, path); + } } } \ No newline at end of file diff --git a/Autodesk.PackageBuilder/Utils/BuilderUtils.cs b/Autodesk.PackageBuilder/Utils/BuilderUtils.cs index b0d4456..98ebc8a 100644 --- a/Autodesk.PackageBuilder/Utils/BuilderUtils.cs +++ b/Autodesk.PackageBuilder/Utils/BuilderUtils.cs @@ -32,6 +32,19 @@ public static TBuilder Build(string path) return builder; } + /// + /// Create a new instance of the type, the instance, and . + /// + /// + /// + /// + /// + public static TBuilder Build(string path, Action config) + where TBuilder : IBuilder, new() + { + return Build(config, path); + } + /// /// Create a new instance of the type, the instance, and . /// diff --git a/CHANGELOG.md b/CHANGELOG.md index ec5c40b..072e7d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [1.0.6] / 2023-11-24 +## [1.0.6] / 2023-11-24 - 2023-12-06 ### Features - `Tests` project. +- Update `BuilderUtils` to return instance and features (#16). ### PackageBuilder - Enable `DocumentationFile` in package. - Update `BuilderUtils` to return instance. diff --git a/README.md b/README.md index 1a37897..32e3f23 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,15 @@ BuilderUtils.Build("PackageContents.xml"); // or +BuilderUtils.Build("PackageContents.xml", builder => {...}); + +// or + BuilderUtils.Build(builder => {...}, "PackageContents.xml"); + +// or + +BuilderUtils.Build(builder => {...}).Build("PackageContents.xml"); ``` ### Create RevitAddin.addin @@ -197,7 +205,15 @@ BuilderUtils.Build("RevitAddin.addin"); // or +BuilderUtils.Build("RevitAddin.addin", builder => {...}); + +// or + BuilderUtils.Build(builder => {...}, "RevitAddin.addin"); + +// or + +BuilderUtils.Build(builder => {...}).Build("RevitAddin.addin"); ``` ## Package Inspiration / Reference