diff --git a/build/Build.cs b/build/Build.cs index 764bae9..95a36df 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,4 +1,5 @@ // ReSharper disable RedundantUsingDirective + using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.IO; @@ -16,19 +17,22 @@ class Build : NukeBuild { const string CiBranchNameEnvVariable = "OCTOVERSION_CurrentBranch"; + [Parameter( + "Whether to auto-detect the branch name - this is okay for a local build, but should not be used under CI.")] + readonly bool AutoDetectBranch = IsLocalBuild; + readonly Configuration Configuration = Configuration.Release; [Solution] readonly Solution Solution; - - [Parameter("Whether to auto-detect the branch name - this is okay for a local build, but should not be used under CI.")] - readonly bool AutoDetectBranch = IsLocalBuild; - - [Parameter("Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable " + CiBranchNameEnvVariable + ".", Name = CiBranchNameEnvVariable)] - string BranchName { get; set; } - [OctoVersion(BranchParameter = nameof(BranchName), AutoDetectBranchParameter = nameof(AutoDetectBranch))] + [OctoVersion(BranchParameter = nameof(BranchName), AutoDetectBranchParameter = nameof(AutoDetectBranch))] public OctoVersionInfo OctoVersionInfo; + [Parameter( + "Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable " + + CiBranchNameEnvVariable + ".", Name = CiBranchNameEnvVariable)] + string BranchName { get; set; } + AbsolutePath SourceDirectory => RootDirectory / "source"; AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; AbsolutePath LocalPackagesDirectory => RootDirectory / ".." / "LocalPackages"; @@ -105,4 +109,4 @@ class Build : NukeBuild /// - Microsoft VisualStudio https://nuke.build/visualstudio /// - Microsoft VSCode https://nuke.build/vscode public static int Main() => Execute(x => x.Default); -} +} \ No newline at end of file diff --git a/build/Configuration.cs b/build/Configuration.cs index 9b22a3b..8c20b1c 100644 --- a/build/Configuration.cs +++ b/build/Configuration.cs @@ -1,14 +1,10 @@ using System.ComponentModel; -using Nuke.Common.Tooling; [TypeConverter(typeof(TypeConverter))] public class Configuration : Enumeration { - public static Configuration Debug = new Configuration { Value = nameof(Debug) }; - public static Configuration Release = new Configuration { Value = nameof(Release) }; + public static Configuration Debug = new() { Value = nameof(Debug) }; + public static Configuration Release = new() { Value = nameof(Release) }; - public static implicit operator string(Configuration configuration) - { - return configuration.Value; - } -} + public static implicit operator string(Configuration configuration) => configuration.Value; +} \ No newline at end of file diff --git a/source/Octopus.Time/FixedClock.cs b/source/Octopus.Time/FixedClock.cs index 28eb490..537374d 100644 --- a/source/Octopus.Time/FixedClock.cs +++ b/source/Octopus.Time/FixedClock.cs @@ -6,16 +6,34 @@ public class FixedClock : IClock { private DateTimeOffset now; - public FixedClock(DateTimeOffset now) => this.now = now; + public FixedClock(DateTimeOffset now) + { + this.now = now; + } - public void Set(DateTimeOffset value) => this.now = value; + public DateTimeOffset GetUtcTime() + { + return Clone().now.ToUniversalTime(); + } - public void WindForward(TimeSpan time) => this.now = this.now.Add(time); + public DateTimeOffset GetLocalTime() + { + return Clone().now.ToLocalTime(); + } - public DateTimeOffset GetUtcTime() => this.Clone().now.ToUniversalTime(); + public void Set(DateTimeOffset value) + { + now = value; + } - public DateTimeOffset GetLocalTime() => this.Clone().now.ToLocalTime(); + public void WindForward(TimeSpan time) + { + now = now.Add(time); + } - private FixedClock Clone() => (FixedClock) this.MemberwiseClone(); + private FixedClock Clone() + { + return (FixedClock)MemberwiseClone(); + } } -} +} \ No newline at end of file diff --git a/source/Octopus.Time/SystemClock.cs b/source/Octopus.Time/SystemClock.cs index bd6d22a..11cbce9 100644 --- a/source/Octopus.Time/SystemClock.cs +++ b/source/Octopus.Time/SystemClock.cs @@ -4,8 +4,14 @@ namespace Octopus.Time { public class SystemClock : IClock { - public DateTimeOffset GetUtcTime() => DateTimeOffset.UtcNow; + public DateTimeOffset GetUtcTime() + { + return DateTimeOffset.UtcNow; + } - public DateTimeOffset GetLocalTime() => DateTimeOffset.Now; + public DateTimeOffset GetLocalTime() + { + return DateTimeOffset.Now; + } } -} +} \ No newline at end of file