Fixed GetDeterministicHashCodeAsString (use InvariantCulture) (#41)
* Akka.Remote example * ToString(CultureInfo.InvariantCulture) * .
This commit is contained in:
@@ -30,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceSourceGenerat
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceConsumerForPnP", "src-examples\ProxyInterfaceConsumerForPnP\ProxyInterfaceConsumerForPnP.csproj", "{5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceConsumerForAkka", "src-examples\ProxyInterfaceConsumerForAkka\ProxyInterfaceConsumerForAkka.csproj", "{590908DF-A813-467A-94E4-3500020D0D54}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -65,6 +67,12 @@ Global
|
||||
{5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}.DebugAttach|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{590908DF-A813-467A-94E4-3500020D0D54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{590908DF-A813-467A-94E4-3500020D0D54}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{590908DF-A813-467A-94E4-3500020D0D54}.DebugAttach|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{590908DF-A813-467A-94E4-3500020D0D54}.DebugAttach|Any CPU.Build.0 = Debug|Any CPU
|
||||
{590908DF-A813-467A-94E4-3500020D0D54}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{590908DF-A813-467A-94E4-3500020D0D54}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -75,6 +83,7 @@ Global
|
||||
{6BEBFEB9-635F-44A2-949C-15DDDF0B7740} = {38BA087F-EDA1-4F8A-A140-85B84791B815}
|
||||
{1BDB9046-D6D1-4FB4-AAB5-F24E33EEAE0A} = {19009F5B-3267-45E2-A8B6-89F2AB47D72C}
|
||||
{5F7DA2C5-B908-4B57-9F5F-BADF1216D89C} = {38BA087F-EDA1-4F8A-A140-85B84791B815}
|
||||
{590908DF-A813-467A-94E4-3500020D0D54} = {38BA087F-EDA1-4F8A-A140-85B84791B815}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {585F071D-051D-441C-9C6B-226D9E15A1F5}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"RoslynExtensionsOptions": {
|
||||
"enableAnalyzersSupport": true
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using Akka.Actor;
|
||||
|
||||
namespace ProxyInterfaceConsumerForAkka.Interfaces
|
||||
{
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(LocalActorRefProvider))]
|
||||
public partial interface ILocalActorRefProvider
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Akka.Actor;
|
||||
using ProxyInterfaceConsumerForAkka.Interfaces;
|
||||
|
||||
namespace ProxyInterfaceConsumerForAkka;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
LocalActorRefProvider p = null;
|
||||
ILocalActorRefProvider proxy = new LocalActorRefProviderProxy(p);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Akka.Remote" Version="1.4.47" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.10.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
|
||||
<PackageReference Include="ProxyInterfaceGenerator" Version="0.0.24">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="TinyMapper" Version="3.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ProxyInterfaceSourceGenerator\ProxyInterfaceSourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||
</ItemGroup>-->
|
||||
|
||||
</Project>
|
||||
@@ -41,11 +41,9 @@ internal static class NamedTypeSymbolExtensions
|
||||
// str.AppendFormat("<{0}>", string.Join(", ", namedTypeSymbol.TypeArguments.OfType<INamedTypeSymbol>().Select(typeArg => typeArg.GetFullType())));
|
||||
//}
|
||||
|
||||
return namedTypeSymbol.OriginalDefinition.ToString();// str.ToString();
|
||||
return namedTypeSymbol.OriginalDefinition.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// See https://stackoverflow.com/questions/24157101/roslyns-gettypebymetadataname-and-generic-types
|
||||
/// </summary>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace ProxyInterfaceSourceGenerator.Extensions;
|
||||
|
||||
internal static class StringExtensions
|
||||
@@ -23,7 +25,7 @@ internal static class StringExtensions
|
||||
|
||||
int result = hash1 + hash2 * 1566083941;
|
||||
|
||||
return result.ToString().Replace('-', '_');
|
||||
return result.ToString(CultureInfo.InvariantCulture).Replace('-', '_');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ internal static class TypeSymbolExtensions
|
||||
}
|
||||
|
||||
public static bool IsString(this ITypeSymbol ts) =>
|
||||
ts.ToString() == "string" || ts.ToString() == "string?";
|
||||
ts.ToString().ToLowerInvariant() == "string" || ts.ToString().ToLowerInvariant() == "string?";
|
||||
|
||||
internal static bool IsClass(this ITypeSymbol ts) =>
|
||||
ts.IsReferenceType && ts.TypeKind == TypeKind.Class;
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using CSharp.SourceGenerators.Extensions;
|
||||
using CSharp.SourceGenerators.Extensions.Models;
|
||||
using CultureAwareTesting.xUnit;
|
||||
using FluentAssertions;
|
||||
using ProxyInterfaceSourceGenerator;
|
||||
|
||||
namespace ProxyInterfaceSourceGeneratorTests;
|
||||
|
||||
public class AkkaTests
|
||||
{
|
||||
private bool Write = true;
|
||||
|
||||
private readonly ProxyInterfaceCodeGenerator _sut;
|
||||
|
||||
public AkkaTests()
|
||||
{
|
||||
_sut = new ProxyInterfaceCodeGenerator();
|
||||
}
|
||||
|
||||
[CulturedFact("sv-SE")]
|
||||
public void GenerateFiles_Should_GenerateCorrectFiles()
|
||||
{
|
||||
// Arrange
|
||||
var fileNames = new[]
|
||||
{
|
||||
"ProxyInterfaceSourceGeneratorTests.Source.AkkaActor.ILocalActorRefProvider.g.cs",
|
||||
"Akka.Actor.LocalActorRefProviderProxy.g.cs"
|
||||
};
|
||||
|
||||
var path = "./Source/AkkaActor/ILocalActorRefProvider.cs";
|
||||
var sourceFile = new SourceFile
|
||||
{
|
||||
Path = path,
|
||||
Text = File.ReadAllText(path),
|
||||
AttributeToAddToInterface = new ExtraAttribute
|
||||
{
|
||||
Name = "ProxyInterfaceGenerator.Proxy",
|
||||
ArgumentList = "typeof(Akka.Actor.LocalActorRefProvider)"
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _sut.Execute(new[]
|
||||
{
|
||||
sourceFile
|
||||
});
|
||||
|
||||
// Assert
|
||||
result.Valid.Should().BeTrue();
|
||||
result.Files.Should().HaveCount(fileNames.Length + 1);
|
||||
|
||||
foreach (var fileName in fileNames.Select((fileName, index) => new { fileName, index }))
|
||||
{
|
||||
var builder = result.Files[fileName.index + 1]; // +1 means skip the attribute
|
||||
builder.Path.Should().EndWith(fileName.fileName);
|
||||
|
||||
if (Write) File.WriteAllText($"../../../Destination/AkkaGenerated/{fileName.fileName}", builder.Text);
|
||||
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/AkkaGenerated/{fileName.fileName}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
//----------------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
|
||||
namespace ProxyInterfaceSourceGeneratorTests.Source.AkkaActor
|
||||
{
|
||||
public partial class LocalActorRefProviderProxy : ILocalActorRefProvider
|
||||
{
|
||||
public Akka.Actor.LocalActorRefProvider _Instance { get; }
|
||||
|
||||
|
||||
public Akka.Actor.IActorRef DeadLetters { get => _Instance.DeadLetters; }
|
||||
|
||||
public Akka.Actor.IActorRef IgnoreRef { get => _Instance.IgnoreRef; }
|
||||
|
||||
public Akka.Actor.Deployer Deployer { get => _Instance.Deployer; }
|
||||
|
||||
public Akka.Actor.IInternalActorRef RootGuardian { get => _Instance.RootGuardian; }
|
||||
|
||||
public Akka.Actor.ActorPath RootPath { get => _Instance.RootPath; }
|
||||
|
||||
public Akka.Actor.Settings Settings { get => _Instance.Settings; }
|
||||
|
||||
public Akka.Actor.LocalActorRef SystemGuardian { get => _Instance.SystemGuardian; }
|
||||
|
||||
public Akka.Actor.IInternalActorRef TempContainer { get => _Instance.TempContainer; }
|
||||
|
||||
public System.Threading.Tasks.Task TerminationTask { get => _Instance.TerminationTask; }
|
||||
|
||||
public Akka.Actor.LocalActorRef Guardian { get => _Instance.Guardian; }
|
||||
|
||||
public Akka.Event.EventStream EventStream { get => _Instance.EventStream; }
|
||||
|
||||
public Akka.Actor.Address DefaultAddress { get => _Instance.DefaultAddress; }
|
||||
|
||||
public Akka.Serialization.Information SerializationInformation { get => _Instance.SerializationInformation; }
|
||||
|
||||
public Akka.Event.ILoggingAdapter Log { get => _Instance.Log; }
|
||||
|
||||
|
||||
|
||||
public Akka.Actor.ActorPath TempPath()
|
||||
{
|
||||
var result_690338229 = _Instance.TempPath();
|
||||
return result_690338229;
|
||||
}
|
||||
|
||||
public void RegisterExtraName(string name, Akka.Actor.IInternalActorRef actor)
|
||||
{
|
||||
string name_ = name;
|
||||
Akka.Actor.IInternalActorRef actor_ = actor;
|
||||
_Instance.RegisterExtraName(name_, actor_);
|
||||
}
|
||||
|
||||
public Akka.Actor.IActorRef RootGuardianAt(Akka.Actor.Address address)
|
||||
{
|
||||
Akka.Actor.Address address_ = address;
|
||||
var result__1703611252 = _Instance.RootGuardianAt(address_);
|
||||
return result__1703611252;
|
||||
}
|
||||
|
||||
public void RegisterTempActor(Akka.Actor.IInternalActorRef actorRef, Akka.Actor.ActorPath path)
|
||||
{
|
||||
Akka.Actor.IInternalActorRef actorRef_ = actorRef;
|
||||
Akka.Actor.ActorPath path_ = path;
|
||||
_Instance.RegisterTempActor(actorRef_, path_);
|
||||
}
|
||||
|
||||
public void UnregisterTempActor(Akka.Actor.ActorPath path)
|
||||
{
|
||||
Akka.Actor.ActorPath path_ = path;
|
||||
_Instance.UnregisterTempActor(path_);
|
||||
}
|
||||
|
||||
public Akka.Actor.FutureActorRef<T> CreateFutureRef<T>(System.Threading.Tasks.TaskCompletionSource<T> tcs)
|
||||
{
|
||||
System.Threading.Tasks.TaskCompletionSource<T> tcs_ = tcs;
|
||||
var result_1137255884 = _Instance.CreateFutureRef<T>(tcs_);
|
||||
return result_1137255884;
|
||||
}
|
||||
|
||||
public void Init(Akka.Actor.Internal.ActorSystemImpl system)
|
||||
{
|
||||
Akka.Actor.Internal.ActorSystemImpl system_ = system;
|
||||
_Instance.Init(system_);
|
||||
}
|
||||
|
||||
public Akka.Actor.IActorRef ResolveActorRef(string path)
|
||||
{
|
||||
string path_ = path;
|
||||
var result_1085051580 = _Instance.ResolveActorRef(path_);
|
||||
return result_1085051580;
|
||||
}
|
||||
|
||||
public Akka.Actor.IActorRef ResolveActorRef(Akka.Actor.ActorPath path)
|
||||
{
|
||||
Akka.Actor.ActorPath path_ = path;
|
||||
var result_1085051580 = _Instance.ResolveActorRef(path_);
|
||||
return result_1085051580;
|
||||
}
|
||||
|
||||
public Akka.Actor.IInternalActorRef ActorOf(Akka.Actor.Internal.ActorSystemImpl system, Akka.Actor.Props props, Akka.Actor.IInternalActorRef supervisor, Akka.Actor.ActorPath path, bool systemService, Akka.Actor.Deploy deploy, bool lookupDeploy, bool @async)
|
||||
{
|
||||
Akka.Actor.Internal.ActorSystemImpl system_ = system;
|
||||
Akka.Actor.Props props_ = props;
|
||||
Akka.Actor.IInternalActorRef supervisor_ = supervisor;
|
||||
Akka.Actor.ActorPath path_ = path;
|
||||
bool systemService_ = systemService;
|
||||
Akka.Actor.Deploy deploy_ = deploy;
|
||||
bool lookupDeploy_ = lookupDeploy;
|
||||
bool @async_ = @async;
|
||||
var result_540498530 = _Instance.ActorOf(system_, props_, supervisor_, path_, systemService_, deploy_, lookupDeploy_, @async_);
|
||||
return result_540498530;
|
||||
}
|
||||
|
||||
public Akka.Actor.Address GetExternalAddressFor(Akka.Actor.Address address)
|
||||
{
|
||||
Akka.Actor.Address address_ = address;
|
||||
var result_1116520814 = _Instance.GetExternalAddressFor(address_);
|
||||
return result_1116520814;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LocalActorRefProviderProxy(Akka.Actor.LocalActorRefProvider instance)
|
||||
{
|
||||
_Instance = instance;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
//----------------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
|
||||
namespace ProxyInterfaceSourceGeneratorTests.Source.AkkaActor
|
||||
{
|
||||
public partial interface ILocalActorRefProvider
|
||||
{
|
||||
Akka.Actor.LocalActorRefProvider _Instance { get; }
|
||||
|
||||
Akka.Actor.IActorRef DeadLetters { get; }
|
||||
|
||||
Akka.Actor.IActorRef IgnoreRef { get; }
|
||||
|
||||
Akka.Actor.Deployer Deployer { get; }
|
||||
|
||||
Akka.Actor.IInternalActorRef RootGuardian { get; }
|
||||
|
||||
Akka.Actor.ActorPath RootPath { get; }
|
||||
|
||||
Akka.Actor.Settings Settings { get; }
|
||||
|
||||
Akka.Actor.LocalActorRef SystemGuardian { get; }
|
||||
|
||||
Akka.Actor.IInternalActorRef TempContainer { get; }
|
||||
|
||||
System.Threading.Tasks.Task TerminationTask { get; }
|
||||
|
||||
Akka.Actor.LocalActorRef Guardian { get; }
|
||||
|
||||
Akka.Event.EventStream EventStream { get; }
|
||||
|
||||
Akka.Actor.Address DefaultAddress { get; }
|
||||
|
||||
Akka.Serialization.Information SerializationInformation { get; }
|
||||
|
||||
Akka.Event.ILoggingAdapter Log { get; }
|
||||
|
||||
|
||||
|
||||
Akka.Actor.ActorPath TempPath();
|
||||
|
||||
void RegisterExtraName(string name, Akka.Actor.IInternalActorRef actor);
|
||||
|
||||
Akka.Actor.IActorRef RootGuardianAt(Akka.Actor.Address address);
|
||||
|
||||
void RegisterTempActor(Akka.Actor.IInternalActorRef actorRef, Akka.Actor.ActorPath path);
|
||||
|
||||
void UnregisterTempActor(Akka.Actor.ActorPath path);
|
||||
|
||||
Akka.Actor.FutureActorRef<T> CreateFutureRef<T>(System.Threading.Tasks.TaskCompletionSource<T> tcs);
|
||||
|
||||
void Init(Akka.Actor.Internal.ActorSystemImpl system);
|
||||
|
||||
Akka.Actor.IActorRef ResolveActorRef(string path);
|
||||
|
||||
Akka.Actor.IActorRef ResolveActorRef(Akka.Actor.ActorPath path);
|
||||
|
||||
Akka.Actor.IInternalActorRef ActorOf(Akka.Actor.Internal.ActorSystemImpl system, Akka.Actor.Props props, Akka.Actor.IInternalActorRef supervisor, Akka.Actor.ActorPath path, bool systemService, Akka.Actor.Deploy deploy, bool lookupDeploy, bool @async);
|
||||
|
||||
Akka.Actor.Address GetExternalAddressFor(Akka.Actor.Address address);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
@@ -3,9 +3,7 @@ using System.Linq;
|
||||
using CSharp.SourceGenerators.Extensions;
|
||||
using CSharp.SourceGenerators.Extensions.Models;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using ProxyInterfaceSourceGenerator;
|
||||
using ProxyInterfaceSourceGeneratorTests.Source.PnP;
|
||||
using Xunit;
|
||||
|
||||
namespace ProxyInterfaceSourceGeneratorTests;
|
||||
@@ -123,15 +121,4 @@ public class PnPTests
|
||||
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void X()
|
||||
{
|
||||
var webMock = new Mock<IWeb>();
|
||||
|
||||
|
||||
var ccMock = new Mock<IClientContext>();
|
||||
// ccMock.SetupGet(cc => cc.Web).Returns(webMock.Object);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Akka.Remote" Version="1.4.47" />
|
||||
<PackageReference Include="AutoMapper" Version="11.0.1" />
|
||||
<PackageReference Include="CultureAwareTesting.xUnit" Version="0.0.1" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.7.0" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
||||
@@ -41,6 +43,13 @@
|
||||
<Compile Update="Source\PnP\*.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Update="Source\AkkaActor\*.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Destination\AkkaGenerated\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace ProxyInterfaceSourceGeneratorTests.Source.AkkaActor
|
||||
{
|
||||
public partial interface ILocalActorRefProvider
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user