Skip to content

Commit

Permalink
[#141] Don't introduce root namespace "Platform"
Browse files Browse the repository at this point in the history
  • Loading branch information
xinchen10 committed Dec 9, 2022
1 parent bded11d commit 1eb4e38
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Microsoft.Azure.Amqp/Amqp/AmqpMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ ulong ReadDescriptorCode()
{
int count = this.ReadInt(formatCode == FormatCode.Symbol8);
ArraySegment<byte> 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);
}

Expand Down
10 changes: 5 additions & 5 deletions Microsoft.Azure.Amqp/Amqp/Encoding/SymbolEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Amqp/AmqpTrace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
Expand Down
19 changes: 10 additions & 9 deletions Microsoft.Azure.Amqp/PlatformSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -219,7 +220,7 @@ class Encoding
}
}
#else
class Encoding
class SystemEncoding
{
public static global::System.Text.Encoding ASCII
{
Expand Down

0 comments on commit 1eb4e38

Please sign in to comment.