Исправлен баг с не правильной генерацией параметров для событий

This commit is contained in:
2025-03-10 17:16:13 +03:00
parent f4a92e4aac
commit b430f1c572
8 changed files with 24 additions and 15 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants></DefineConstants> <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+3 -3
View File
@@ -10,7 +10,7 @@ namespace Example.Backend
{ {
public string Name; public string Name;
public void OnPrintExternal(IPage p0, RequestContext p1) public void OnPrintExternal(IPage p0)
{ {
} }
@@ -27,12 +27,12 @@ namespace Example.Backend
// throw new Exception("The method or operation is not implemented."); // throw new Exception("The method or operation is not implemented.");
var page = new Page { Text = text }; var page = new Page { Text = text };
Console.WriteLine($"Request id : :{context.RequestId}"); Console.WriteLine($"Request id : :{context.RequestId}");
OnPrint?.Invoke(page, context); OnPrint?.Invoke(page);
Resource /= 1.5; Resource /= 1.5;
return page; return page;
} }
public event Action<IPage, RequestContext>? OnPrint; public event Action<IPage>? OnPrint;
public void Dispose() public void Dispose()
{ {
+2 -2
View File
@@ -8,7 +8,7 @@ namespace Example.Frontend
{ {
public class ClientBasedPrinter : IPrinter public class ClientBasedPrinter : IPrinter
{ {
public void OnPrintExternal(IPage p0, RequestContext p1) public void OnPrintExternal(IPage p0)
{ {
} }
@@ -29,7 +29,7 @@ namespace Example.Frontend
return new ClientBasedPage(); return new ClientBasedPage();
} }
public event Action<IPage, RequestContext>? OnPrint; public event Action<IPage>? OnPrint;
public void Dispose() public void Dispose()
{ {
+1 -1
View File
@@ -10,7 +10,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants /> <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+1
View File
@@ -48,6 +48,7 @@ class Program
//правильный порядок команд 8-5-10-7 //правильный порядок команд 8-5-10-7
using (var disposingPrinter = factory.Create("Test")) using (var disposingPrinter = factory.Create("Test"))
{ {
disposingPrinter.OnPrint += page1 => { Console.WriteLine("New page creater. Called from event!!!"); };
Console.WriteLine("Printer created"); Console.WriteLine("Printer created");
Thread.Sleep(100); Thread.Sleep(100);
+1 -1
View File
@@ -12,6 +12,6 @@ namespace Example.Shared
double Resource { get; set; } double Resource { get; set; }
string GetName(); string GetName();
Task<IPage> Print(string text, bool someParameter, RequestContext context, CancellationToken cancellationToken); Task<IPage> Print(string text, bool someParameter, RequestContext context, CancellationToken cancellationToken);
event Action<IPage, RequestContext> OnPrint; event Action<IPage> OnPrint;
} }
} }
+5 -2
View File
@@ -463,7 +463,8 @@ namespace {classSymbol.ContainingNamespace.ToDisplayString()}
JoinWithComa(Enumerable.Range(0, parameters.Count).Select(i => "p" + i++))); JoinWithComa(Enumerable.Range(0, parameters.Count).Select(i => "p" + i++)));
var transferParameters = var transferParameters =
JoinWithComa(parameters.Where(i => ParameterFilterForType(i)).Select(i => "p" + parameters.IndexOf(i))); JoinWithComa(parameters.Where(i => !ParameterFilterForType(i))
.Select(i => "p" + parameters.IndexOf(i)));
var callFilter = ""; var callFilter = "";
@@ -475,7 +476,9 @@ namespace {classSymbol.ContainingNamespace.ToDisplayString()}
var eventBinderCode = var eventBinderCode =
$@" (instance as {baseType.ToDisplayString()}).{eventSymbol.Name} += ({parametersDeclaration}) => $@" (instance as {baseType.ToDisplayString()}).{eventSymbol.Name} += ({parametersDeclaration}) =>
{{ {callFilter} {{
Console.WriteLine(""Sending event..."");
{callFilter}
var request = new DefaultCallRequest var request = new DefaultCallRequest
{{ {{
CommandId = {index}, ObjectId = index, Parameters = new object[] {{ {transferParameters} }} CommandId = {index}, ObjectId = index, Parameters = new object[] {{ {transferParameters} }}
+6 -1
View File
@@ -7,8 +7,8 @@ namespace mROA.Implementation
{ {
public class RepresentationModule : IRepresentationModule public class RepresentationModule : IRepresentationModule
{ {
private ISerializationToolkit? _serialization;
private INextGenerationInteractionModule? _interaction; private INextGenerationInteractionModule? _interaction;
private ISerializationToolkit? _serialization;
public void Inject<T>(T dependency) public void Inject<T>(T dependency)
{ {
@@ -70,6 +70,11 @@ namespace mROA.Implementation
} }
} }
if (fromBuffer == null)
{
return Array.Empty<byte>();
}
_interaction.HandleMessage(fromBuffer); _interaction.HandleMessage(fromBuffer);
return fromBuffer.Data; return fromBuffer.Data;
} }