Добавление препроцессора для очистки консоли

This commit is contained in:
2025-02-25 22:38:53 +03:00
parent d1a4d6f97e
commit c36e768210
15 changed files with 61 additions and 30 deletions
+4
View File
@@ -10,6 +10,10 @@
<LangVersion>9</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Example.Shared\Example.Shared.csproj" />
</ItemGroup>
-2
View File
@@ -1,6 +1,4 @@
using System;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Example.Shared;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Net;
using System.Text;
using System.Threading;
+1 -3
View File
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace mROA.Benchmark
{
-1
View File
@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Formats.Cbor;
using System.Linq;
using System.Reflection;
using System.Text.Json;
using mROA.Abstract;
using mROA.Implementation;
using mROA.Implementation.Attributes;
+4 -4
View File
@@ -27,18 +27,18 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.Build.0 = Release|Any CPU
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.Build.0 = Release|Any CPU
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.Build.0 = Release|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.Build.0 = Release|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.Build.0 = Release|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Release|Any CPU.ActiveCfg = Release|Any CPU
-1
View File
@@ -1,7 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
using mROA.Implementation;
using mROA.Implementation.CommandExecution;
@@ -21,8 +21,9 @@ namespace mROA.Implementation.Backend
public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
IRepresentationModule representationModule)
{
#if TRACE
Console.WriteLine(command.GetType().Name);
#endif
if (_cancellationRepo is null)
throw new NullReferenceException("Method repository was not defined");
@@ -34,7 +35,9 @@ namespace mROA.Implementation.Backend
if (command is CancelRequest)
{
#if TRACE
Console.WriteLine("Final cancelling request");
#endif
var cts = _cancellationRepo.GetCancellation(command.Id);
cts.Cancel();
_cancellationRepo.FreeCancelation(command.Id);
@@ -68,7 +71,9 @@ namespace mROA.Implementation.Backend
var result = Execute(currentCommand, context, parameter, command);
if (command.CommandId == -1)
{
#if TRACE
Console.WriteLine("Disposing object");
#endif
contextRepository.ClearObject(command.ObjectId);
}
@@ -118,7 +123,9 @@ namespace mROA.Implementation.Backend
var tokenSource = new CancellationTokenSource();
cancellationRepository.RegisterCancellation(command.Id, tokenSource);
var token = tokenSource.Token;
#if TRACE
token.Register(() => Console.WriteLine($"Cancellation requested check {command.Id}"));
#endif
try
{
var finalParameter = parameter is null
@@ -63,7 +63,9 @@ namespace mROA.Implementation.Frontend
{
while (true)
{
#if TRACE
Console.WriteLine("Waiting for request...");
#endif
var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var defaultRequest =
@@ -75,11 +77,14 @@ namespace mROA.Implementation.Frontend
Task.WaitAny(defaultRequest, cancelRequest);
#if TRACE
Console.WriteLine("Request received");
#endif
if (cancelRequest.IsCompleted)
{
#if TRACE
Console.WriteLine("Cancelling request");
#endif
var req = cancelRequest.Result;
tokenSource.Cancel();
_executeModule.Execute(req, _contextRepository, _representationModule);
@@ -87,7 +87,9 @@ namespace mROA.Implementation
// Console.WriteLine("Receiving {0}", Encoding.Default.GetString(_buffer[..len]));
var message = _serialization.Deserialize<NetworkMessage>(localSpan.Span);
#if TRACE
Console.WriteLine($"Received Message {message.SchemaId} - {message.Id}");
#endif
_messageBuffer.Add(message);
_currentReceiving = Task.Run(async () => await GetNextMessage());
+6 -1
View File
@@ -42,7 +42,9 @@ namespace mROA.Implementation
cancellationToken.Register(async () =>
{
#if TRACE
Console.WriteLine("Cancelling task");
#endif
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
new CancelRequest
{
@@ -92,7 +94,9 @@ namespace mROA.Implementation
cancellationToken.Register(async () =>
{
#if TRACE
Console.WriteLine("Cancelling task");
#endif
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
new CancelRequest
{
@@ -106,8 +110,9 @@ namespace mROA.Implementation
errorResponse, successResponse
}, cancellationToken);
#if TRACE
Console.WriteLine($"Handling message");
#endif
if (successResponse.IsCompletedSuccessfully)
return;
+8 -4
View File
@@ -23,9 +23,11 @@ namespace mROA.Implementation
}
}
public int Id => (_interaction ?? throw new NullReferenceException("Interaction is not initialized")).ConnectionId;
public int Id => (_interaction ?? throw new NullReferenceException("Interaction is not initialized"))
.ConnectionId;
public async Task<T> GetMessageAsync<T>(Guid? requestId, MessageType? messageType, CancellationToken token = default)
public async Task<T> GetMessageAsync<T>(Guid? requestId, MessageType? messageType,
CancellationToken token = default)
{
if (_serialization == null)
throw new NullReferenceException("Serialization toolkit is not initialized");
@@ -43,7 +45,8 @@ namespace mROA.Implementation
return _serialization.Deserialize<T>(rawMessage)!;
}
public async Task<byte[]> GetRawMessage(Guid? requestId = null, MessageType? messageType = null, CancellationToken token = default)
public async Task<byte[]> GetRawMessage(Guid? requestId = null, MessageType? messageType = null,
CancellationToken token = default)
{
if (_interaction == null)
throw new NullReferenceException("Interaction toolkit is not initialized");
@@ -82,8 +85,9 @@ namespace mROA.Implementation
throw new NullReferenceException("Interaction toolkit is not initialized");
if (_serialization == null)
throw new NullReferenceException("Serialization toolkit is not initialized");
#if TRACE
Console.WriteLine($"Posting message: {id} - {messageType}");
#endif
var serialized = _serialization.Serialize(payload, payloadType);
await _interaction.PostMessage(new NetworkMessage
+3 -1
View File
@@ -79,7 +79,8 @@ namespace mROA.Implementation
}
}
[JsonIgnore] public T Value { get; private set; }
[JsonIgnore]
public T Value { get; private set; }
// ReSharper disable once MemberCanBePrivate.Global
// ReSharper disable once UnusedMember.Global
@@ -106,6 +107,7 @@ namespace mROA.Implementation
public static implicit operator SharedObject<T>(T value) =>
new(value);
[JsonIgnore]
public IEndPointContext EndPointContext { get; set; } = new EndPointContext
{
RealRepository = TransmissionConfig.RealContextRepository,
+4 -5
View File
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using global::System;
using global::System.IO;
using global::System.Threading;
using global::System.Threading.Tasks;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace mROA
{
+10
View File
@@ -12,6 +12,16 @@
<RepositoryType>git</RepositoryType>
<PackageTags>RPC</PackageTags>
<LangVersion>9</LangVersion>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants />
</PropertyGroup>
<ItemGroup>