баг решен
This commit is contained in:
@@ -28,14 +28,12 @@ var factory = context.GetSingleObject(typeof(IPrinterFactory)) as IPrinterFactor
|
|||||||
|
|
||||||
//правильный порядок команд 8-5-10-7
|
//правильный порядок команд 8-5-10-7
|
||||||
var printer = factory.Create("Test");
|
var printer = factory.Create("Test");
|
||||||
Thread.Sleep(100);
|
|
||||||
var name = printer.Value.GetName();
|
var name = printer.Value.GetName();
|
||||||
Thread.Sleep(100);
|
|
||||||
Console.WriteLine("Printer name : {0}", name);
|
Console.WriteLine("Printer name : {0}", name);
|
||||||
|
|
||||||
Console.WriteLine("Registered printer");
|
Console.WriteLine("Registered printer");
|
||||||
|
|
||||||
factory.Register(new SharedObject<IPrinter>(new ClientBasedPrinter()));
|
factory.Register(new SharedObject<IPrinter>(new ClientBasedPrinter()));
|
||||||
Thread.Sleep(100);
|
|
||||||
Console.WriteLine("Collecting all printers");
|
Console.WriteLine("Collecting all printers");
|
||||||
var names = factory.CollectAllNames();
|
var names = factory.CollectAllNames();
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
|||||||
@@ -56,17 +56,17 @@ namespace {Namespace}
|
|||||||
|
|
||||||
// Go through all attributes of the class.
|
// Go through all attributes of the class.
|
||||||
foreach (AttributeListSyntax attributeListSyntax in classDeclarationSyntax.AttributeLists)
|
foreach (AttributeListSyntax attributeListSyntax in classDeclarationSyntax.AttributeLists)
|
||||||
foreach (AttributeSyntax attributeSyntax in attributeListSyntax.Attributes)
|
foreach (AttributeSyntax attributeSyntax in attributeListSyntax.Attributes)
|
||||||
{
|
{
|
||||||
if (context.SemanticModel.GetSymbolInfo(attributeSyntax).Symbol is not IMethodSymbol attributeSymbol)
|
if (context.SemanticModel.GetSymbolInfo(attributeSyntax).Symbol is not IMethodSymbol attributeSymbol)
|
||||||
continue; // if we can't get the symbol, ignore it
|
continue; // if we can't get the symbol, ignore it
|
||||||
|
|
||||||
string attributeName = attributeSymbol.ContainingType.ToDisplayString();
|
string attributeName = attributeSymbol.ContainingType.ToDisplayString();
|
||||||
|
|
||||||
// Check the full name of the [Report] attribute.
|
// Check the full name of the [Report] attribute.
|
||||||
if (attributeName == "mROA.Implementation.Attributes.SharedObjectInterfaceAttribute")
|
if (attributeName == "mROA.Implementation.Attributes.SharedObjectInterfaceAttribute")
|
||||||
return (classDeclarationSyntax, true);
|
return (classDeclarationSyntax, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (classDeclarationSyntax, false);
|
return (classDeclarationSyntax, false);
|
||||||
}
|
}
|
||||||
@@ -141,8 +141,7 @@ namespace {Namespace}
|
|||||||
sb.AppendLine(
|
sb.AppendLine(
|
||||||
$"\t\tvar defaultCallRequestCodegen = new DefaultCallRequest {{ CommandId = {index}, ObjectId = id }};");
|
$"\t\tvar defaultCallRequestCodegen = new DefaultCallRequest {{ CommandId = {index}, ObjectId = id }};");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendLine("\t\tSystem.Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(defaultCallRequestCodegen));");
|
|
||||||
//Post created request
|
//Post created request
|
||||||
sb.AppendLine("\t\tserialisationModule.PostCallRequest(defaultCallRequestCodegen);");
|
sb.AppendLine("\t\tserialisationModule.PostCallRequest(defaultCallRequestCodegen);");
|
||||||
|
|
||||||
@@ -154,7 +153,6 @@ namespace {Namespace}
|
|||||||
}
|
}
|
||||||
else if (method.ReturnType.OriginalDefinition.ToString() == "System.Threading.Tasks.Task<TResult>")
|
else if (method.ReturnType.OriginalDefinition.ToString() == "System.Threading.Tasks.Task<TResult>")
|
||||||
{
|
{
|
||||||
|
|
||||||
var type = method.ReturnType.ToString();
|
var type = method.ReturnType.ToString();
|
||||||
type = type.Substring(type.IndexOf('<') + 1);
|
type = type.Substring(type.IndexOf('<') + 1);
|
||||||
type = type.Substring(0, type.Length - 1);
|
type = type.Substring(0, type.Length - 1);
|
||||||
@@ -169,6 +167,11 @@ namespace {Namespace}
|
|||||||
$"\t\tvar response = serialisationModule.GetFinalCommandExecution<{type}>(defaultCallRequestCodegen.CallRequestId).GetAwaiter().GetResult();");
|
$"\t\tvar response = serialisationModule.GetFinalCommandExecution<{type}>(defaultCallRequestCodegen.CallRequestId).GetAwaiter().GetResult();");
|
||||||
sb.AppendLine($"\t\treturn ({type})response.Result;");
|
sb.AppendLine($"\t\treturn ({type})response.Result;");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.AppendLine(
|
||||||
|
"\t\tserialisationModule.GetNextCommandExecution<FinalCommandExecution>(defaultCallRequestCodegen.CallRequestId).Wait();");
|
||||||
|
}
|
||||||
|
|
||||||
sb.AppendLine("\t}");
|
sb.AppendLine("\t}");
|
||||||
|
|
||||||
@@ -198,16 +201,16 @@ partial class {className} (int id, ISerialisationModule.IFrontendSerialisationMo
|
|||||||
// Add the source code to the compilation.
|
// Add the source code to the compilation.
|
||||||
context.AddSource($"{className}.g.cs", SourceText.From(code, Encoding.UTF8));
|
context.AddSource($"{className}.g.cs", SourceText.From(code, Encoding.UTF8));
|
||||||
|
|
||||||
frontendContextRepo.Add($"{{ typeof({classSymbol.ToDisplayString()}), typeof({namespaceName}.{className}) }}");
|
frontendContextRepo.Add(
|
||||||
|
$"{{ typeof({classSymbol.ToDisplayString()}), typeof({namespaceName}.{className}) }}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methods.Count != 0)
|
if (methods.Count != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
var methodsStringed = methods.Select(i =>
|
var methodsStringed = methods.Select(i =>
|
||||||
$"typeof({i.Item1}).GetMethod(\"{i.Item2.Name}\", [{string.Join(", ", i.Item2.Parameters.Select(p => $"typeof({p.Type.ToDisplayString()})"))}])")
|
$"typeof({i.Item1}).GetMethod(\"{i.Item2.Name}\", [{string.Join(", ", i.Item2.Parameters.Select(p => $"typeof({p.Type.ToDisplayString()})"))}])")
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var coCodegenRepoCode = @$"// <auto-generated/>
|
var coCodegenRepoCode = @$"// <auto-generated/>
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -249,7 +252,6 @@ public class CoCodegenMethodRepository : IMethodRepository
|
|||||||
|
|
||||||
if (frontendContextRepo.Count != 0)
|
if (frontendContextRepo.Count != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
var fronendRepoCode = @$"// <auto-generated/>
|
var fronendRepoCode = @$"// <auto-generated/>
|
||||||
using System.Collections.Frozen;
|
using System.Collections.Frozen;
|
||||||
using mROA.Implementation;
|
using mROA.Implementation;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public class BasicExecutionModule : IExecuteModule
|
|||||||
public ICommandExecution Execute(ICallRequest command, IContextRepository _contextRepo)
|
public ICommandExecution Execute(ICallRequest command, IContextRepository _contextRepo)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Executing command: {command.CommandId}");
|
Console.WriteLine($"Executing command: {command.CommandId}");
|
||||||
|
Thread.Sleep(100);
|
||||||
|
|
||||||
if (_methodRepo is null)
|
if (_methodRepo is null)
|
||||||
throw new NullReferenceException("Method repository was not defined");
|
throw new NullReferenceException("Method repository was not defined");
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class JsonSerialisationModule : ISerialisationModule
|
|||||||
command.Parameter = jsElement.Deserialize(parameter);
|
command.Parameter = jsElement.Deserialize(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Calling command execution {command.CommandId}");
|
||||||
var response = _executeModule!.Execute(command, _contextRepo);
|
var response = _executeModule!.Execute(command, _contextRepo);
|
||||||
response.ClientId = clientId;
|
response.ClientId = clientId;
|
||||||
var resultType = response is FinalCommandExecution
|
var resultType = response is FinalCommandExecution
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using mROA.Abstract;
|
using mROA.Abstract;
|
||||||
|
|
||||||
@@ -15,11 +16,20 @@ public class JsonFrontendSerialisationModule
|
|||||||
throw new Exception("Interaction module not initialized");
|
throw new Exception("Interaction module not initialized");
|
||||||
|
|
||||||
var receiveMessage = await _interactionModule.ReceiveMessage();
|
var receiveMessage = await _interactionModule.ReceiveMessage();
|
||||||
var parsed = JsonSerializer.Deserialize<T>(receiveMessage)!;
|
var message = JsonSerializer.Deserialize<NetworkMessage>(receiveMessage)!;
|
||||||
while (parsed.CallRequestId != requestId)
|
|
||||||
|
while (message.Id != requestId)
|
||||||
{
|
{
|
||||||
receiveMessage = await _interactionModule.ReceiveMessage();
|
receiveMessage = await _interactionModule.ReceiveMessage();
|
||||||
parsed = JsonSerializer.Deserialize<T>(receiveMessage)!;
|
message = JsonSerializer.Deserialize<NetworkMessage>(receiveMessage)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsed = JsonSerializer.Deserialize<T>(message.Data)!;
|
||||||
|
|
||||||
|
if (message.SchemaId == MessageType.ErrorCommandExecution)
|
||||||
|
{
|
||||||
|
throw new RemoteException(JsonSerializer.Deserialize<ExceptionCommandExecution>(message.Data)!.Exception)
|
||||||
|
{ CallRequestId = requestId };
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
@@ -31,11 +41,14 @@ public class JsonFrontendSerialisationModule
|
|||||||
throw new Exception("Interaction module not initialized");
|
throw new Exception("Interaction module not initialized");
|
||||||
|
|
||||||
var receiveMessage = await _interactionModule.ReceiveMessage();
|
var receiveMessage = await _interactionModule.ReceiveMessage();
|
||||||
|
Console.WriteLine($"Received message: {Encoding.UTF8.GetString(receiveMessage)}");
|
||||||
|
|
||||||
var message = JsonSerializer.Deserialize<NetworkMessage>(receiveMessage)!;
|
var message = JsonSerializer.Deserialize<NetworkMessage>(receiveMessage)!;
|
||||||
while (message.Id != requestId)
|
while (message.Id != requestId)
|
||||||
{
|
{
|
||||||
receiveMessage = await _interactionModule.ReceiveMessage();
|
receiveMessage = await _interactionModule.ReceiveMessage();
|
||||||
|
Console.WriteLine($"Received message again: {Encoding.UTF8.GetString(receiveMessage)}");
|
||||||
|
|
||||||
message = JsonSerializer.Deserialize<NetworkMessage>(receiveMessage)!;
|
message = JsonSerializer.Deserialize<NetworkMessage>(receiveMessage)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +66,8 @@ public class JsonFrontendSerialisationModule
|
|||||||
if (_interactionModule is null)
|
if (_interactionModule is null)
|
||||||
throw new Exception("Interaction module not initialized");
|
throw new Exception("Interaction module not initialized");
|
||||||
|
|
||||||
|
Console.WriteLine($"PostCallRequest: {JsonSerializer.Serialize(callRequest)}");
|
||||||
|
|
||||||
var post = JsonSerializer.SerializeToUtf8Bytes(callRequest, callRequest.GetType());
|
var post = JsonSerializer.SerializeToUtf8Bytes(callRequest, callRequest.GetType());
|
||||||
_interactionModule.PostMessage(JsonSerializer.SerializeToUtf8Bytes(new NetworkMessage
|
_interactionModule.PostMessage(JsonSerializer.SerializeToUtf8Bytes(new NetworkMessage
|
||||||
{
|
{
|
||||||
@@ -60,9 +75,8 @@ public class JsonFrontendSerialisationModule
|
|||||||
Data = post,
|
Data = post,
|
||||||
SchemaId = MessageType.CallRequest
|
SchemaId = MessageType.CallRequest
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Inject<T>(T dependency)
|
public void Inject<T>(T dependency)
|
||||||
{
|
{
|
||||||
if (dependency is IInteractionModule.IFrontendInteractionModule interactionModule)
|
if (dependency is IInteractionModule.IFrontendInteractionModule interactionModule)
|
||||||
|
|||||||
Reference in New Issue
Block a user