Skip to content

Commit

Permalink
Merge pull request #333 from rasmus/nullable
Browse files Browse the repository at this point in the history
Implement nullable
  • Loading branch information
rasmus authored Jan 11, 2024
2 parents b488698 + 7102072 commit 62bc384
Show file tree
Hide file tree
Showing 317 changed files with 731 additions and 1,002 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Rasmus Mikkelsen
Copyright (c) 2021-2024 Rasmus Mikkelsen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Here are some examples of common used arguments to Bake
```
MIT License
Copyright (c) 2021-2023 Rasmus Mikkelsen
Copyright (c) 2021-2024 Rasmus Mikkelsen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions Source/Bake.Tests/Bake.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Include="WireMock.Net" Version="1.5.46" />
</ItemGroup>

Expand Down
11 changes: 3 additions & 8 deletions Source/Bake.Tests/ExplicitTests/GitHubReleaseCookTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,11 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Bake.Cooking.Cooks.GitHub;
using Bake.Core;
using Bake.Services;
Expand Down Expand Up @@ -67,7 +62,7 @@ public async Task CreateRelease()

// Arrange
var result = await Sut.CookAsync(
null,
null!,
recipe,
CancellationToken.None);

Expand All @@ -79,7 +74,7 @@ private static string GetToken()
{
return new ConfigurationBuilder()
.AddUserSecrets<GitHubReleaseCookTests>()
.Build()["github.token"];
.Build()["github.token"]!;
}

protected override IServiceCollection Configure(IServiceCollection serviceCollection)
Expand Down
4 changes: 2 additions & 2 deletions Source/Bake.Tests/ExplicitTests/GitHubTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -96,7 +96,7 @@ private static string GetToken()
{
return new ConfigurationBuilder()
.AddUserSecrets<GitHubReleaseCookTests>()
.Build()["github:token"];
.Build()["github:token"]!;
}

protected override IServiceCollection Configure(IServiceCollection serviceCollection)
Expand Down
2 changes: 1 addition & 1 deletion Source/Bake.Tests/Files/license.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 6 additions & 24 deletions Source/Bake.Tests/Helpers/BakeTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,11 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Bake.Core;
using Bake.Extensions;
using Bake.Services;
Expand All @@ -38,9 +33,9 @@ namespace Bake.Tests.Helpers
{
public abstract class BakeTest : TestProject
{
private CancellationTokenSource _timeout;
private CancellationTokenSource? _timeout;

private List<Release> _releases;
private List<Release> _releases = null!;
protected IReadOnlyCollection<Release> Releases => _releases;

protected BakeTest(string projectName) : base(projectName)
Expand All @@ -57,7 +52,7 @@ public void SetUpBakeTest()
[TearDown]
public void TearDownBakeTest()
{
_timeout.Dispose();
_timeout?.Dispose();
_timeout = null;
}

Expand Down Expand Up @@ -132,20 +127,7 @@ public Task CreateReleaseAsync(
GitHubInformation gitHubInformation,
CancellationToken cancellationToken)
{
return Task.FromResult<PullRequestInformation>(null);
}

public Task<IReadOnlyCollection<Commit>> GetCommitsAsync(string baseSha, string headSha,
GitHubInformation gitHubInformation,
CancellationToken cancellationToken)
{
var commits = new List<Commit>
{
new("Wrote some awesome tests", "c2dbe6e", DateTimeOffset.Now, new Author("Rasmus Mikkelsen", "[email protected]")),
new("Got it working", "4d79e4e", DateTimeOffset.Now, new Author("Rasmus Mikkelsen", "[email protected]"))
};

return Task.FromResult<IReadOnlyCollection<Commit>>(commits);
return Task.FromResult<PullRequestInformation?>(null);
}

public Task<IReadOnlyCollection<PullRequest>> GetPullRequestsAsync(string baseSha,
Expand All @@ -156,7 +138,7 @@ public Task<IReadOnlyCollection<PullRequest>> GetPullRequestsAsync(string baseSh
throw new NotImplementedException();
}

public Task<PullRequest> GetPullRequestAsync(
public Task<PullRequest?> GetPullRequestAsync(
GitHubInformation gitHubInformation,
int number,
CancellationToken cancellationToken)
Expand Down
2 changes: 1 addition & 1 deletion Source/Bake.Tests/Helpers/DockerArguments.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions Source/Bake.Tests/Helpers/DockerHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -70,8 +70,8 @@ await Client.Containers.StartContainerAsync(
null,
cancellationToken);

var autoResetEvent = new AutoResetEvent(false);
Task.Run(async () =>
// TODO: What to do here?
var _ = Task.Run(async () =>
{
await Client.Containers.GetContainerLogsAsync(
createContainerResponse.ID,
Expand Down
2 changes: 1 addition & 1 deletion Source/Bake.Tests/Helpers/GitHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Source/Bake.Tests/Helpers/NuGetHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Source/Bake.Tests/Helpers/OctopusDeployMock.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 3 additions & 7 deletions Source/Bake.Tests/Helpers/ProjectHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,24 +20,20 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.IO;
using System.Linq;

namespace Bake.Tests.Helpers
{
public static class ProjectHelper
{
public static string GetRoot()
{
var uri = new Uri(typeof(LicenseHeader).Assembly.CodeBase);
var uri = new Uri(typeof(LicenseHeader).Assembly.Location);
var directory = Path.GetDirectoryName(uri.LocalPath);

while (true)
{
if (string.IsNullOrEmpty(directory))
{
throw new Exception($"Could not find repository root from '{typeof(LicenseHeader).Assembly.CodeBase}'");
throw new Exception($"Could not find repository root from '{typeof(LicenseHeader).Assembly.Location}'");
}

var isRepositoryRoot = Directory.GetFiles(directory)
Expand Down
16 changes: 7 additions & 9 deletions Source/Bake.Tests/Helpers/ServiceTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.Threading;
using Bake.Core;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
Expand All @@ -32,13 +30,13 @@ namespace Bake.Tests.Helpers
public abstract class ServiceTest<T> : TestProject
where T : class
{
private Lazy<T> _lazySut;
private ServiceProvider _serviceProvider;
private Lazy<T>? _lazySut;
private ServiceProvider? _serviceProvider;

protected T Sut => _lazySut.Value;
protected IServiceProvider ServiceProvider => _serviceProvider;
protected T Sut => _lazySut!.Value;
protected IServiceProvider ServiceProvider => _serviceProvider!;

protected ServiceTest(string projectName) : base(projectName)
protected ServiceTest(string? projectName) : base(projectName)
{
}

Expand All @@ -51,7 +49,7 @@ public void SetUpServiceTest()
[TearDown]
public void TearDownServiceTest()
{
_serviceProvider.Dispose();
_serviceProvider?.Dispose();
_serviceProvider = null;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Bake.Tests/Helpers/SocketHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -35,7 +35,7 @@ public static int FreeTcpPort()
{
var ipEndPoint = new IPEndPoint(IPAddress.Loopback, 0);
socket.Bind(ipEndPoint);
ipEndPoint = (IPEndPoint)socket.LocalEndPoint;
ipEndPoint = (IPEndPoint)socket.LocalEndPoint!;
port = ipEndPoint.Port;
}
finally
Expand Down
2 changes: 1 addition & 1 deletion Source/Bake.Tests/Helpers/TestEnvironmentVariables.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 4 additions & 5 deletions Source/Bake.Tests/Helpers/TestFor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,7 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using AutoFixture;
using Bake.Core;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -33,9 +32,9 @@ namespace Bake.Tests.Helpers
{
public class TestFor<T> : TestIt
{
private Lazy<T> _lazySut;
private ServiceProvider _serviceProvider;
private Logger _logger;
private Lazy<T> _lazySut = null!;
private ServiceProvider _serviceProvider = null!;
private Logger _logger = null!;
protected T Sut => _lazySut.Value;

[SetUp]
Expand Down
17 changes: 6 additions & 11 deletions Source/Bake.Tests/Helpers/TestIt.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2021-2023 Rasmus Mikkelsen
// Copyright (c) 2021-2024 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,11 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using NSubstitute;
Expand All @@ -36,9 +31,9 @@ namespace Bake.Tests.Helpers
{
public abstract class TestIt
{
private List<string> _filesToDelete;
private List<string> _filesToDelete = null!;

protected IFixture Fixture { get; private set; }
protected IFixture Fixture { get; private set; } = null!;

[SetUp]
public void SetUpTestIt()
Expand All @@ -53,9 +48,9 @@ public void TearDownTestIt()
{
foreach (var file in _filesToDelete)
{
if (System.IO.File.Exists(file))
if (File.Exists(file))
{
System.IO.File.Delete(file);
File.Delete(file);
}
}
}
Expand Down Expand Up @@ -100,7 +95,7 @@ protected async Task<string> ReadEmbeddedAsync(
.ToList();
var resourceName = resourceNames.Single(n => n.EndsWith(fileEnding, StringComparison.OrdinalIgnoreCase));
await using var stream = assembly.GetManifestResourceStream(resourceName);
using var streamReader = new StreamReader(stream);
using var streamReader = new StreamReader(stream!);
return await streamReader.ReadToEndAsync();
}

Expand Down
Loading

0 comments on commit 62bc384

Please sign in to comment.