Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 57b0c2c

Browse files
committed
Fix ConsoleEncoding to delegate all virtuals
ConsoleEncoding is supposed to pass through all calls to the Encoding it wraps, replacing only GetPreamble, but it was missing several, as discovered while writing some new tests. This just adds the missing overrides.
1 parent c80e1a9 commit 57b0c2c

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/System.Console/src/System/Text/ConsoleEncoding.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ public override byte[] GetPreamble()
2222
return Array.Empty<byte>();
2323
}
2424

25+
public override int CodePage
26+
{
27+
get { return _encoding.CodePage; }
28+
}
29+
30+
public override bool IsSingleByte
31+
{
32+
get { return _encoding.IsSingleByte; }
33+
}
34+
35+
public override string EncodingName
36+
{
37+
get { return _encoding.EncodingName; }
38+
}
39+
2540
public override string WebName
2641
{
2742
get { return _encoding.WebName; }
@@ -32,6 +47,11 @@ public override int GetByteCount(char[] chars)
3247
return _encoding.GetByteCount(chars);
3348
}
3449

50+
public override unsafe int GetByteCount(char* chars, int count)
51+
{
52+
return _encoding.GetByteCount(chars, count);
53+
}
54+
3555
public override int GetByteCount(char[] chars, int index, int count)
3656
{
3757
return _encoding.GetByteCount(chars, index, count);
@@ -42,6 +62,11 @@ public override int GetByteCount(string s)
4262
return _encoding.GetByteCount(s);
4363
}
4464

65+
public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
66+
{
67+
return _encoding.GetBytes(chars, charCount, bytes, byteCount);
68+
}
69+
4570
public override byte[] GetBytes(char[] chars)
4671
{
4772
return _encoding.GetBytes(chars);
@@ -67,6 +92,11 @@ public override int GetBytes(string s, int charIndex, int charCount, byte[] byte
6792
return _encoding.GetBytes(s, charIndex, charCount, bytes, byteIndex);
6893
}
6994

95+
public override unsafe int GetCharCount(byte* bytes, int count)
96+
{
97+
return _encoding.GetCharCount(bytes, count);
98+
}
99+
70100
public override int GetCharCount(byte[] bytes)
71101
{
72102
return _encoding.GetCharCount(bytes);
@@ -77,6 +107,11 @@ public override int GetCharCount(byte[] bytes, int index, int count)
77107
return _encoding.GetCharCount(bytes, index, count);
78108
}
79109

110+
public override unsafe int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
111+
{
112+
return _encoding.GetChars(bytes, byteCount, chars, charCount);
113+
}
114+
80115
public override char[] GetChars(byte[] bytes)
81116
{
82117
return _encoding.GetChars(bytes);
@@ -112,9 +147,14 @@ public override int GetMaxCharCount(int byteCount)
112147
return _encoding.GetMaxCharCount(byteCount);
113148
}
114149

150+
public override string GetString(byte[] bytes)
151+
{
152+
return _encoding.GetString(bytes);
153+
}
154+
115155
public override string GetString(byte[] bytes, int index, int count)
116156
{
117157
return _encoding.GetString(bytes, index, count);
118158
}
119159
}
120-
}
160+
}

0 commit comments

Comments
 (0)