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