style(dotnet): run dotnet format

This commit is contained in:
Benoît CORTIER
2024-04-09 11:35:48 -04:00
committed by Benoît Cortier
parent bffe18d204
commit d70c9f0e98
5 changed files with 21 additions and 15 deletions
@@ -87,7 +87,7 @@ namespace Devolutions.IronRdp.ConnectExample
bytes[i + 2] = temp; // Move original Blue to Red's position
// Green (bytes[i+1]) and Alpha (bytes[i+3]) remain unchanged
}
#if WINDOWS // Bitmap is only available on Windows
#if WINDOWS // Bitmap is only available on Windows
using (var bmp = new Bitmap(width, height))
{
// Lock the bits of the bitmap.
@@ -104,7 +104,7 @@ namespace Devolutions.IronRdp.ConnectExample
// Save the bitmap to the specified output path
bmp.Save("./output.bmp", ImageFormat.Bmp);
}
#endif
#endif
}
@@ -46,11 +46,11 @@ public struct DiplomatWriteable : IDisposable
IntPtr flushFuncPtr = Marshal.GetFunctionPointerForDelegate(flushFunc);
IntPtr growFuncPtr = Marshal.GetFunctionPointerForDelegate(growFunc);
// flushFunc and growFunc are managed objects and might be disposed of by the garbage collector.
// To prevent this, we make the context hold the references and protect the context itself
// for automatic disposal by moving it behind a GCHandle.
DiplomatWriteableContext ctx = new DiplomatWriteableContext();
DiplomatWriteableContext ctx = new DiplomatWriteableContext();
ctx.flushFunc = flushFunc;
ctx.growFunc = growFunc;
GCHandle ctxHandle = GCHandle.Alloc(ctx);
@@ -81,7 +81,7 @@ public struct DiplomatWriteable : IDisposable
{
throw new IndexOutOfRangeException("DiplomatWriteable buffer is too big");
}
return Marshal.PtrToStringUTF8(buf, (int) len);
return Marshal.PtrToStringUTF8(buf, (int)len);
#else
byte[] utf8 = ToUtf8Bytes();
return DiplomatUtils.Utf8ToString(utf8);
@@ -7,7 +7,7 @@ using Devolutions.IronRdp;
public class Connection
{
public static async Task<(ConnectionResult,Framed<SslStream>)> Connect(Config config,string servername)
public static async Task<(ConnectionResult, Framed<SslStream>)> Connect(Config config, string servername)
{
var stream = await CreateTcpConnection(servername, 3389);
@@ -26,7 +26,7 @@ public class Connection
await connectBegin(framed, connector);
var (serverPublicKey, framedSsl) = await securityUpgrade(servername, framed, connector);
var result = await ConnectFinalize(servername, connector, serverPublicKey, framedSsl);
var result = await ConnectFinalize(servername, connector, serverPublicKey, framedSsl);
return (result, framedSsl);
}
@@ -3,7 +3,7 @@ public class IronRdpLibException : Exception
{
public IronRdpLibExceptionType type { get; private set; }
public IronRdpLibException(IronRdpLibExceptionType type, string message): base(message)
public IronRdpLibException(IronRdpLibExceptionType type, string message) : base(message)
{
this.type = type;
}
+13 -7
View File
@@ -18,19 +18,25 @@ public class Framed<S> where S : Stream
return (this.stream, this.buffer);
}
public async Task<(Devolutions.IronRdp.Action,byte[])> ReadPdu() {
public async Task<(Devolutions.IronRdp.Action, byte[])> ReadPdu()
{
while(true) {
while (true)
{
var pduInfo = IronRdpPdu.New().FindSize(this.buffer.ToArray());
if (null != pduInfo) {
if (null != pduInfo)
{
var frame = await this.ReadExact(pduInfo.GetLength());
var action = pduInfo.GetAction();
return (action,frame);
}else {
return (action, frame);
}
else
{
var len = await this.Read();
if (len == 0) {
throw new IronRdpLibException(IronRdpLibExceptionType.EndOfFile,"EOF on ReadPdu");
if (len == 0)
{
throw new IronRdpLibException(IronRdpLibExceptionType.EndOfFile, "EOF on ReadPdu");
}
}
}