Skip to content

Commit

Permalink
Build with source link information
Browse files Browse the repository at this point in the history
  • Loading branch information
colinangusmackay committed Jul 17, 2023
1 parent 66a5d28 commit 8950c06
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 20 deletions.
11 changes: 4 additions & 7 deletions release-notes/wip-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

Date: ???

### Bugs

### Features

### Miscellaneous

### Dependabot
### Initial Release

* IClock interface
* Regular Clock + Dependency Injection extensions
* Fake Clock for testing with a fixed `DateTime`


2 changes: 2 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ dotnet_diagnostic.ca2241.severity = error
dotnet_diagnostic.cs0108.severity = error

dotnet_diagnostic.sa1101.severity = silent # Prefix local calls with this.
dotnet_diagnostic.sa1309.severity = silent # Field names must not begin with underscore.
dotnet_diagnostic.sa1633.severity = silent # The file header is missing or not located at the top of the file.
dotnet_diagnostic.sa1642.severity = silent # Constructor summary documentation must begin with standard text.

dotnet_diagnostic.sx1101.severity = warning # Do not prefix local calls with 'this.'
dotnet_diagnostic.sx1309.severity = warning # Field names must begin with underscore.

dotnet_diagnostic.ide0005.severity = warning
dotnet_diagnostic.ide0010.severity = warning
Expand Down
8 changes: 8 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@
<ItemGroup>
<AdditionalFiles Include="../stylecop.json" Link="stylecop.json" />
</ItemGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
</Project>
6 changes: 3 additions & 3 deletions src/Stravaig.Clock.Tests/ClockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public ClockTests()
// savings time so the offset will be consistent year round.
_testTimeZone = FakeLocalTimeZone.Set("Africa/Johannesburg");
}

public void Dispose()
{
_testTimeZone.Dispose();
Expand All @@ -27,7 +27,7 @@ public void LocalNowIsLocal()
var start = DateTime.Now;
var testTime = Clock.Instance.LocalNow;
var end = DateTime.Now;

Console.WriteLine($"Test time is {testTime:O}");
testTime.Kind.ShouldBe(DateTimeKind.Local);
testTime.ShouldBeGreaterThanOrEqualTo(start);
Expand All @@ -46,7 +46,7 @@ public void UtcNowIsUtc()
testTime.ShouldBeGreaterThanOrEqualTo(start);
testTime.ShouldBeLessThanOrEqualTo(end);
}

[Test]
public void TodayIsTodayLocally()
{
Expand Down
22 changes: 13 additions & 9 deletions src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public class FakeLocalTimeZone : IDisposable
{
private readonly TimeZoneInfo _actualLocalTimeZoneInfo;

private static void SetLocalTimeZone(TimeZoneInfo timeZoneInfo)
private FakeLocalTimeZone(TimeZoneInfo timeZoneInfo)
{
Console.WriteLine($"Setting Timezone to {timeZoneInfo.DisplayName}.");
typeof(TimeZoneInfo).AsDynamicType().s_cachedData._localTimeZone = timeZoneInfo;
_actualLocalTimeZoneInfo = TimeZoneInfo.Local;
SetLocalTimeZone(timeZoneInfo);
}

public static FakeLocalTimeZone Set(string name)
Expand All @@ -19,16 +19,20 @@ public static FakeLocalTimeZone Set(string name)
return new FakeLocalTimeZone(tz);
}

private FakeLocalTimeZone(TimeZoneInfo timeZoneInfo)
{
_actualLocalTimeZoneInfo = TimeZoneInfo.Local;
SetLocalTimeZone(timeZoneInfo);
}

/// <summary>
/// Resets the timezone information to what it was.
/// </summary>
public void Dispose()
{
Console.WriteLine($"Resetting Timezone to {_actualLocalTimeZoneInfo.DisplayName}.");
SetLocalTimeZone(_actualLocalTimeZoneInfo);
GC.SuppressFinalize(this);
}

private static void SetLocalTimeZone(TimeZoneInfo timeZoneInfo)
{
Console.WriteLine($"Setting Timezone to {timeZoneInfo.DisplayName}.");
typeof(TimeZoneInfo).AsDynamicType().s_cachedData._localTimeZone = timeZoneInfo;
}

}

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line

Check warning on line 38 in src/Stravaig.Clock.Tests/FakeLocalTimeZone.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Release

A closing brace should not be preceded by a blank line
2 changes: 1 addition & 1 deletion src/Stravaig.Clock.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__BuildAndDeploy", "__Build
..\Reset-WipReleaseNotes.ps1 = ..\Reset-WipReleaseNotes.ps1
..\Set-Version.ps1 = ..\Set-Version.ps1
..\version.txt = ..\version.txt
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__Documentation", "__Documentation", "{61C05782-A253-4EDD-9463-04912EB73870}"
Expand All @@ -36,7 +37,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stravaig.Clock.Tests", "Str
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__Style", "__Style", "{9A7A82FB-082B-43F9-B843-4C3C44E461AF}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
.editorconfig = .editorconfig
stylecop.json = stylecop.json
EndProjectSection
Expand Down

0 comments on commit 8950c06

Please sign in to comment.