Skip to content

Commit

Permalink
added Akka.Analyzer reference (#7031)
Browse files Browse the repository at this point in the history
* added Akka.Analyzer reference; bumped Msft.Ext minVer to 7.0

* cleaning up some code and fixes

* upgrade to nuget-supported version of Akka.Analyzers

* upgrade to Akka.Analyzers v0.1.2

* fixed `PipeTo` errors

* reverted MSFT.EXT bump to 7.0
  • Loading branch information
Aaronontheweb authored Jan 3, 2024
1 parent 2633f91 commit 1a06ec1
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 62 deletions.
2 changes: 2 additions & 0 deletions src/Akka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{10C5B1E8-15B5-4EB3-81AE-1FC054FE1305}"
ProjectSection(SolutionItems) = preProject
..\build.fsx = ..\build.fsx
Directory.Build.props = Directory.Build.props
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Contrib", "Contrib", "{588C1513-FAB6-42C3-B6FC-3485F13620CF}"
Expand Down
3 changes: 3 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ If you want to see the [full set of changes made in Akka.NET v1.5.14, click here
| 1 | 227 | 25 | Drew |
| 1 | 1 | 1 | szaliszali |</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup Label="Analyzers">
<PackageReference Include="Akka.Analyzers" Version="0.1.2" PrivateAssets="all" />
</ItemGroup>
<!-- SourceLink support for all Akka.NET projects -->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
Expand Down
4 changes: 4 additions & 0 deletions src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ public override int GetNrOfInstances(ActorSystem system)
/// <inheritdoc cref="RouterConfig.CreateRouterActor"/>
public override ActorBase CreateRouterActor()
{
#pragma warning disable AK1000
return new ClusterRouterPoolActor(Local.SupervisorStrategy, Settings);
#pragma warning restore AK1000
}

/// <summary>
Expand Down Expand Up @@ -445,7 +447,9 @@ public override IEnumerable<string> GetPaths(ActorSystem system)
/// <inheritdoc cref="RouterConfig.CreateRouterActor"/>
public override ActorBase CreateRouterActor()
{
#pragma warning disable AK1000
return new ClusterRouterGroupActor(Settings);
#pragma warning restore AK1000
}

/// <summary>
Expand Down
6 changes: 4 additions & 2 deletions src/core/Akka.Docs.Tests/Streams/StreamRefsDocTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ public DataSource()
{
Receive<RequestLogs>(request =>
{
var sender = Sender;
// create a source
StreamLogs(request.StreamId)
// materialize it using stream refs
.RunWith(StreamRefs.SourceRef<string>(), Context.System.Materializer())
// and send to sender
.PipeTo(Sender, success: sourceRef => new LogsOffer(request.StreamId, sourceRef));
.PipeTo(sender, success: sourceRef => new LogsOffer(request.StreamId, sourceRef));
});
}

Expand Down Expand Up @@ -96,12 +97,13 @@ public DataReceiver()
{
// obtain a source you want to offer
var sink = LogsSinksFor(prepare.Id);
var sender = this.Sender;

// materialize sink ref (remote is source data for us)
StreamRefs.SinkRef<string>()
.To(sink)
.Run(Context.System.Materializer())
.PipeTo(Sender, success: sinkRef => new MeasurementsSinkReady(prepare.Id, sinkRef));
.PipeTo(sender, success: sinkRef => new MeasurementsSinkReady(prepare.Id, sinkRef));
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/Akka.Docs.Tests/Utilities/CircuitBreakerDocSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public DangerousActorCallProtection()

Receive<string>(str => str.Equals("is my middle name"), _ =>
{
breaker.WithCircuitBreaker(() => Task.FromResult(dangerousCall)).PipeTo(Sender);
var sender = this.Sender;
breaker.WithCircuitBreaker(() => Task.FromResult(dangerousCall)).PipeTo(sender);
});

Receive<string>(str => str.Equals("block for me"), _ =>
Expand Down
3 changes: 2 additions & 1 deletion src/core/Akka.Streams.Tests/Dsl/StreamRefsSerializerSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ public ProducerActor(string data)
_data = data;
Receive<RequestStream>(_ =>
{
var sender = this.Sender;
// create a source
StreamLogs()
// materialize it using stream refs
.RunWith(StreamRefs.SourceRef<string>(), Context.System.Materializer())
// and send to sender
.PipeTo(Sender, success: sourceRef => new EnvelopedStream(sourceRef));
.PipeTo(sender, success: sourceRef => new EnvelopedStream(sourceRef));
});

Receive<string>(_ => Sender.Tell("pong"));
Expand Down
24 changes: 16 additions & 8 deletions src/core/Akka.Streams.Tests/Dsl/StreamRefsSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,31 @@ protected override bool Receive(object message)
*/
var source = Source.From(new[] { "hello", "world" });
var aref = source.RunWith(StreamRefs.SourceRef<string>(), _materializer);
aref.PipeTo(Sender);
var sender = this.Sender;
aref.PipeTo(sender);
return true;
}
case "give-infinite":
{
var source = Source.From(Enumerable.Range(1, int.MaxValue).Select(i => "ping-" + i));
var t = source.ToMaterialized(StreamRefs.SourceRef<string>(), Keep.Right).Run(_materializer);
t.PipeTo(Sender);
var sender = this.Sender;
t.PipeTo(sender);
return true;
}
case "give-fail":
{
var r = Source.Failed<string>(new Exception("Boom!"))
.RunWith(StreamRefs.SourceRef<string>(), _materializer);
r.PipeTo(Sender);
var sender = this.Sender;
r.PipeTo(sender);
return true;
}
case "give-complete-asap":
{
var r = Source.Empty<string>().RunWith(StreamRefs.SourceRef<string>(), _materializer);
r.PipeTo(Sender);
var sender = this.Sender;
r.PipeTo(sender);
return true;
}
case "give-subscribe-timeout":
Expand All @@ -85,7 +89,8 @@ protected override bool Receive(object message)
.ToMaterialized(StreamRefs.SourceRef<string>(), Keep.Right)
.WithAttributes(StreamRefAttributes.CreateSubscriptionTimeout(TimeSpan.FromMilliseconds(500)))
.Run(_materializer);
r.PipeTo(Sender);
var sender = this.Sender;
r.PipeTo(sender);
return true;
}
case "receive":
Expand All @@ -96,13 +101,15 @@ protected override bool Receive(object message)
*/
var sink = StreamRefs.SinkRef<string>().To(Sink.ActorRef<string>(_probe, "<COMPLETE>", ex => new Status.Failure(ex)))
.Run(_materializer);
sink.PipeTo(Sender);
var sender = this.Sender;
sink.PipeTo(sender);
return true;
}
case "receive-ignore":
{
var sink = StreamRefs.SinkRef<string>().To(Sink.Ignore<string>()).Run(_materializer);
sink.PipeTo(Sender);
var sender = Sender;
sink.PipeTo(sender);
return true;
}
case "receive-subscribe-timeout":
Expand All @@ -111,7 +118,8 @@ protected override bool Receive(object message)
.WithAttributes(StreamRefAttributes.CreateSubscriptionTimeout(TimeSpan.FromMilliseconds(500)))
.To(Sink.ActorRef<string>(_probe, "<COMPLETE>", ex => new Status.Failure(ex)))
.Run(_materializer);
sink.PipeTo(Sender);
var sender = this.Sender;
sink.PipeTo(sender);
return true;
}
case "receive-32":
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.TestKit/Akka.TestKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftLibVersion)" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
<PackageReference Include="Nito.AsyncEx.Context" Version="5.1.2" />
<PackageReference Include="System.Linq.Async" Version="$(MicrosoftLibVersion)" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
</ItemGroup>

