Skip to content

Commit

Permalink
More c# /.net8 clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
damianh committed Nov 19, 2023
1 parent 3991e3a commit da3e096
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ void RecurseChildren(
}
else
{
using var sha256 = SHA256.Create();
var bytes = Encoding.UTF8.GetBytes(value!);
var hash = sha256.ComputeHash(bytes);
var hash = SHA256.HashData(bytes);
var valueHash = Convert.ToBase64String(hash);
var configInfo = new ConfigItem(child.Path, valueHash, provider.ToString()!);
infos.Add(configInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ IScenarioBuilder IScenarioThenNoEventsStateBuilder.Expect(object outcome)

Scenario IScenarioBuilder.Build() => this;

public ScenarioPassed Pass(object result) => new(this);
public ScenarioPassed Pass(object _) => new(this);

public ScenarioRecordedOtherEvents ButRecordedOtherEvents(IReadOnlyCollection<RecordedEvent> other) =>
new(this, other);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace Logicality.EventSourcing.Domain;

public class NamespaceBasedGuidGenerator
{
private static readonly Tuple<int, int>[] ByteOrderPairsToSwap = {
private static readonly Tuple<int, int>[] ByteOrderPairsToSwap = [
Tuple.Create(0, 3),
Tuple.Create(1, 2),
Tuple.Create(4, 5),
Tuple.Create(6, 7),
};
Tuple.Create(6, 7)
];

private readonly byte[] _namespace;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ public void ResetHasExpectedResult()
public class EventRecorderWithRecordedEvents
{
private readonly EventRecorder _sut;
private readonly object[] _recorded = {
new(), new(),
};
private readonly object[] _recorded = [new(), new()];

public EventRecorderWithRecordedEvents()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ public void ApplyHasExpectedResult()

private class Entity : EventSourcedEntity
{
private readonly List<object> _restoredFromEvents;
private readonly List<object> _restoredFromEvents = [];

public Entity()
{
_restoredFromEvents = new List<object>();
On<Event>(e => _restoredFromEvents.Add(e));
On<Event>(_restoredFromEvents.Add);
}

public object[] RestoredFromEvents => _restoredFromEvents.ToArray();
Expand Down Expand Up @@ -121,12 +120,11 @@ public void ApplyHasExpectedResult()

private class Entity : EventSourcedEntity
{
private readonly List<object> _restoredFromEvents;
private readonly List<object> _restoredFromEvents = [];

public Entity()
{
_restoredFromEvents = new List<object>();
On<Event>(e => _restoredFromEvents.Add(e));
On<Event>(_restoredFromEvents.Add);
}

public object[] RestoredFromEvents => _restoredFromEvents.ToArray();
Expand Down
13 changes: 4 additions & 9 deletions libs/github/tests/Actions.Workflow.Tests/Example.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using Xunit;
using Xunit.Abstractions;
namespace Logicality.GitHub.Actions.Workflow;

namespace Logicality.GitHub.Actions.Workflow;

public class Example(ITestOutputHelper outputHelper)
public class Example()
{
[Fact]
public void ReadMeExample()
{
var workflow = new Workflow("my-workflow");
Expand All @@ -26,9 +22,8 @@ public void ReadMeExample()
.Run("./build.ps1")
.Shell(Shells.Pwsh);

var yaml = workflow.GetYaml();
var fileName = "my-workflow.yaml";

outputHelper.WriteLine(yaml);
var filePath = $"../workflows/{fileName}";
workflow.WriteYaml(filePath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static LoggerConfiguration WriteHostedServiceMessagesToConsole(this Logge
{
configuration
.Filter
.ByIncludingOnly(e => Matching.FromSource(typeof(HostedServiceWrapper).FullName)(e))
.ByIncludingOnly(e => Matching.FromSource(typeof(HostedServiceWrapper).FullName!)(e))
.WriteTo
.Console(
outputTemplate:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task Parallel_calls_should_all_get_different_ports()
tasks.Add(Task.Run(() =>
{
var port = PortFinder.GetNext();
ports.AddOrUpdate(port, _ => null, (_, _) => null);
ports.AddOrUpdate(port, _ => null!, (_, _) => null!);
outputHelper.WriteLine(port.ToString());
}));
}
Expand Down

0 comments on commit da3e096

Please sign in to comment.