From 745def13651d917448f7967d937507fd30af1c8f Mon Sep 17 00:00:00 2001 From: Mitrofanov Mikhail Date: Tue, 3 Jun 2025 12:09:32 +0300 Subject: [PATCH] Moving codegen tools to another project --- Example.Backend/Printer.cs | 6 ++ Example.Frontend/ClientBasedPrinter.cs | 5 ++ Example.Frontend/Program.cs | 19 ++-- Example.Shared/IPrinter.cs | 33 +++++++ mROA.Cbor/PreParsedValue.cs | 2 +- mROA.Cbor/mROA.Cbor.csproj | 2 +- mROA.Codegen/mROA.Codegen.csproj | 14 +-- mROA.CodegenTools/DefineTemplateSection.cs | 30 +++++++ mROA.CodegenTools/ITemplateSection.cs | 20 +++++ mROA.CodegenTools/InnerTemplateSection.cs | 24 ++++++ mROA.CodegenTools/InsertTemplateSection.cs | 86 +++++++++++++++++++ mROA.CodegenTools/LinkTemplateSection.cs | 39 +++++++++ mROA.CodegenTools/LiteralTemplateSection.cs | 31 +++++++ mROA.CodegenTools/ProgrammableTextSection.cs | 29 +++++++ .../Reading/DefineSectionReader.cs | 24 ++++++ mROA.CodegenTools/Reading/ISectionReader.cs | 9 ++ .../Reading/InnerTemplateSectionReader.cs | 39 +++++++++ .../Reading/InsertSectionReader.cs | 24 ++++++ .../Reading/LeadingTextSectionReader.cs | 41 +++++++++ .../Reading/LinkSectionReader.cs | 20 +++++ mROA.CodegenTools/Reading/TemplateReader.cs | 82 ++++++++++++++++++ mROA.CodegenTools/TemplateDocument.cs | 61 +++++++++++++ mROA.CodegenTools/mROA.CodegenTools.csproj | 9 ++ mROA.sln | 6 ++ mROA/Abstract/IChannelInteractionModule.cs | 1 + .../ChannelInteractionModule.cs | 4 + mROA/mROA.csproj | 2 +- 27 files changed, 640 insertions(+), 22 deletions(-) create mode 100644 mROA.CodegenTools/DefineTemplateSection.cs create mode 100644 mROA.CodegenTools/ITemplateSection.cs create mode 100644 mROA.CodegenTools/InnerTemplateSection.cs create mode 100644 mROA.CodegenTools/InsertTemplateSection.cs create mode 100644 mROA.CodegenTools/LinkTemplateSection.cs create mode 100644 mROA.CodegenTools/LiteralTemplateSection.cs create mode 100644 mROA.CodegenTools/ProgrammableTextSection.cs create mode 100644 mROA.CodegenTools/Reading/DefineSectionReader.cs create mode 100644 mROA.CodegenTools/Reading/ISectionReader.cs create mode 100644 mROA.CodegenTools/Reading/InnerTemplateSectionReader.cs create mode 100644 mROA.CodegenTools/Reading/InsertSectionReader.cs create mode 100644 mROA.CodegenTools/Reading/LeadingTextSectionReader.cs create mode 100644 mROA.CodegenTools/Reading/LinkSectionReader.cs create mode 100644 mROA.CodegenTools/Reading/TemplateReader.cs create mode 100644 mROA.CodegenTools/TemplateDocument.cs create mode 100644 mROA.CodegenTools/mROA.CodegenTools.csproj diff --git a/Example.Backend/Printer.cs b/Example.Backend/Printer.cs index 9e9bb07..2dbd067 100644 --- a/Example.Backend/Printer.cs +++ b/Example.Backend/Printer.cs @@ -21,6 +21,12 @@ namespace Example.Backend return Task.CompletedTask; } + public Task IntTest(MyData data) + { + Console.WriteLine(data); + return Task.CompletedTask; + } + public void OnPrintExternal(IPage p0, RequestContext ro) { OnPrint?.Invoke(p0, ro); diff --git a/Example.Frontend/ClientBasedPrinter.cs b/Example.Frontend/ClientBasedPrinter.cs index 1c4f0cb..16ca306 100644 --- a/Example.Frontend/ClientBasedPrinter.cs +++ b/Example.Frontend/ClientBasedPrinter.cs @@ -18,6 +18,11 @@ namespace Example.Frontend return Task.CompletedTask; } + public Task IntTest(MyData data) + { + throw new NotImplementedException(); + } + public void OnPrintExternal(IPage p0, RequestContext ro) { } diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index 5e1b7a7..e9cd6fc 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -37,7 +37,7 @@ class Program builder.Modules.Add(new CancellationRepository()); builder.Build(); - + var frontendBridge = builder.GetModule()!; await frontendBridge.Connect(); _ = builder.GetModule()!.StartExtraction(); @@ -51,11 +51,9 @@ class Program using (var disposingPrinter = factory.Create("Test")) { - disposingPrinter.SetFingerPrint(new[] { 1, 2, 3 }).ContinueWith(r => - { - Console.WriteLine(r.Status); - }); - + disposingPrinter.SetFingerPrint(new[] { 1, 2, 3 }).ContinueWith(r => { Console.WriteLine(r.Status); }); + + await disposingPrinter.IntTest(new MyData { Id = 5, Score = 7, Name = "Test" }); DemoCheck.CreatingPrinter = true; disposingPrinter.OnPrint += (_, _) => { @@ -74,7 +72,7 @@ class Program disposingPrinter.SomeoneIsApproaching("Mikhail"); Console.WriteLine("Approaching detected"); - + factory.Register(new ClientBasedPrinter()); factory.Register(disposingPrinter); DemoCheck.ClientBasedImplementation = true; @@ -134,18 +132,15 @@ class Program { x = loadSingleton.Next(x); } - + timer.Stop(); Console.WriteLine("X is {0}", x); Console.WriteLine("Time : {0}", timer.Elapsed.TotalMilliseconds); Console.WriteLine($"Time per call: {timer.Elapsed.TotalMilliseconds / iterations} ms"); - + frontendBridge.Disconnect(); DemoCheck.Show(); Console.ReadKey(); - - - } } \ No newline at end of file diff --git a/Example.Shared/IPrinter.cs b/Example.Shared/IPrinter.cs index e34b889..83138f6 100644 --- a/Example.Shared/IPrinter.cs +++ b/Example.Shared/IPrinter.cs @@ -13,8 +13,41 @@ namespace Example.Shared string GetName(); Task Print(string text, bool someParameter, RequestContext context, CancellationToken cancellationToken); event Action OnPrint; + [Untrusted] Task SomeoneIsApproaching(string humanName); + Task SetFingerPrint(int[] fingerPrint); + Task IntTest(MyData data); + } + + public class MyData + { + public int Id { get; set; } + public string Name { get; set; } + public double Score { get; set; } + + public override string ToString() + { + return $"{{{nameof(Id)}: {Id}, {nameof(Name)}: {Name}, {nameof(Score)}: {Score}}}"; + } + + protected bool Equals(MyData other) + { + return Id == other.Id && Name == other.Name && Score.Equals(other.Score); + } + + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((MyData)obj); + } + + public override int GetHashCode() + { + return HashCode.Combine(Id, Name, Score); + } } } \ No newline at end of file diff --git a/mROA.Cbor/PreParsedValue.cs b/mROA.Cbor/PreParsedValue.cs index c1b1575..3000bbb 100644 --- a/mROA.Cbor/PreParsedValue.cs +++ b/mROA.Cbor/PreParsedValue.cs @@ -65,7 +65,7 @@ namespace mROA.Cbor property.SetValue(instance, _properties[index] is IPreParsedValue ppv ? ppv.ToObject(property.PropertyType, context) - : _properties[index]); + : Convert.ChangeType(_properties[index], property.PropertyType)); } return instance; diff --git a/mROA.Cbor/mROA.Cbor.csproj b/mROA.Cbor/mROA.Cbor.csproj index 47df304..1382ad8 100644 --- a/mROA.Cbor/mROA.Cbor.csproj +++ b/mROA.Cbor/mROA.Cbor.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable true - 2.0.3 + 2.0.4 9 diff --git a/mROA.Codegen/mROA.Codegen.csproj b/mROA.Codegen/mROA.Codegen.csproj index 0b91fce..b92d3ea 100644 --- a/mROA.Codegen/mROA.Codegen.csproj +++ b/mROA.Codegen/mROA.Codegen.csproj @@ -25,20 +25,20 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - - - - - + + + + + diff --git a/mROA.CodegenTools/DefineTemplateSection.cs b/mROA.CodegenTools/DefineTemplateSection.cs new file mode 100644 index 0000000..31eadb7 --- /dev/null +++ b/mROA.CodegenTools/DefineTemplateSection.cs @@ -0,0 +1,30 @@ +namespace mROA.CodegenTools +{ + public class DefineTemplateSection : ITagged + { + public DefineTemplateSection(string storedText, string tag, TemplateDocument context) + { + StoredText = storedText; + Tag = tag; + Context = context; + } + + public string StoredText { get; } + public TemplateDocument Context { get; set; } + + public string Tag { get; } + + public int TargetLength => StoredText.Length; + + public object Clone() + { + return new DefineTemplateSection(StoredText, Tag, Context); + } + + + public override string ToString() + { + return StoredText; + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/ITemplateSection.cs b/mROA.CodegenTools/ITemplateSection.cs new file mode 100644 index 0000000..cf7d34c --- /dev/null +++ b/mROA.CodegenTools/ITemplateSection.cs @@ -0,0 +1,20 @@ +using System; + +namespace mROA.CodegenTools +{ + public interface ITemplateSection : ICloneable + { + TemplateDocument Context { get; set; } + int TargetLength { get; } + } + + public interface IBaking + { + string Bake(); + } + + public interface ITagged : ITemplateSection + { + string Tag { get; } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/InnerTemplateSection.cs b/mROA.CodegenTools/InnerTemplateSection.cs new file mode 100644 index 0000000..1a6d5f7 --- /dev/null +++ b/mROA.CodegenTools/InnerTemplateSection.cs @@ -0,0 +1,24 @@ +namespace mROA.CodegenTools +{ + public class InnerTemplateSection : ITemplateSection, ITagged + { + public InnerTemplateSection(string tag, TemplateDocument innerTemplate, TemplateDocument context) + { + Tag = tag; + Context = context; + InnerTemplate = innerTemplate; + } + + public TemplateDocument InnerTemplate { get; } + + public string Tag { get; } + + public TemplateDocument Context { get; set; } + public int TargetLength => 0; + + public object Clone() + { + return new InnerTemplateSection(Tag, InnerTemplate, Context); + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/InsertTemplateSection.cs b/mROA.CodegenTools/InsertTemplateSection.cs new file mode 100644 index 0000000..e47cd50 --- /dev/null +++ b/mROA.CodegenTools/InsertTemplateSection.cs @@ -0,0 +1,86 @@ +using System.Collections.Generic; +using System.Linq; + +namespace mROA.CodegenTools +{ + public class InsertTemplateSection : ITagged, IBaking + { + public readonly List Parameters; + private object _insertedValue; + + public InsertTemplateSection(string tag, TemplateDocument context, params string[] parameters) + { + Tag = tag; + Parameters = parameters.ToList(); + Context = context; + } + + public string Bake() + { + switch (_insertedValue) + { + case null: + return string.Empty; + case string s: + return s; + default: + return ((ITemplateSection)_insertedValue).ToString(); + } + } + + public string Tag { get; private set; } + + public TemplateDocument Context { get; set; } + + + public int TargetLength => 0; + + public object Clone() + { + return new InsertTemplateSection(Tag, Context, Parameters.ToArray()); + } + + private bool IsInserted(object value) + { + if (Parameters.IndexOf("r") == -1) return false; + + ProduceInserted(value); + + return true; + } + + private void ProduceInserted(object value) + { + var currentIndex = Context.Parts.IndexOf(this); + var clone = (InsertTemplateSection)MemberwiseClone(); + clone.Tag += "+"; + + clone._insertedValue = value; + + Context.Parts.Insert(currentIndex, clone); + + InsertSeparator(currentIndex + 1); + } + + private void InsertSeparator(int currentIndex) + { + var sepIndex = Parameters.IndexOf("sep"); + if (sepIndex == -1) + return; + + Context.Parts.Insert(currentIndex, + new LiteralTemplateSection(Context[Parameters[sepIndex + 1]].ToString(), Context)); + } + + + public void Setup(object value) + { + if (!(value is string) && !(value is ITemplateSection)) + return; + if (IsInserted(value)) + return; + + _insertedValue = value; + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/LinkTemplateSection.cs b/mROA.CodegenTools/LinkTemplateSection.cs new file mode 100644 index 0000000..45f58c6 --- /dev/null +++ b/mROA.CodegenTools/LinkTemplateSection.cs @@ -0,0 +1,39 @@ +namespace mROA.CodegenTools +{ + public class LinkTemplateSection : ITemplateSection, IBaking + { + public LinkTemplateSection(string linkedTag, TemplateDocument context) + { + LinkedTag = linkedTag; + Context = context; + } + + public string LinkedTag { get; } + + public string Bake() + { + return Context[LinkedTag]?.ToString(); + } + + public TemplateDocument Context { get; set; } + + public int TargetLength + { + get + { + var attached = Context[LinkedTag]; + return attached?.TargetLength ?? 0; + } + } + + public object Clone() + { + return new LinkTemplateSection(LinkedTag, Context); + } + + public override string ToString() + { + return $"{nameof(LinkedTag)}: {LinkedTag}"; + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/LiteralTemplateSection.cs b/mROA.CodegenTools/LiteralTemplateSection.cs new file mode 100644 index 0000000..45c2dec --- /dev/null +++ b/mROA.CodegenTools/LiteralTemplateSection.cs @@ -0,0 +1,31 @@ +namespace mROA.CodegenTools +{ + public class LiteralTemplateSection : ITemplateSection, IBaking + { + private readonly string _internalText; + + public LiteralTemplateSection(string internalText, TemplateDocument context) + { + _internalText = internalText; + Context = context; + } + + public string Bake() + { + return ToString(); + } + + public TemplateDocument Context { get; set; } + public int TargetLength => _internalText.Length; + + public object Clone() + { + return new LiteralTemplateSection(_internalText, Context); + } + + public override string ToString() + { + return _internalText; + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/ProgrammableTextSection.cs b/mROA.CodegenTools/ProgrammableTextSection.cs new file mode 100644 index 0000000..0e34391 --- /dev/null +++ b/mROA.CodegenTools/ProgrammableTextSection.cs @@ -0,0 +1,29 @@ +using System; + +namespace mROA.CodegenTools +{ + public class ProgrammableTextSection : ITemplateSection, IBaking + { + private readonly Func _bakeFunc; + + public ProgrammableTextSection(Func bakeFunc, TemplateDocument context) + { + _bakeFunc = bakeFunc; + Context = context; + } + + + public string Bake() + { + return _bakeFunc(Context.AdditionalContext); + } + + public TemplateDocument Context { get; set; } + public int TargetLength => 0; + + public object Clone() + { + return new ProgrammableTextSection(_bakeFunc, Context); + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/Reading/DefineSectionReader.cs b/mROA.CodegenTools/Reading/DefineSectionReader.cs new file mode 100644 index 0000000..0f3840a --- /dev/null +++ b/mROA.CodegenTools/Reading/DefineSectionReader.cs @@ -0,0 +1,24 @@ +using System; + +namespace mROA.CodegenTools.Reading +{ + public class DefineSectionReader : LeadingTextSectionReader + { + public DefineSectionReader() : base("", index, StringComparison.Ordinal); + var sectionName = GetTagValue(index, tagEnd); + tagEnd += 1; + var endIndex = TemplateText.IndexOf("", tagEnd, StringComparison.Ordinal); + var storedText = TemplateText.Substring(tagEnd, endIndex - tagEnd); + index = endIndex + 4; + PassCaretToCloseSymbol(); + PassCaretToCloseSymbol(); + return new DefineTemplateSection(storedText, sectionName, document); + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/Reading/ISectionReader.cs b/mROA.CodegenTools/Reading/ISectionReader.cs new file mode 100644 index 0000000..fd89e5d --- /dev/null +++ b/mROA.CodegenTools/Reading/ISectionReader.cs @@ -0,0 +1,9 @@ +namespace mROA.CodegenTools.Reading +{ + public interface ISectionReader + { + string TemplateText { get; set; } + int GetNextSectionIndex(int currentIndex); + ITemplateSection ExtractSection(ref int index, TemplateDocument document); + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/Reading/InnerTemplateSectionReader.cs b/mROA.CodegenTools/Reading/InnerTemplateSectionReader.cs new file mode 100644 index 0000000..11fc269 --- /dev/null +++ b/mROA.CodegenTools/Reading/InnerTemplateSectionReader.cs @@ -0,0 +1,39 @@ +using System; + +namespace mROA.CodegenTools.Reading +{ + public class InnerTemplateSectionReader : LeadingTextSectionReader + { + public InnerTemplateSectionReader() + : base("", start, StringComparison.Ordinal); + var innerStartSymbol = TemplateText.IndexOf("", _currentCaretPosition, StringComparison.Ordinal) + 1; + return _currentCaretPosition; + } + + protected string GetTagValue(int from, int to) + { + var realStart = from + 4; + var span = TemplateText.AsSpan(); + var slice = span.Slice(realStart, to - realStart); + return new string(slice.ToArray()); + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/Reading/LinkSectionReader.cs b/mROA.CodegenTools/Reading/LinkSectionReader.cs new file mode 100644 index 0000000..07947ad --- /dev/null +++ b/mROA.CodegenTools/Reading/LinkSectionReader.cs @@ -0,0 +1,20 @@ +namespace mROA.CodegenTools.Reading +{ + public class LinkSectionReader : LeadingTextSectionReader + { + public LinkSectionReader() : base(" ReaderTypes = new() + { + typeof(DefineSectionReader), + typeof(InsertSectionReader), + typeof(LinkSectionReader), + typeof(InnerTemplateSectionReader) + }; + + public static TemplateDocument Parse(string templateText) + { + var currentIndex = 0; + var activeReaders = new List(); + + foreach (var readerType in ReaderTypes) + { + var reader = Activator.CreateInstance(readerType) as ISectionReader; + reader.TemplateText = templateText; + activeReaders.Add(reader); + } + + var doc = new TemplateDocument(); + + while (currentIndex < templateText.Length) + { + List<(ISectionReader reader, int index)> indices = activeReaders + .Select(i => ((ISectionReader Readers, int index))(i, i.GetNextSectionIndex(currentIndex))) + .Where(i => i.index > -1).ToList(); + var minIndex = templateText.Length; + ISectionReader minReader = null; + if (indices.Count != 0) + { + minIndex = indices.Min(i => i.index); + minReader = indices.FirstOrDefault(i => i.index == minIndex).reader; + + if (indices.Count != activeReaders.Count) activeReaders = indices.Select(i => i.reader).ToList(); + } + + + if (currentIndex != minIndex) + { + var literalText = templateText.Substring(currentIndex, minIndex - currentIndex); + var literal = + new LiteralTemplateSection(literalText, doc); + doc.Parts.Add(literal); + currentIndex = minIndex; + } + + if (indices.Count != 0) + { + var section = minReader.ExtractSection(ref currentIndex, doc); + doc.Parts.Add(section); + } + } + + return doc; + } + + public static TemplateDocument FromEmbeddedResource(string resourceName) + { + return FromEmbeddedResource(resourceName, Assembly.GetCallingAssembly()); + } + + public static TemplateDocument FromEmbeddedResource(string resourceName, Assembly assembly) + { + var fileName = assembly.GetManifestResourceNames().First(n => n.EndsWith(resourceName)); + var res = assembly.GetManifestResourceStream(fileName); + var reader = new StreamReader(res); + var templateText = reader.ReadToEnd(); + return Parse(templateText); + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/TemplateDocument.cs b/mROA.CodegenTools/TemplateDocument.cs new file mode 100644 index 0000000..cfaac8f --- /dev/null +++ b/mROA.CodegenTools/TemplateDocument.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace mROA.CodegenTools +{ + public class TemplateDocument : ICloneable + { + public List Parts { get; set; } = new(); + public object AdditionalContext { get; set; } + public ITagged? this[string tag] => Parts.OfType().FirstOrDefault(i => i.Tag == tag); + + public object Clone() + { + var cloneDoc = new TemplateDocument + { + AdditionalContext = AdditionalContext is ICloneable c ? c.Clone() : AdditionalContext + }; + + cloneDoc.Parts = Parts.Select(i => + { + var clone = i.Clone() as ITemplateSection; + clone.Context = cloneDoc; + return clone; + }).ToList(); + + return cloneDoc; + } + + public void Insert(string tag, object value) + { + var selectedPart = this[tag]; + if (selectedPart is InsertTemplateSection itp) itp.Setup(value); + } + + public string Compile() + { + var approximatelyLength = Parts.Sum(i => i.TargetLength); + var stringBuilder = new StringBuilder(approximatelyLength); + + foreach (var part in Parts.OfType()) + { + var baked = part.Bake(); + stringBuilder.Append(baked); + } + + return stringBuilder.ToString(); + } + + public void AddDefine(string tag, string text) + { + Parts.Add(new DefineTemplateSection(text, tag, this)); + } + + public void AddDefine(string tag, object value) + { + AddDefine(tag, value.ToString()); + } + } +} \ No newline at end of file diff --git a/mROA.CodegenTools/mROA.CodegenTools.csproj b/mROA.CodegenTools/mROA.CodegenTools.csproj new file mode 100644 index 0000000..4924533 --- /dev/null +++ b/mROA.CodegenTools/mROA.CodegenTools.csproj @@ -0,0 +1,9 @@ + + + + netstandard2.1 + enable + 9 + + + diff --git a/mROA.sln b/mROA.sln index 40a367e..4532adc 100644 --- a/mROA.sln +++ b/mROA.sln @@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.Cbor", "mROA.Cbor\mROA EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TotalDemo", "TotalDemo", "{FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.CodegenTools", "mROA.CodegenTools\mROA.CodegenTools.csproj", "{FFB8DFAE-17F0-4335-8F17-187B3619E8F2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -61,6 +63,10 @@ Global {6211E4EA-13FD-4EB1-8E6A-C0173DD0784A}.Debug|Any CPU.Build.0 = Debug|Any CPU {6211E4EA-13FD-4EB1-8E6A-C0173DD0784A}.Release|Any CPU.ActiveCfg = Release|Any CPU {6211E4EA-13FD-4EB1-8E6A-C0173DD0784A}.Release|Any CPU.Build.0 = Release|Any CPU + {FFB8DFAE-17F0-4335-8F17-187B3619E8F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FFB8DFAE-17F0-4335-8F17-187B3619E8F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFB8DFAE-17F0-4335-8F17-187B3619E8F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FFB8DFAE-17F0-4335-8F17-187B3619E8F2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mROA/Abstract/IChannelInteractionModule.cs b/mROA/Abstract/IChannelInteractionModule.cs index 2c59de3..db7a3b6 100644 --- a/mROA/Abstract/IChannelInteractionModule.cs +++ b/mROA/Abstract/IChannelInteractionModule.cs @@ -17,5 +17,6 @@ namespace mROA.Abstract Task PostMessageUntrustedAsync(NetworkMessageHeader messageHeader); event Action OnDisconnected; Task Restart(bool sendRecovery); + void PassReconnection(); } } \ No newline at end of file diff --git a/mROA/Implementation/ChannelInteractionModule.cs b/mROA/Implementation/ChannelInteractionModule.cs index f6ac785..1792e48 100644 --- a/mROA/Implementation/ChannelInteractionModule.cs +++ b/mROA/Implementation/ChannelInteractionModule.cs @@ -128,7 +128,11 @@ namespace mROA.Implementation await _trustedWriter.WriteAsync(new NetworkMessageHeader()); } + PassReconnection(); + } + public void PassReconnection() + { _reconnection.TrySetResult(Stream.Null); _isConnected = true; _reconnection = new TaskCompletionSource(); diff --git a/mROA/mROA.csproj b/mROA/mROA.csproj index 3b037dc..7397051 100644 --- a/mROA/mROA.csproj +++ b/mROA/mROA.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable mROA - 2.0.5 + 2.0.6 YaslePoy Fast and easy RPC with contex https://github.com/YaslePoy/mROA