@@ -29,8 +29,8 @@ class SocketAddress : System.IEquatable<SocketAddress>
2929 internal static readonly int MaxAddressSize = SocketAddressPal . MaxAddressSize ;
3030#pragma warning restore CA1802
3131
32- internal int InternalSize ;
33- internal byte [ ] InternalBuffer ;
32+ private int _size ;
33+ private byte [ ] _buffer ;
3434
3535 private const int MinSize = 2 ;
3636 private const int DataOffset = 2 ;
@@ -39,21 +39,21 @@ public AddressFamily Family
3939 {
4040 get
4141 {
42- return SocketAddressPal . GetAddressFamily ( InternalBuffer ) ;
42+ return SocketAddressPal . GetAddressFamily ( _buffer ) ;
4343 }
4444 }
4545
4646 public int Size
4747 {
4848 get
4949 {
50- return InternalSize ;
50+ return _size ;
5151 }
5252 set
5353 {
54- ArgumentOutOfRangeException . ThrowIfGreaterThan ( value , InternalBuffer . Length ) ;
54+ ArgumentOutOfRangeException . ThrowIfGreaterThan ( value , _buffer . Length ) ;
5555 ArgumentOutOfRangeException . ThrowIfLessThan ( value , MinSize ) ;
56- InternalSize = value ;
56+ _size = value ;
5757 }
5858 }
5959
@@ -69,15 +69,15 @@ public byte this[int offset]
6969 {
7070 throw new IndexOutOfRangeException ( ) ;
7171 }
72- return InternalBuffer [ offset ] ;
72+ return _buffer [ offset ] ;
7373 }
7474 set
7575 {
7676 if ( ( uint ) offset >= ( uint ) Size )
7777 {
7878 throw new IndexOutOfRangeException ( ) ;
7979 }
80- InternalBuffer [ offset ] = value ;
80+ _buffer [ offset ] = value ;
8181 }
8282 }
8383
@@ -97,11 +97,11 @@ public SocketAddress(AddressFamily family, int size)
9797 {
9898 ArgumentOutOfRangeException . ThrowIfLessThan ( size , MinSize ) ;
9999
100- InternalSize = size ;
101- InternalBuffer = new byte [ size ] ;
102- InternalBuffer [ 0 ] = ( byte ) InternalSize ;
100+ _size = size ;
101+ _buffer = new byte [ size ] ;
102+ _buffer [ 0 ] = ( byte ) _size ;
103103
104- SocketAddressPal . SetAddressFamily ( InternalBuffer , family ) ;
104+ SocketAddressPal . SetAddressFamily ( _buffer , family ) ;
105105 }
106106
107107 internal SocketAddress ( IPAddress ipAddress )
@@ -110,15 +110,15 @@ internal SocketAddress(IPAddress ipAddress)
110110 {
111111
112112 // No Port.
113- SocketAddressPal . SetPort ( InternalBuffer , 0 ) ;
113+ SocketAddressPal . SetPort ( _buffer , 0 ) ;
114114
115115 if ( ipAddress . AddressFamily == AddressFamily . InterNetworkV6 )
116116 {
117117 Span < byte > addressBytes = stackalloc byte [ IPAddressParserStatics . IPv6AddressBytes ] ;
118118 ipAddress . TryWriteBytes ( addressBytes , out int bytesWritten ) ;
119119 Debug . Assert ( bytesWritten == IPAddressParserStatics . IPv6AddressBytes ) ;
120120
121- SocketAddressPal . SetIPv6Address ( InternalBuffer , addressBytes , ( uint ) ipAddress . ScopeId ) ;
121+ SocketAddressPal . SetIPv6Address ( _buffer , addressBytes , ( uint ) ipAddress . ScopeId ) ;
122122 }
123123 else
124124 {
@@ -127,21 +127,21 @@ internal SocketAddress(IPAddress ipAddress)
127127#pragma warning restore CS0618
128128
129129 Debug . Assert ( ipAddress . AddressFamily == AddressFamily . InterNetwork ) ;
130- SocketAddressPal . SetIPv4Address ( InternalBuffer , address ) ;
130+ SocketAddressPal . SetIPv4Address ( _buffer , address ) ;
131131 }
132132 }
133133
134134 internal SocketAddress ( IPAddress ipaddress , int port )
135135 : this ( ipaddress )
136136 {
137- SocketAddressPal . SetPort ( InternalBuffer , unchecked ( ( ushort ) port ) ) ;
137+ SocketAddressPal . SetPort ( _buffer , unchecked ( ( ushort ) port ) ) ;
138138 }
139139
140140 internal SocketAddress ( AddressFamily addressFamily , ReadOnlySpan < byte > buffer )
141141 {
142- InternalBuffer = buffer . ToArray ( ) ;
143- InternalSize = InternalBuffer . Length ;
144- SocketAddressPal . SetAddressFamily ( InternalBuffer , addressFamily ) ;
142+ _buffer = buffer . ToArray ( ) ;
143+ _size = _buffer . Length ;
144+ SocketAddressPal . SetAddressFamily ( _buffer , addressFamily ) ;
145145 }
146146
147147 /// <summary>This represents underlying memory that can be passed to native OS calls.</summary>
@@ -152,7 +152,7 @@ public Memory<byte> Buffer
152152 {
153153 get
154154 {
155- return new Memory < byte > ( InternalBuffer , 0 , InternalSize ) ;
155+ return new Memory < byte > ( _buffer , 0 , _size ) ;
156156 }
157157 }
158158
@@ -164,14 +164,14 @@ internal IPAddress GetIPAddress()
164164
165165 Span < byte > address = stackalloc byte [ IPAddressParserStatics . IPv6AddressBytes ] ;
166166 uint scope ;
167- SocketAddressPal . GetIPv6Address ( InternalBuffer , address , out scope ) ;
167+ SocketAddressPal . GetIPv6Address ( _buffer , address , out scope ) ;
168168
169169 return new IPAddress ( address , ( long ) scope ) ;
170170 }
171171 else if ( Family == AddressFamily . InterNetwork )
172172 {
173173 Debug . Assert ( Size >= IPv4AddressSize ) ;
174- long address = ( long ) SocketAddressPal . GetIPv4Address ( InternalBuffer ) & 0x0FFFFFFFF ;
174+ long address = ( long ) SocketAddressPal . GetIPv4Address ( _buffer ) & 0x0FFFFFFFF ;
175175 return new IPAddress ( address ) ;
176176 }
177177 else
@@ -184,7 +184,7 @@ internal IPAddress GetIPAddress()
184184 }
185185 }
186186
187- internal int GetPort ( ) => ( int ) SocketAddressPal . GetPort ( InternalBuffer ) ;
187+ internal int GetPort ( ) => ( int ) SocketAddressPal . GetPort ( _buffer ) ;
188188
189189 internal IPEndPoint GetIPEndPoint ( )
190190 {
@@ -199,7 +199,7 @@ public override bool Equals(object? comparand) =>
199199 public override int GetHashCode ( )
200200 {
201201 HashCode hash = default ;
202- hash . AddBytes ( new ReadOnlySpan < byte > ( InternalBuffer , 0 , InternalSize ) ) ;
202+ hash . AddBytes ( new ReadOnlySpan < byte > ( _buffer , 0 , _size ) ) ;
203203 return hash . ToHashCode ( ) ;
204204 }
205205
@@ -234,7 +234,7 @@ public override string ToString()
234234 result [ length ++ ] = ':' ;
235235 result [ length ++ ] = '{' ;
236236
237- byte [ ] buffer = InternalBuffer ;
237+ byte [ ] buffer = _buffer ;
238238 for ( int i = DataOffset ; i < Size ; i ++ )
239239 {
240240 if ( i > DataOffset )
0 commit comments