From 1eb4e3896fc2a4a205805fc5188a597b73218e17 Mon Sep 17 00:00:00 2001 From: Xin Chen Date: Thu, 8 Dec 2022 21:04:44 -0800 Subject: [PATCH] [#141] Don't introduce root namespace "Platform" --- Microsoft.Azure.Amqp/Amqp/AmqpMessage.cs | 2 +- .../Amqp/Encoding/SymbolEncoding.cs | 10 +++++----- Microsoft.Azure.Amqp/AmqpTrace.cs | 2 +- Microsoft.Azure.Amqp/PlatformSupport.cs | 19 ++++++++++--------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Microsoft.Azure.Amqp/Amqp/AmqpMessage.cs b/Microsoft.Azure.Amqp/Amqp/AmqpMessage.cs index 77aeb61b..ecd6ae6c 100644 --- a/Microsoft.Azure.Amqp/Amqp/AmqpMessage.cs +++ b/Microsoft.Azure.Amqp/Amqp/AmqpMessage.cs @@ -1220,7 +1220,7 @@ ulong ReadDescriptorCode() { int count = this.ReadInt(formatCode == FormatCode.Symbol8); ArraySegment nameBuffer = this.ReadBytes(count); - string descriptorName = Platform.System.Text.Encoding.ASCII.GetString(nameBuffer.Array, nameBuffer.Offset, count); + string descriptorName = SystemEncoding.ASCII.GetString(nameBuffer.Array, nameBuffer.Offset, count); sectionCodeByName.TryGetValue(descriptorName, out descriptorCode); } diff --git a/Microsoft.Azure.Amqp/Amqp/Encoding/SymbolEncoding.cs b/Microsoft.Azure.Amqp/Amqp/Encoding/SymbolEncoding.cs index 735b267d..789666d0 100644 --- a/Microsoft.Azure.Amqp/Amqp/Encoding/SymbolEncoding.cs +++ b/Microsoft.Azure.Amqp/Amqp/Encoding/SymbolEncoding.cs @@ -14,7 +14,7 @@ public SymbolEncoding() public static int GetValueSize(AmqpSymbol value) { - return value.Value == null ? FixedWidth.Null : Platform.System.Text.Encoding.ASCII.GetByteCount(value.Value); + return value.Value == null ? FixedWidth.Null : SystemEncoding.ASCII.GetByteCount(value.Value); } public static int GetEncodeSize(AmqpSymbol value) @@ -32,7 +32,7 @@ public static void Encode(AmqpSymbol value, ByteBuffer buffer) } else { - byte[] encodedData = Platform.System.Text.Encoding.ASCII.GetBytes(value.Value); + byte[] encodedData = SystemEncoding.ASCII.GetBytes(value.Value); int encodeWidth = AmqpEncoding.GetEncodeWidthBySize(encodedData.Length); AmqpBitConverter.WriteUByte(buffer, encodeWidth == FixedWidth.UByte ? FormatCode.Symbol8 : FormatCode.Symbol32); SymbolEncoding.Encode(encodedData, encodeWidth, buffer); @@ -48,7 +48,7 @@ public static AmqpSymbol Decode(ByteBuffer buffer, FormatCode formatCode) int count; AmqpEncoding.ReadCount(buffer, formatCode, FormatCode.Symbol8, FormatCode.Symbol32, out count); - string value = Platform.System.Text.Encoding.ASCII.GetString(buffer.Buffer, buffer.Offset, count); + string value = SystemEncoding.ASCII.GetString(buffer.Buffer, buffer.Offset, count); buffer.Complete(count); return new AmqpSymbol(value); @@ -58,7 +58,7 @@ public override int GetObjectEncodeSize(object value, bool arrayEncoding) { if (arrayEncoding) { - return FixedWidth.UInt + Platform.System.Text.Encoding.ASCII.GetByteCount(((AmqpSymbol)value).Value); + return FixedWidth.UInt + SystemEncoding.ASCII.GetByteCount(((AmqpSymbol)value).Value); } else { @@ -70,7 +70,7 @@ public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer b { if (arrayEncoding) { - SymbolEncoding.Encode(Platform.System.Text.Encoding.ASCII.GetBytes(((AmqpSymbol)value).Value), FixedWidth.UInt, buffer); + SymbolEncoding.Encode(SystemEncoding.ASCII.GetBytes(((AmqpSymbol)value).Value), FixedWidth.UInt, buffer); } else { diff --git a/Microsoft.Azure.Amqp/AmqpTrace.cs b/Microsoft.Azure.Amqp/AmqpTrace.cs index 09743c38..692969e2 100644 --- a/Microsoft.Azure.Amqp/AmqpTrace.cs +++ b/Microsoft.Azure.Amqp/AmqpTrace.cs @@ -288,7 +288,7 @@ static void TraceFrame(FrameType type, ushort channel, Performative command, boo static void AppendCommon(StringBuilder sb, bool send) { sb.Append('['); - sb.AppendFormat("{0:X3}", Diagnostics.CurrentProcess.ID); + sb.AppendFormat("{0:X3}", CurrentProcess.ID); sb.Append('.'); sb.AppendFormat("{0:X3}", Environment.CurrentManagedThreadId); sb.Append(' '); diff --git a/Microsoft.Azure.Amqp/PlatformSupport.cs b/Microsoft.Azure.Amqp/PlatformSupport.cs index 11ada368..4c05018c 100644 --- a/Microsoft.Azure.Amqp/PlatformSupport.cs +++ b/Microsoft.Azure.Amqp/PlatformSupport.cs @@ -176,16 +176,17 @@ namespace System.Threading #if WINDOWS_UWP - -class Win32 +namespace Microsoft.Azure.Amqp { - [DllImport("kernel32.dll")] - public static extern int GetCurrentProcessId(); + class Win32 + { + [DllImport("kernel32.dll")] + public static extern int GetCurrentProcessId(); + } } - #endif -namespace Diagnostics +namespace Microsoft.Azure.Amqp { static class CurrentProcess { @@ -205,10 +206,10 @@ public static int ID } } -namespace Platform.System.Text +namespace Microsoft.Azure.Amqp { #if PCL - class Encoding + class SystemEncoding { public static global::System.Text.Encoding ASCII { @@ -219,7 +220,7 @@ class Encoding } } #else - class Encoding + class SystemEncoding { public static global::System.Text.Encoding ASCII {