Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
max-eroshkin committed Mar 2, 2022
2 parents 51ff420 + ea45145 commit dfaf0ca
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 3 deletions.
10 changes: 9 additions & 1 deletion source/BuilderTests/BuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public void WriteFile()
BuilderUtils.Build(
c =>
{
c.Directives
.Define("var1", "15")
.Include("file.iss")
.Include("<file.iss>")
.FreeText(";comments")
.Undef("var1");

c.Setup.Create("BimTools.Support")
.AppVersion("1.2.5.1634640046")
.DefaultDirName(@"{userappdata}\Autodesk\Revit\Addins\2019\SupportTools")
Expand Down Expand Up @@ -105,7 +112,8 @@ public void TestBuilderContainsAllAvailableSections()
return (string)nameProperty.GetValue(sectionBuilder);
});

classSections.Should().OnlyContain(x => testBuilderSections.Any(t => t.Name == x));
classSections.Where(x => x != "Directives")
.Should().OnlyContain(x => testBuilderSections.Any(t => t.Name == x));
}

private static bool IsNullable(Type type)
Expand Down
52 changes: 52 additions & 0 deletions source/InnoSetup.ScriptBuilder/Builder/DirectivesBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace InnoSetup.ScriptBuilder
{
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

public class DirectivesBuilder
{
private readonly StringBuilder _builder = new();

public string SectionName => "Directives";

public void Write(TextWriter writer)
{
if (_builder.Length > 0)
writer.Write(_builder);
}

public DirectivesBuilder Include(string filePath)
{
if (Regex.IsMatch(filePath, @"^\<.+\>$"))
_builder.AppendFormat("#include {0}", filePath);
else
_builder.AppendFormat("#include \"{0}\"", filePath);

_builder.AppendLine();

return this;
}

public DirectivesBuilder Define(string variable, string experession)
{
_builder.AppendFormat("#define {0} {1}", variable, experession);
_builder.AppendLine();
return this;
}

public DirectivesBuilder Undef(string variable)
{
_builder.AppendFormat("#undef {0}", variable);
_builder.AppendLine();
return this;
}

public DirectivesBuilder FreeText(string text)
{
_builder.Append(text);
_builder.AppendLine();
return this;
}
}
}
3 changes: 3 additions & 0 deletions source/InnoSetup.ScriptBuilder/Builder/IssBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ public abstract class IssBuilder : IBuilder

public GenericSections Sections { get; } = new();

public DirectivesBuilder Directives { get; } = new();

public void Write(TextWriter writer)
{
Directives.Write(writer);
_setup.Write(writer);
_components.Write(writer);
_tasks.Write(writer);
Expand Down
3 changes: 2 additions & 1 deletion source/InnoSetup.ScriptBuilder/Constants/ComponentFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum ComponentFlags
Restart = 0x2,
DisableNoUninstallWarning = 0x4,
Exclusive = 0x8,
DontInheritCheck = 0x10
DontInheritCheck = 0x10,
CheckAbleAlone = 0x20
}
}
2 changes: 1 addition & 1 deletion source/InnoSetup.ScriptBuilder/Directory.Build.Props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
Expand Down

0 comments on commit dfaf0ca

Please sign in to comment.