Expand Down
44 changes: 1 addition & 43 deletions src/core/Akka.Tests/Actor/ActorRefSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public async Task An_ActorRef_should_support_nested_ActorOfs()
var a = Sys.ActorOf(Props.Create(() => new NestingActor(Sys)));
a.Should().NotBeNull();

Func<Task> t1 = async () =>
var t1 = async () =>
{
var nested = (IActorRef) await a.Ask("any");
nested.Should().NotBeNull();
Expand Down Expand Up @@ -523,15 +523,6 @@ protected override bool Receive(object message)
}
}

private class FailingChildInnerActor : FailingInnerActor
{
public FailingChildInnerActor(ActorBase fail)
: base(fail)
{
Fail = new InnerActor();
}
}

private class OuterActor : ActorBase
{
private readonly IActorRef _inner;
Expand All @@ -555,39 +546,6 @@ protected override bool Receive(object message)
}
}

private class FailingOuterActor : ActorBase
{
private readonly IActorRef _inner;
protected ActorBase Fail;

public FailingOuterActor(IActorRef inner)
{
_inner = inner;
Fail = new InnerActor();
}
protected override bool Receive(object message)
{
if (message.ToString() == "self")
{
Sender.Tell(Self);
}
else
{
_inner.Forward(message);
}
return true;
}
}

private class FailingChildOuterActor : FailingOuterActor
{
public FailingChildOuterActor(IActorRef inner)
: base(inner)
{
Fail = new InnerActor();
}
}

private class PoisonPilledActor : ActorBase
{
protected override bool Receive(object message)
Expand Down
3 changes: 2 additions & 1 deletion src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,9 @@ public AsyncPipeToDelayActor()
{
ReceiveAsync<string>(async msg =>
{
var sender = Sender;
#pragma warning disable CS4014
Delayed(msg).PipeTo(Sender, Self);
Delayed(msg).PipeTo(sender);
#pragma warning restore CS4014

await Task.Delay(3000);
Expand Down
3 changes: 2 additions & 1 deletion src/core/Akka.Tests/Routing/RoutingSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public InlineRouterActor()
ReceiveAsync<string>(s => s == "start", async _ =>
{
var actor = Context.ActorOf(new RoundRobinPool(2).Props(Props.Create<InlineReceiverActor>()));
await actor.Ask("hello").PipeTo(Sender);
var sender = this.Sender;
await actor.Ask("hello").PipeTo(sender);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Akka.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="System.Threading.Channels" Version="$(MicrosoftLibVersion)" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="$(ConfigurationManagerVersion)"/>
</ItemGroup>

<ItemGroup>
<None Update="Util\MatchHandler\PartialHandlerArgumentsCapture.tt">
<Generator>TextTemplatingFileGenerator</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public FactorialBackend()
Receive<int>(n =>
{
log.Info($"{Self.Path} received factorial job [{n}]");

Factorial(n).PipeTo(Sender);
var sender = Sender;
Factorial(n).PipeTo(sender);
});
}

private async Task<(int, BigInteger)> Factorial(int n)
private static async Task<(int, BigInteger)> Factorial(int n)
{
var i = n;
var accumulator = new BigInteger(1);
Expand Down

0 comments on commit 1a06ec1

Please sign in to comment.