2745 references to UTF8
AnalyzerRunner (2)
DiagnosticAnalyzerRunner.cs (2)
228File.WriteAllText(fileName, completeOutput.ToString(), Encoding.UTF8); 229File.WriteAllText(uniqueFileName, uniqueOutput.ToString(), Encoding.UTF8);
aspire (1)
Program.cs (1)
169Console.OutputEncoding = Encoding.UTF8;
Aspire.Azure.Messaging.EventHubs.Tests (2)
AspireEventHubsExtensionsTests.cs (1)
624var buffer = Encoding.UTF8.GetBytes(content);
tests\Aspire.Azure.Security.KeyVault.Tests\MockTransport.cs (1)
163SetContent(Encoding.UTF8.GetBytes(content));
Aspire.Azure.Security.KeyVault.Tests (2)
AspireKeyVaultExtensionsTests.cs (1)
150var buffer = Encoding.UTF8.GetBytes(content);
MockTransport.cs (1)
163SetContent(Encoding.UTF8.GetBytes(content));
Aspire.Cli.Tests (1)
Utils\CliTestHelper.cs (1)
243public override Encoding Encoding => Encoding.UTF8;
Aspire.Confluent.Kafka (2)
src\Vendoring\OpenTelemetry.Instrumentation.ConfluentKafka\InstrumentedProducer.cs (1)
368message.Headers.Add(key, Encoding.UTF8.GetBytes(value));
src\Vendoring\OpenTelemetry.Instrumentation.ConfluentKafka\OpenTelemetryConsumeResultExtensions.cs (1)
181yield return Encoding.UTF8.GetString(bytes);
Aspire.Confluent.Kafka.Tests (2)
ConsumerConfigurationTests.cs (1)
222static Stream CreateStreamFromString(string data) => new MemoryStream(Encoding.UTF8.GetBytes(data));
ProducerConfigurationTests.cs (1)
212static Stream CreateStreamFromString(string data) => new MemoryStream(Encoding.UTF8.GetBytes(data));
Aspire.Dashboard (8)
Components\Dialogs\TextVisualizerDialog.razor.cs (2)
192var jsonData = Encoding.UTF8.GetBytes(jsonString); 257var formattedJson = Encoding.UTF8.GetString(stream.ToArray());
Configuration\DashboardOptions.cs (4)
49_apiKeyBytes = ApiKey != null ? Encoding.UTF8.GetBytes(ApiKey) : null; 134_primaryApiKeyBytes = PrimaryApiKey != null ? Encoding.UTF8.GetBytes(PrimaryApiKey) : null; 135_secondaryApiKeyBytes = SecondaryApiKey != null ? Encoding.UTF8.GetBytes(SecondaryApiKey) : null; 206_browserTokenBytes = BrowserToken != null ? Encoding.UTF8.GetBytes(BrowserToken) : null;
src\Shared\CompareHelpers.cs (2)
18var requestByteCount = Encoding.UTF8.GetByteCount(requestKey); 29var encodedByteCount = Encoding.UTF8.GetBytes(requestKey, requestBytesSpan);
Aspire.Dashboard.Components.Tests (10)
Pages\TraceDetailsTests.cs (5)
75var traceId = Convert.ToHexString(Encoding.UTF8.GetBytes("1")); 130var traceId = Convert.ToHexString(Encoding.UTF8.GetBytes("1")); 146traceId = Convert.ToHexString(Encoding.UTF8.GetBytes("2")); 212var traceId = Convert.ToHexString(Encoding.UTF8.GetBytes("1")); 269var traceId = Convert.ToHexString(Encoding.UTF8.GetBytes("1"));
tests\Shared\Telemetry\TelemetryTestHelpers.cs (5)
37var resolved = Encoding.UTF8.GetString(bytes); 43var id = Encoding.UTF8.GetBytes(text); 160TraceId = ByteString.CopyFrom(Encoding.UTF8.GetBytes(traceId)), 161SpanId = ByteString.CopyFrom(Encoding.UTF8.GetBytes(spanId)), 162ParentSpanId = parentSpanId is null ? ByteString.Empty : ByteString.CopyFrom(Encoding.UTF8.GetBytes(parentSpanId)),
Aspire.Dashboard.Tests (16)
Integration\OtlpHttpServiceTests.cs (1)
229using var content = new ByteArrayContent(Encoding.UTF8.GetBytes("{}"));
TelemetryRepositoryTests\MetricsTests.cs (2)
415SpanId = ByteString.CopyFrom(Encoding.UTF8.GetBytes("span-id")), 416TraceId = ByteString.CopyFrom(Encoding.UTF8.GetBytes("trace-id"))
TelemetryRepositoryTests\TraceTests.cs (8)
616TraceId = ByteString.CopyFrom(Encoding.UTF8.GetBytes("1")), 617SpanId = ByteString.CopyFrom(Encoding.UTF8.GetBytes("1-1")), 625TraceId = ByteString.CopyFrom(Encoding.UTF8.GetBytes("2")), 626SpanId = ByteString.CopyFrom(Encoding.UTF8.GetBytes("2-1")), 966TraceId = ByteString.CopyFrom(Encoding.UTF8.GetBytes(traceId)), 967SpanId = ByteString.CopyFrom(Encoding.UTF8.GetBytes($"{traceId}-2")), 975TraceId = ByteString.CopyFrom(Encoding.UTF8.GetBytes(traceId)), 976SpanId = ByteString.CopyFrom(Encoding.UTF8.GetBytes($"{traceId}-1")),
tests\Shared\Telemetry\TelemetryTestHelpers.cs (5)
37var resolved = Encoding.UTF8.GetString(bytes); 43var id = Encoding.UTF8.GetBytes(text); 160TraceId = ByteString.CopyFrom(Encoding.UTF8.GetBytes(traceId)), 161SpanId = ByteString.CopyFrom(Encoding.UTF8.GetBytes(spanId)), 162ParentSpanId = parentSpanId is null ? ByteString.Empty : ByteString.CopyFrom(Encoding.UTF8.GetBytes(parentSpanId)),
Aspire.Hosting (10)
Dashboard\ResourceServiceOptions.cs (1)
32_apiKeyBytes = value is null ? null : Encoding.UTF8.GetBytes(value);
Dcp\DcpHost.cs (2)
325loggerCache[hashValue] = logger = _loggerFactory.CreateLogger($"Aspire.Hosting.Dcp.{Encoding.UTF8.GetString(category)}"); 328return (logger, logLevel, Encoding.UTF8.GetString(message));
Dcp\DcpKubernetesClient.cs (1)
130httpRequest.Content = new StringContent(content, System.Text.Encoding.UTF8);
DistributedApplicationBuilder.cs (2)
219var appHostNameShaBytes = SHA256.HashData(Encoding.UTF8.GetBytes(appHostName)); 224var appHostShaBytes = SHA256.HashData(Encoding.UTF8.GetBytes(AppHostPath));
src\Shared\CompareHelpers.cs (2)
18var requestByteCount = Encoding.UTF8.GetByteCount(requestKey); 29var encodedByteCount = Encoding.UTF8.GetBytes(requestKey, requestBytesSpan);
src\Shared\SecretsStore.cs (1)
75File.WriteAllText(_secretsFilePath, json, Encoding.UTF8);
Utils\ImageNameGenerator.cs (1)
21var bytes = Encoding.UTF8.GetBytes($"{builder.ApplicationBuilder.AppHostDirectory}{DateTime.UtcNow.Ticks}");
Aspire.Hosting.Azure (2)
AzureBicepResource.cs (1)
141using var reader = new StreamReader(resourceStream, Encoding.UTF8);
Provisioning\BicepUtilities.cs (1)
95var hashedContents = Crc32.Hash(Encoding.UTF8.GetBytes(input));
Aspire.Hosting.Azure.EventHubs (2)
AzureEventHubsExtensions.cs (2)
315Contents = Encoding.UTF8.GetString(writeStream.ToArray()), 445return Encoding.UTF8.GetString(stream.ToArray());
Aspire.Hosting.Azure.ServiceBus (2)
AzureServiceBusExtensions.cs (2)
452Contents = Encoding.UTF8.GetString(writeStream.ToArray()), 588return Encoding.UTF8.GetString(stream.ToArray());
Aspire.Hosting.Azure.Tests (14)
AzureEventHubsExtensionsTests.cs (2)
101await producerClient.SendAsync([new EventData(Encoding.UTF8.GetBytes("hello worlds"))]); 105Assert.Equal("hello worlds", Encoding.UTF8.GetString(partitionEvent.Data.EventBody.ToArray()));
DefaultUserPrincipalProviderTests.cs (9)
98var header = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { alg = "RS256", typ = "JWT" }))); 109var payloadBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(payloadJson)) 114var signature = Convert.ToBase64String(Encoding.UTF8.GetBytes("test-signature")); 121var header = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { alg = "RS256", typ = "JWT" }))); 132var payloadBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(payloadJson)) 137var signature = Convert.ToBase64String(Encoding.UTF8.GetBytes("test-signature")); 191var header = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { alg = "RS256", typ = "JWT" }))); 202var payloadBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(payloadJson)) 207var signature = Convert.ToBase64String(Encoding.UTF8.GetBytes("test-signature"));
ProvisioningTestHelpers.cs (3)
80var headerBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(headerJson)) 94var payloadBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(payloadJson)) 99var signatureBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes("test-signature"))
Aspire.Hosting.Kubernetes (2)
Yaml\ByteArrayStringYamlConverter.cs (2)
24return string.IsNullOrEmpty(scalar.Value) ? null : Encoding.UTF8.GetBytes(scalar.Value); 43emitter.Emit(new Scalar(Encoding.UTF8.GetString(obj)));
Aspire.Hosting.PostgreSQL (1)
PostgresBuilderExtensions.cs (1)
556return Encoding.UTF8.GetString(stream.ToArray());
Aspire.Hosting.RabbitMQ.Tests (4)
RabbitMQFunctionalTests.cs (4)
85var body = Encoding.UTF8.GetBytes(message); 90Assert.Equal(message, Encoding.UTF8.GetString(result!.Body.Span)); 148var body = Encoding.UTF8.GetBytes(message); 205Assert.Equal("Hello World!", Encoding.UTF8.GetString(result!.Body.Span));
Aspire.Hosting.Seq.Tests (1)
SeqFunctionalTests.cs (1)
54var content = new StringContent(payload, Encoding.UTF8, "application/json");
Aspire.Hosting.Tests (11)
AspireStoreTests.cs (2)
64var content = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("Test content")); 107var content = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("Test content"));
Dcp\DcpExecutorTests.cs (6)
608await pipes.StandardOut.Writer.WriteAsync(Encoding.UTF8.GetBytes("2024-08-19T06:10:33.473275911Z Hello world" + Environment.NewLine)); 619await pipes.StandardErr.Writer.WriteAsync(Encoding.UTF8.GetBytes("2024-08-19T06:10:32.661Z Next" + Environment.NewLine)); 662return new MemoryStream(Encoding.UTF8.GetBytes("2024-08-19T06:10:01.000Z First" + Environment.NewLine)); 664return new MemoryStream(Encoding.UTF8.GetBytes("2024-08-19T06:10:02.000Z Second" + Environment.NewLine)); 666return new MemoryStream(Encoding.UTF8.GetBytes("2024-08-19T06:10:03.000Z Third" + Environment.NewLine)); 668return new MemoryStream(Encoding.UTF8.GetBytes(
Dcp\TestKubernetesService.cs (1)
34_startStream = startStream ?? ((obj, logStreamType) => new MemoryStream(Encoding.UTF8.GetBytes($"Logs for {obj.Metadata.Name} ({logStreamType})")));
ProjectResourceTests.cs (1)
681.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(JsonConfigString)))
UserSecretsParameterDefaultTests.cs (1)
65File.WriteAllText(userSecretsPath, secretsFileContents, Encoding.UTF8);
Aspire.RabbitMQ.Client.Tests (1)
AspireRabbitMQExtensionsTests.cs (1)
116static Stream CreateStreamFromString(string data) => new MemoryStream(Encoding.UTF8.GetBytes(data));
Aspire.RabbitMQ.Client.v7.Tests (1)
tests\Aspire.RabbitMQ.Client.Tests\AspireRabbitMQExtensionsTests.cs (1)
116static Stream CreateStreamFromString(string data) => new MemoryStream(Encoding.UTF8.GetBytes(data));
AzureFunctionsEndToEnd.ApiService (2)
Program.cs (2)
31var data = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello, World!")); 57var data = new BinaryData(Encoding.UTF8.GetBytes(RandomString(length)));
BasicWebSite (2)
Formatters\VCardFormatter_V3.cs (1)
20SupportedEncodings.Add(Encoding.UTF8);
Formatters\VCardFormatter_V4.cs (1)
21SupportedEncodings.Add(Encoding.UTF8);
Benchmarks (2)
StartupUsingEndpointRouting.cs (1)
11private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
StartupUsingRouter.cs (1)
10private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
BinaryFormatTests (1)
FormatTests\FormattedObject\PrimitiveTypeTests.cs (1)
24using (BinaryWriter writer = new(stream, Encoding.UTF8, leaveOpen: true))
Binding.Http.IntegrationTests (1)
MtomBindingTestHelper.cs (1)
68var mtomElement = new MtomMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8);
BoundTreeGenerator (1)
Program.cs (1)
61using (var outfile = new StreamWriter(File.Open(outfilename, FileMode.Create), Encoding.UTF8))
BuildBoss (2)
OptProfCheckerUtil.cs (1)
105using var reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 2048, leaveOpen: true);
SharedUtil.cs (1)
19internal static Encoding Encoding { get; } = Encoding.UTF8;
BuildValidator (1)
Program.cs (1)
373var documents = JsonConvert.DeserializeAnonymousType(Encoding.UTF8.GetString(sourceLinkUtf8), new { documents = (Dictionary<string, string>?)null })?.documents
Client.TypedClient.IntegrationTests (3)
TypedProxyTests.4.0.0.cs (3)
231new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8), 295new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8), 359new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8),
ClientSample (2)
RawSample.cs (2)
86await output.WriteLineAsync(Encoding.UTF8.GetString(buffer.ToArray())); 106await output.WriteAsync(Encoding.UTF8.GetBytes(result));
ConfigurationSchemaGenerator.Tests (1)
GeneratorTests.cs (1)
159var bytes = Encoding.UTF8.GetBytes($"<summary>{input}</summary>");
Contract.Service.IntegrationTests (2)
ServiceContractTests.4.0.0.cs (2)
499var reader = new StreamReader(stream, Encoding.UTF8); 506var sw = new StreamWriter(ms, Encoding.UTF8);
CorsMiddlewareWebSite (1)
EchoMiddleware.cs (1)
29return context.Response.WriteAsync(path, Encoding.UTF8);
csc (2)
src\Compilers\Shared\BuildServerConnection.cs (1)
575var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(pipeNameInput));
src\Compilers\Shared\CompilerServerLogger.cs (1)
157byte[] bytes = Encoding.UTF8.GetBytes(output);
CSharpErrorFactsGenerator (1)
Program.cs (1)
135File.WriteAllText(outputPath, outputText.ToString(), Encoding.UTF8);
CSharpSyntaxGenerator (2)
Program.cs (2)
100using var outFile = new StreamWriter(File.Open(outputMainFile, FileMode.Create), Encoding.UTF8); 171using var outFile = new StreamWriter(File.Open(outputFile, FileMode.Create), Encoding.UTF8);
CustomAuthorizationFailureResponse (1)
Authorization\SampleAuthorizationMiddlewareResultHandler.cs (1)
58httpContext.Response.OnStarting(() => httpContext.Response.BodyWriter.WriteAsync(Encoding.UTF8.GetBytes(message)).AsTask());
dotnet-getdocument (1)
src\Tools\GetDocumentInsider\src\ProgramBase.cs (1)
28Console.OutputEncoding = Encoding.UTF8;
dotnet-razorpagegenerator (1)
Program.cs (1)
189return new MemoryStream(Encoding.UTF8.GetBytes(processedContent));
dotnet-svcutil.xmlserializer (1)
Microsoft\Tools\ServiceModel\SvcUtil\Tool.cs (1)
99if ((System.Console.OutputEncoding.CodePage != Encoding.UTF8.CodePage) &&
dotnet-svcutil-lib (53)
CodeDomFixup\MethodCreationHelper.cs (1)
1619if (encoding.WebName == Encoding.UTF8.WebName)
FrameworkFork\Microsoft.CodeDom\Compiler\CodeCompiler.cs (3)
272using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8)) 344using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8)) 384using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8))
FrameworkFork\Microsoft.CodeDom\Microsoft\CSharpCodeProvider.cs (4)
713using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8)) 3928string[] lines = ReadAllLines(outputFile, Encoding.UTF8, FileShare.ReadWrite); 4180using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8)) 4241using (StreamWriter sw = new StreamWriter(temp, Encoding.UTF8))
FrameworkFork\Microsoft.Xml\Xml\Core\XmlTextReaderImpl.cs (1)
3252_ps.encoding = Encoding.UTF8;
FrameworkFork\Microsoft.Xml\Xml\Core\XmlWriterSettings.cs (2)
502Debug.Assert(Encoding.UTF8.WebName == "utf-8"); 688_encoding = Encoding.UTF8;
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\DataContract.cs (1)
1862byte[] namespaceBytes = Encoding.UTF8.GetBytes(namespaces);
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\ExceptionDataContract.cs (1)
589byte[] byteBuffer = Encoding.UTF8.GetBytes(result);
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\XmlObjectSerializer.cs (1)
26XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8, false /*ownsStream*/);
FrameworkFork\System.Runtime.Serialization\System\Xml\EncodingStreamWrapper.cs (1)
640_byteCount = Encoding.UTF8.GetBytes(_chars, 0, charCount, _bytes, 0);
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlDictionaryString.cs (1)
80_buffer = System.Text.Encoding.UTF8.GetBytes(_value);
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlNodeWriter.cs (8)
35WriteStartElement(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(localNameBuffer, localNameOffset, localNameLength)); 50WriteEndElement(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(localNameBuffer, localNameOffset, localNameLength)); 55WriteXmlnsAttribute(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(nsBuffer, nsOffset, nsLength)); 61WriteStartAttribute(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(localNameBuffer, localNameOffset, localNameLength));
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlUTF8TextReader.cs (2)
666XmlExceptionHelper.ThrowTokenExpected(this, "?>", Encoding.UTF8.GetString(buffer, offset, 2)); 1077XmlExceptionHelper.ThrowTokenExpected(this, "[CDATA[", Encoding.UTF8.GetString(buffer, offset, 7));
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlUTF8TextWriter.cs (2)
29if (encoding.WebName != Encoding.UTF8.WebName) 106if (encoding != null && encoding == Encoding.UTF8)
FrameworkFork\System.ServiceModel\Internals\System\Runtime\UrlUtility.cs (4)
31return ParseQueryString(query, Encoding.UTF8); 60return UrlEncode(str, Encoding.UTF8); 79return UrlEncodeSpaces(UrlEncodeNonAscii(str, Encoding.UTF8)); 148e = Encoding.UTF8;
FrameworkFork\System.ServiceModel\System\IdentityModel\CanonicalFormWriter.cs (1)
15internal static readonly Encoding Utf8WithoutPreamble = Encoding.UTF8;
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\BinaryMessageEncoder.cs (5)
391int utf8ValueSize = Encoding.UTF8.GetByteCount(newStrings[i].Value); 422int utf8ValueSize = Encoding.UTF8.GetByteCount(newString); 424offset += Encoding.UTF8.GetBytes(newString, 0, newString.Length, buffer, offset); 496string value = Encoding.UTF8.GetString(buffer, offset, utf8ValueSize); 905int bytesRequired = Encoding.UTF8.GetByteCount(s.Value);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\FramingDecoders.cs (1)
159_value = Encoding.UTF8.GetString(_encodedBytes, 0, _encodedSize);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\FramingEncoders.cs (2)
56int valueByteCount = Encoding.UTF8.GetByteCount(value); 62Encoding.UTF8.GetBytes(value, 0, value.Length, _encodedBytes, offset);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpChannelHelpers.cs (1)
171return Encoding.UTF8.GetString(responseBuffer, 0, bytesToRead);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\TransportDefaults.cs (2)
58public static readonly Encoding[] SupportedEncodings = new Encoding[] { Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode }; 63new CharSetEncoding("utf-8", Encoding.UTF8),
FrameworkFork\System.ServiceModel\System\ServiceModel\Security\WSSecurityPolicy.cs (2)
2292writer = new XmlTextWriter(stream, System.Text.Encoding.UTF8); 2307writer = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
FrameworkFork\System.ServiceModel\System\ServiceModel\Security\WSTrust.cs (1)
807using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateDictionaryWriter(new XmlTextWriter(stream, Encoding.UTF8)))
Metadata\ServiceDescriptor.cs (2)
127Encoding encoding = Encoding.UTF8; 132Encoding.UTF8,
Shared\Utilities\ProcessRunner.cs (2)
88proc.StartInfo.StandardErrorEncoding = Encoding.UTF8; 89proc.StartInfo.StandardOutputEncoding = Encoding.UTF8;
Tool.cs (2)
429Console.InputEncoding = Encoding.UTF8; 430Console.OutputEncoding = Encoding.UTF8;
dotnet-user-secrets (1)
Internal\SecretsStore.cs (1)
89File.WriteAllText(_secretsFilePath, contents.ToString(), Encoding.UTF8);
Encoding.MessageVersion.IntegrationTests (7)
MessageVersionTests.4.0.0.cs (2)
30binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8), new HttpTransportBindingElement()); 66binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpTransportBindingElement());
MessageVersionTests.cs (5)
30binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressingAugust2004, Encoding.UTF8), new HttpTransportBindingElement()); 66binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11WSAddressingAugust2004, Encoding.UTF8), new HttpTransportBindingElement()); 102binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None), Encoding.UTF8), new HttpTransportBindingElement()); 138binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.WSAddressing10), Encoding.UTF8), new HttpTransportBindingElement()); 174binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.WSAddressing10), Encoding.UTF8), new TcpTransportBindingElement());
ExceptionHandlerSample (1)
StartupWithWebSocket.cs (1)
32await ws.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes("Hello")), System.Net.WebSockets.WebSocketMessageType.Text, true, context.RequestAborted);
Extensibility.MessageEncoder.IntegrationTests (2)
TextTests.4.1.0.cs (2)
29CustomBinding binding = new CustomBinding(new CustomTextMessageBindingElement(Encoding.UTF8.WebName), 72CustomBinding binding = new CustomBinding(new CustomTextMessageBindingElement(Encoding.UTF8.WebName),
FilesWebSite (3)
Controllers\DownloadFilesController.cs (3)
99var data = Encoding.UTF8.GetBytes("This is a sample text from a binary array"); 105var data = Encoding.UTF8.GetBytes("This is a sample text from a binary array"); 111var data = Encoding.UTF8.GetBytes("This is a sample text from a binary array");
FormatterWebSite (1)
StringInputFormatter.cs (1)
16SupportedEncodings.Add(Encoding.UTF8);
GenerateDocumentationAndConfigFiles (9)
Program.cs (1)
639textWriter = new StreamWriter(fileWithPath, false, Encoding.UTF8);
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
GetDocument.Insider (1)
ProgramBase.cs (1)
28Console.OutputEncoding = Encoding.UTF8;
http2cat (1)
Program.cs (1)
60h2Connection.Logger.LogInformation(Encoding.UTF8.GetString(dataFrame.Payload.ToArray()));
HttpStress (1)
Program.cs (1)
694public StringDuplexContent(string value) => _data = Encoding.UTF8.GetBytes(value);
IdeCoreBenchmarks (1)
ProjectOperationBenchmarks.cs (1)
68var emptySourceText = SourceText.From("", Encoding.UTF8);
IdentitySample.PasskeyConformance (1)
Program.cs (1)
201var resultJson = Encoding.UTF8.GetString(resultBytes);
IIS.FunctionalTests (7)
src\Servers\IIS\IIS\test\Common.FunctionalTests\Http2Tests.cs (5)
162await h2Connection.SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 190Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span)); 231await h2Connection.SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 259Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span)); 304Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span));
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestPathBaseTests.cs (1)
99return (status, Encoding.UTF8.GetString(bytes0.Span));
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestResponseTests.cs (1)
807return (status, Encoding.UTF8.GetString(bytes0.Span));
IIS.Microbenchmarks (1)
PlaintextBenchmark.cs (1)
45private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
IISExpress.FunctionalTests (7)
src\Servers\IIS\IIS\test\Common.FunctionalTests\Http2Tests.cs (5)
162await h2Connection.SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 190Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span)); 231await h2Connection.SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 259Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span)); 304Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span));
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestPathBaseTests.cs (1)
99return (status, Encoding.UTF8.GetString(bytes0.Span));
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestResponseTests.cs (1)
807return (status, Encoding.UTF8.GetString(bytes0.Span));
illink (2)
Infrastructure.Common (2)
SafeKeychainHandle.cs (2)
51byte[] utf8Passphrase = Encoding.UTF8.GetBytes(passphrase); 78byte[] utf8Passphrase = Encoding.UTF8.GetBytes(passphrase);
InMemory.FunctionalTests (47)
Http2\Http2StreamTests.cs (19)
193await SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 215Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span)); 244await SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 266Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span)); 2180_serviceContext.ServerOptions.ResponseHeaderEncodingSelector = _ => Encoding.UTF8; 2181_serviceContext.ServerOptions.RequestHeaderEncodingSelector = _ => Encoding.UTF8; // Used for decoding response. 2506_serviceContext.ServerOptions.ResponseHeaderEncodingSelector = _ => Encoding.UTF8; 2507_serviceContext.ServerOptions.RequestHeaderEncodingSelector = _ => Encoding.UTF8; // Used for decoding response. 4964Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5088Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5156var length = Encoding.UTF8.GetBytes("Hello World", buffer.Span); 5206Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5280Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5357Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5428Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5506Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5595Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5682Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span)); 5774Assert.Equal("Hello World", Encoding.UTF8.GetString(bodyFrame.Payload.Span));
Http3\Http3StreamTests.cs (22)
811Assert.Equal("hello,", Encoding.UTF8.GetString(response.Span)); 814Assert.Equal(" world", Encoding.UTF8.GetString(secondResponse.Span)); 891_serviceContext.ServerOptions.ResponseHeaderEncodingSelector = _ => Encoding.UTF8; 892_serviceContext.ServerOptions.RequestHeaderEncodingSelector = _ => Encoding.UTF8; // Used for decoding response. 1040_serviceContext.ServerOptions.ResponseHeaderEncodingSelector = _ => Encoding.UTF8; 1041_serviceContext.ServerOptions.RequestHeaderEncodingSelector = _ => Encoding.UTF8; // Used for decoding response. 1316Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1419Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1485var length = Encoding.UTF8.GetBytes("Hello World", buffer.Span); 1515Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1570Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1628Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1686Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1744Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1808Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1869Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1937Assert.Equal("Hello World", Encoding.UTF8.GetString(data.Span)); 1961await requestStream.SendDataAsync(Encoding.UTF8.GetBytes("This is invalid.")); 1989await requestStream.SendDataAsync(Encoding.UTF8.GetBytes("Hello world")); 2023await requestStream.SendDataAsync(Encoding.UTF8.GetBytes("Hello world")); 2025await requestStream.SendDataAsync(Encoding.UTF8.GetBytes("This is invalid.")); 2073await requestStream.SendDataAsync(Encoding.UTF8.GetBytes("Hello world"));
HttpsConnectionMiddlewareTests.cs (3)
1102var request = Encoding.UTF8.GetBytes($"POST / HTTP/1.1\r\nHost: localhost\r\nContent-Length: {expectedBody.Length}\r\n\r\n{expectedBody}"); 1522var request = body == null ? Encoding.UTF8.GetBytes("GET / HTTP/1.0\r\n\r\n") 1523: Encoding.UTF8.GetBytes($"POST / HTTP/1.0\r\nContent-Length: {body.Length}\r\n\r\n{body}");
KestrelMetricsTests.cs (1)
286await c.Response.BodyWriter.WriteAsync(Encoding.UTF8.GetBytes("Hello world"));
ResponseHeaderTests.cs (2)
50testContext.ServerOptions.ResponseHeaderEncodingSelector = _ => Encoding.UTF8; 63using var connection = server.CreateConnection(Encoding.UTF8);
InProcessWebSite (8)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Program.cs (1)
82Console.OutputEncoding = Encoding.UTF8;
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (6)
635await ctx.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); 648await ctx.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); 741await ctx.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); 743await ctx.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); 778await ctx.Response.WriteAsync(Encoding.UTF8.GetString(buffer)); 963await fileStream.WriteAsync(Encoding.UTF8.GetBytes(fileContent), 0, fileContent.Length);
src\Servers\IIS\IIS\test\testassets\shared\WebSockets\HandshakeHelpers.cs (1)
30byte[] mergedBytes = Encoding.UTF8.GetBytes(merged);
Interop.FunctionalTests (10)
Http2WebSocketInteropTests.cs (4)
68Assert.Equal("Hello", Encoding.UTF8.GetString(bytes, 0, result.Count)); 70await ws.SendAsync(Encoding.UTF8.GetBytes("Hi there"), WebSocketMessageType.Text, endOfMessage: true, default); 86await wsClient.SendAsync(Encoding.UTF8.GetBytes("Hello"), WebSocketMessageType.Text, endOfMessage: true, default); 92Assert.Equal("Hi there", Encoding.UTF8.GetString(bytes, 0, result.Count));
Http3\Http3RequestTests.cs (1)
71private static readonly byte[] TestData = Encoding.UTF8.GetBytes("Hello world");
HttpClientHttp2InteropTests.cs (3)
354var result = Encoding.UTF8.GetString(readResult.Buffer.FirstSpan); 485var bytes = Encoding.UTF8.GetBytes(text); 1734Assert.Equal("Hello World", Encoding.UTF8.GetString(responseBuffer));
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
88int maxAlloc = checked(Encoding.UTF8.GetMaxByteCount(myString.Length) + 1); 90length = Encoding.UTF8.GetBytes(myString, buffer);
IOperationGenerator (2)
IOperationClassWriter.cs (2)
107using (_writer = new StreamWriter(File.Open(outFileName, FileMode.Create), Encoding.UTF8)) 161using (_writer = new StreamWriter(File.Open(Path.Combine(_location, "OperationKind.Generated.cs"), FileMode.Create), Encoding.UTF8))
LargeResponseApp (1)
Startup.cs (1)
19private static readonly byte[] _chunk = Encoding.UTF8.GetBytes(new string('a', _chunkSize));
Metrics (9)
Program.cs (1)
235metricFile = new XmlTextWriter(outputFile, Encoding.UTF8);
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Metrics.Legacy (9)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Tools\Metrics\Program.cs (1)
235metricFile = new XmlTextWriter(outputFile, Encoding.UTF8);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.Arcade.Common (2)
Helpers.cs (1)
26var dirHash = Convert.ToBase64String(hasher.ComputeHash(Encoding.UTF8.GetBytes(normalizedPath)));
ZipArchiveManager.cs (1)
45=> AddContentToArchive(archivePath, targetFilename, new MemoryStream(Encoding.UTF8.GetBytes(content)));
Microsoft.Arcade.Test.Common (1)
MockFileSystem.cs (1)
105: base(fileSystem.FileExists(path) ? System.Text.Encoding.UTF8.GetBytes(fileSystem.Files[path]) : new byte[2048])
Microsoft.AspNetCore.Antiforgery (3)
Internal\AntiforgeryOptionsSetup.cs (1)
34byte[] fullHash = SHA256.HashData(Encoding.UTF8.GetBytes(applicationId));
Internal\AntiforgerySerializationContext.cs (2)
53_reader = new BinaryReader(Stream, Encoding.UTF8, leaveOpen: true); 71_writer = new BinaryWriter(Stream, Encoding.UTF8, leaveOpen: true);
Microsoft.AspNetCore.App.Analyzers.Test (1)
Verifiers\CSharpSourceGeneratorVerifier.cs (1)
26(typeof(TSourceGenerator), generatedFileName, SourceText.From(generatedSource, Encoding.UTF8))
Microsoft.AspNetCore.Authentication.MicrosoftAccount (1)
MicrosoftAccountHandler.cs (1)
88var challengeBytes = SHA256.HashData(Encoding.UTF8.GetBytes(codeVerifier));
Microsoft.AspNetCore.Authentication.Negotiate (2)
Internal\LdapAdapter.cs (2)
68var groupDN = $"{Encoding.UTF8.GetString((byte[])group)}"; 126var nestedGroupDN = $"{Encoding.UTF8.GetString((byte[])member)}";
Microsoft.AspNetCore.Authentication.OAuth (1)
OAuthHandler.cs (1)
322var challengeBytes = SHA256.HashData(Encoding.UTF8.GetBytes(codeVerifier));
Microsoft.AspNetCore.Authentication.OpenIdConnect (5)
OpenIdConnectHandler.cs (3)
288var buffer = Encoding.UTF8.GetBytes(content); 420var challengeBytes = SHA256.HashData(Encoding.UTF8.GetBytes(codeVerifier)); 535var buffer = Encoding.UTF8.GetBytes(content);
OpenIdConnectPostConfigureOptions.cs (2)
114return Encoding.UTF8.GetString(data); 119return Encoding.UTF8.GetBytes(model);
Microsoft.AspNetCore.Authentication.Test (29)
CookieTests.cs (1)
1899var xmlBytes = Encoding.UTF8.GetBytes(xml.ToString());
FacebookTests.cs (3)
337res.Content = new StringContent(graphResponse, Encoding.UTF8); 346res.Content = new StringContent(graphResponse, Encoding.UTF8); 482res.Content = new StringContent(text, Encoding.UTF8, "application/json");
GoogleTests.cs (1)
1126res.Content = new StringContent(text, Encoding.UTF8, "application/json");
JwtBearerTests.cs (5)
50var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 87var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 919var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 964var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 1276var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128)));
JwtBearerTests_Handler.cs (5)
42var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 78var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 864var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 908var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); 1343var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128)));
MicrosoftAccountTests.cs (1)
429res.Content = new StringContent(text, Encoding.UTF8, "application/json");
OAuthTests.cs (1)
537res.Content = new StringContent(text, Encoding.UTF8, "application/json");
OpenIdConnect\TestSettings.cs (1)
339var content = new StringContent(body, Encoding.UTF8, "application/json");
SecureDataFormatTests.cs (2)
69return Encoding.UTF8.GetBytes(model); 74return Encoding.UTF8.GetString(data);
TestExtensions.cs (2)
60var xmlBytes = Encoding.UTF8.GetBytes(xml.ToString()); 77var xmlBytes = Encoding.UTF8.GetBytes(xml.ToString());
TwitterTests.cs (4)
486res.Content = new StringContent(graphResponse, Encoding.UTF8); 600Encoding.UTF8, 615Encoding.UTF8, 630Encoding.UTF8,
WsFederation\CustomStateDataFormat.cs (1)
49var stateDataAsBytes = Encoding.UTF8.GetBytes(state);
WsFederation\WsFederationTest.cs (1)
453var newResponse = new HttpResponseMessage() { Content = new StringContent(metadata, Encoding.UTF8, "text/xml") };
WsFederation\WsFederationTest_Handler.cs (1)
449var newResponse = new HttpResponseMessage() { Content = new StringContent(metadata, Encoding.UTF8, "text/xml") };
Microsoft.AspNetCore.Components (5)
PersistentState\PersistentServicesRegistry.cs (1)
221var input = Encoding.UTF8.GetBytes(inputString);
PersistentStateValueProvider.cs (2)
166wroteKey = Encoding.UTF8.TryGetBytes(keySpan, currentBuffer, out var written); 267SHA256.HashData(Encoding.UTF8.GetBytes(string.Join(".", parts.parentComponentType, parts.componentType, parts.propertyName)));
Routing\RouteContext.cs (2)
29if (Encoding.UTF8.TryGetBytes(path.AsSpan(), utf8Span, out var written)) 34path = Encoding.UTF8.GetString(utf8Span);
Microsoft.AspNetCore.Components.Endpoints (11)
Builder\ResourceCollectionUrlEndpoint.cs (3)
133if (Encoding.UTF8.TryGetBytes(value, buffer, out var written)) 139var length = Encoding.UTF8.GetByteCount(value); 147var bytesWritten = Encoding.UTF8.GetBytes(value, rented);
RazorComponentEndpointInvoker.cs (1)
100await using var writer = new HttpResponseStreamWriter(context.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Rendering\Buffering\BufferedTextWriter.cs (1)
23public override Encoding Encoding => Encoding.UTF8;
Rendering\EndpointHtmlRenderer.EventDispatch.cs (2)
94await using var writer = new HttpResponseStreamWriter(_httpContext.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 131await using var writer = new HttpResponseStreamWriter(_httpContext.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Rendering\EndpointHtmlRenderer.Streaming.cs (1)
101var initializersBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(_options.JavaScriptInitializers));
Rendering\TypeNameHash.cs (2)
23if (!Encoding.UTF8.TryGetBytes(typeName, typeNameBytes, out var written)) 25typeNameBytes = Encoding.UTF8.GetBytes(typeName);
Results\RazorComponentResultExecutor.cs (1)
65await using var writer = new HttpResponseStreamWriter(httpContext.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Microsoft.AspNetCore.Components.Endpoints.Tests (8)
Binding\FormDataMapperTests.cs (6)
2011var expected = new FormFileCollection { new FormFile(new MemoryStream(Encoding.UTF8.GetBytes(expectedString)), 0, expectedString.Length, "file", "file.txt") }; 2031Assert.Equal(expectedString, Encoding.UTF8.GetString(buffer, 0, buffer.Length)); 2042new FormFile(new MemoryStream(Encoding.UTF8.GetBytes(expectedString1)), 0, expectedString1.Length, "file", "file1.txt"), 2043new FormFile(new MemoryStream(Encoding.UTF8.GetBytes(expectedString2)), 0, expectedString2.Length, "file", "file2.txt") 2066Assert.Equal(expectedString1, Encoding.UTF8.GetString(buffer1, 0, buffer1.Length)); 2073Assert.Equal(expectedString1, Encoding.UTF8.GetString(buffer2, 0, buffer2.Length));
Builder\TestFileProvider\TestFileInfo.cs (2)
28Length = Encoding.UTF8.GetByteCount(Content); 39var bytes = Encoding.UTF8.GetBytes(Content);
Microsoft.AspNetCore.Components.Server (5)
Circuits\CircuitPersistenceManager.cs (2)
69var rootComponents = Encoding.UTF8.GetString(state.RootComponents); 80var rootComponentsBytes = Encoding.UTF8.GetBytes(rootComponents);
Circuits\ServerComponentDeserializer.cs (1)
248unprotected = Encoding.UTF8.GetString(unprotectedBytes);
src\Components\Shared\src\RenderBatchWriter.cs (1)
44_binaryWriter = new BinaryWriter(output, Encoding.UTF8, leaveOpen);
src\SignalR\common\Protocols.MessagePack\src\Protocol\MessagePackHubProtocolWorker.cs (1)
658return binder.GetTarget(span) ?? Encoding.UTF8.GetString(span);
Microsoft.AspNetCore.Components.Server.Tests (11)
Circuits\RenderBatchWriterTest.cs (1)
300var value = Encoding.UTF8.GetString(bytes, tableEntryPos + numLEB128Bytes, length);
ElementReferenceJsonConverterTest.cs (5)
35var json = Encoding.UTF8.GetString(memoryStream.ToArray()); 45var bytes = Encoding.UTF8.GetBytes(json); 65var bytes = Encoding.UTF8.GetBytes(json); 81var bytes = Encoding.UTF8.GetBytes(json); 100var bytes = Encoding.UTF8.GetBytes(json);
ProtectedBrowserStorageTest.cs (5)
208var storedString = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes("This string is not even protected")); 328var plaintextString = Encoding.UTF8.GetString(plaintext); 330return Encoding.UTF8.GetBytes(fakeProtectedString); 336var protectedString = Encoding.UTF8.GetString(protectedData); 345return Encoding.UTF8.GetBytes(unprotectedString);
Microsoft.AspNetCore.Components.Web.Tests (1)
HtmlRendering\HtmlRendererTest.cs (1)
856var actual = Encoding.UTF8.GetString(ms.ToArray());
Microsoft.AspNetCore.Components.WebAssembly.Server (5)
TargetPickerUi.cs (5)
54var bytes = Encoding.UTF8.GetBytes(msg); 55var bytesWithHeader = Encoding.UTF8.GetBytes($"{bytes.Length}:").Concat(bytes).ToArray(); 74$"after reading {bytesRead} bytes. Instead got: {Encoding.UTF8.GetString(_lengthBuffer)}"); 80string str = Encoding.UTF8.GetString(_lengthBuffer, 0, bytesRead - 1); 95var messageReceived = Encoding.UTF8.GetString(buffer, 0, messageLen);
Microsoft.AspNetCore.Components.WebView (2)
src\Components\Shared\src\RenderBatchWriter.cs (1)
44_binaryWriter = new BinaryWriter(output, Encoding.UTF8, leaveOpen);
StaticContentProvider.cs (1)
45content = new MemoryStream(Encoding.UTF8.GetBytes($"There is no content at {relativePath}"));
Microsoft.AspNetCore.Components.WebView.Maui (1)
src\BlazorWebView\src\SharedSource\StaticContentHotReloadManager.cs (1)
41 { (ApplicationAssemblyName, "_framework/static-content-hot-reload.js"), ("text/javascript", Encoding.UTF8.GetBytes(NotifyCssUpdatedScript)) }
Microsoft.AspNetCore.Components.WebView.Test (1)
StaticContentProviderTests.cs (1)
127return new MemoryStream(Encoding.UTF8.GetBytes(_fileContents));
Microsoft.AspNetCore.Components.WebView.WindowsForms (1)
src\BlazorWebView\src\SharedSource\StaticContentHotReloadManager.cs (1)
41 { (ApplicationAssemblyName, "_framework/static-content-hot-reload.js"), ("text/javascript", Encoding.UTF8.GetBytes(NotifyCssUpdatedScript)) }
Microsoft.AspNetCore.Components.WebView.Wpf (1)
src\BlazorWebView\src\SharedSource\StaticContentHotReloadManager.cs (1)
41 { (ApplicationAssemblyName, "_framework/static-content-hot-reload.js"), ("text/javascript", Encoding.UTF8.GetBytes(NotifyCssUpdatedScript)) }
Microsoft.AspNetCore.Cryptography.Internal.Tests (2)
Cng\CachedAlgorithmHandlesTests.cs (2)
18private static readonly byte[] _dataToHash = Encoding.UTF8.GetBytes("Sample input data."); 19private static readonly byte[] _hmacKey = Encoding.UTF8.GetBytes("Secret key material.");
Microsoft.AspNetCore.Cryptography.KeyDerivation (5)
PBKDF2\ManagedPbkdf2Provider.cs (1)
71byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
PBKDF2\Win7Pbkdf2Provider.cs (2)
30int cbPasswordBuffer = Encoding.UTF8.GetMaxByteCount(password.Length); 52cbPasswordBufferUsed = Encoding.UTF8.GetBytes(pszPassword, password.Length, pbPasswordBuffer, cbPasswordBuffer);
PBKDF2\Win8Pbkdf2Provider.cs (2)
64int cbPasswordBuffer = Encoding.UTF8.GetMaxByteCount(password.Length); 86cbPasswordBufferUsed = Encoding.UTF8.GetBytes(pszPassword, password.Length, pbPasswordBuffer, cbPasswordBuffer);
Microsoft.AspNetCore.Cryptography.KeyDerivation.Tests (3)
Pbkdf2Tests.cs (3)
53byte[] salt = Encoding.UTF8.GetBytes("salt"); 69var salt = Encoding.UTF8.GetBytes("abcdefghijkl"); 183byte[] salt = Encoding.UTF8.GetBytes("salt");
Microsoft.AspNetCore.DataProtection (1)
Cng\DpapiSecretSerializerHelper.cs (1)
24private static readonly byte[] _purpose = Encoding.UTF8.GetBytes("DPAPI-Protected Secret");
Microsoft.AspNetCore.DataProtection.Extensions.Tests (3)
DataProtectionAdvancedExtensionsTests.cs (3)
20var plaintextAsBytes = Encoding.UTF8.GetBytes("this is plaintext"); 36var plaintextAsBytes = Encoding.UTF8.GetBytes("this is plaintext"); 86mockDataProtector.Setup(o => o.Unprotect(new byte[] { 0x01, 0x02 }, out controlExpiration)).Returns(Encoding.UTF8.GetBytes("this is plaintext"));
Microsoft.AspNetCore.DataProtection.Tests (57)
AuthenticatedEncryption\ConfigurationModel\AuthenticatedEncryptorDescriptorDeserializerTests.cs (1)
17var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
AuthenticatedEncryption\ConfigurationModel\AuthenticatedEncryptorDescriptorTests.cs (2)
146var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]")); 169var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
AuthenticatedEncryption\ConfigurationModel\CngCbcAuthenticatedEncryptorDescriptorDeserializerTests.cs (1)
20var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
AuthenticatedEncryption\ConfigurationModel\CngCbcAuthenticatedEncryptorDescriptorTests.cs (2)
14var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]")); 44var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
AuthenticatedEncryption\ConfigurationModel\CngGcmAuthenticatedEncryptorDescriptorDeserializerTests.cs (1)
21var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
AuthenticatedEncryption\ConfigurationModel\CngGcmAuthenticatedEncryptorDescriptorTests.cs (2)
14var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]")); 41var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
AuthenticatedEncryption\ConfigurationModel\ManagedAuthenticatedEncryptorDescriptorDeserializerTests.cs (4)
22var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]")); 56var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]")); 90var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]")); 113var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
AuthenticatedEncryption\ConfigurationModel\ManagedAuthenticatedEncryptorDescriptorTests.cs (2)
15var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]")); 47var masterKey = Convert.ToBase64String(Encoding.UTF8.GetBytes("[PLACEHOLDER]"));
Cng\CbcAuthenticatedEncryptorTests.cs (6)
24ArraySegment<byte> plaintext = new ArraySegment<byte>(Encoding.UTF8.GetBytes("plaintext")); 25ArraySegment<byte> aad = new ArraySegment<byte>(Encoding.UTF8.GetBytes("aad")); 45ArraySegment<byte> plaintext = new ArraySegment<byte>(Encoding.UTF8.GetBytes("plaintext")); 46ArraySegment<byte> aad = new ArraySegment<byte>(Encoding.UTF8.GetBytes("aad")); 78encryptor.Decrypt(new ArraySegment<byte>(validCiphertext), new ArraySegment<byte>(Encoding.UTF8.GetBytes("different aad"))); 87Secret kdk = new Secret(Encoding.UTF8.GetBytes("master key"));
Cng\GcmAuthenticatedEncryptorTests.cs (6)
21ArraySegment<byte> plaintext = new ArraySegment<byte>(Encoding.UTF8.GetBytes("plaintext")); 22ArraySegment<byte> aad = new ArraySegment<byte>(Encoding.UTF8.GetBytes("aad")); 39ArraySegment<byte> plaintext = new ArraySegment<byte>(Encoding.UTF8.GetBytes("plaintext")); 40ArraySegment<byte> aad = new ArraySegment<byte>(Encoding.UTF8.GetBytes("aad")); 72encryptor.Decrypt(new ArraySegment<byte>(validCiphertext), new ArraySegment<byte>(Encoding.UTF8.GetBytes("different aad"))); 81Secret kdk = new Secret(Encoding.UTF8.GetBytes("master key"));
EphemeralDataProtectionProviderTests.cs (3)
18byte[] bytes = Encoding.UTF8.GetBytes("Hello there!"); 36byte[] bytes = Encoding.UTF8.GetBytes("Hello there!"); 53byte[] bytes = Encoding.UTF8.GetBytes("Hello there!");
Managed\ManagedAuthenticatedEncryptorTests.cs (6)
20ArraySegment<byte> plaintext = new ArraySegment<byte>(Encoding.UTF8.GetBytes("plaintext")); 21ArraySegment<byte> aad = new ArraySegment<byte>(Encoding.UTF8.GetBytes("aad")); 40ArraySegment<byte> plaintext = new ArraySegment<byte>(Encoding.UTF8.GetBytes("plaintext")); 41ArraySegment<byte> aad = new ArraySegment<byte>(Encoding.UTF8.GetBytes("aad")); 73encryptor.Decrypt(new ArraySegment<byte>(validCiphertext), new ArraySegment<byte>(Encoding.UTF8.GetBytes("different aad"))); 81Secret kdk = new Secret(Encoding.UTF8.GetBytes("master key"));
SP800_108\SP800_108Tests.cs (21)
24byte[] kdk = Encoding.UTF8.GetBytes("kdk"); 25byte[] label = Encoding.UTF8.GetBytes("label"); 26byte[] contextHeader = Encoding.UTF8.GetBytes("contextHeader"); 27byte[] context = Encoding.UTF8.GetBytes("context"); 43byte[] kdk = Encoding.UTF8.GetBytes("kdk"); 44byte[] label = Encoding.UTF8.GetBytes("label"); 45byte[] contextHeader = Encoding.UTF8.GetBytes("contextHeader"); 46byte[] context = Encoding.UTF8.GetBytes("context"); 62byte[] kdk = Encoding.UTF8.GetBytes("kdk"); 63byte[] label = Encoding.UTF8.GetBytes("label"); 64byte[] contextHeader = Encoding.UTF8.GetBytes("contextHeader"); 65byte[] context = Encoding.UTF8.GetBytes("context"); 86byte[] label = Encoding.UTF8.GetBytes("label"); 87byte[] contextHeader = Encoding.UTF8.GetBytes("contextHeader"); 88byte[] context = Encoding.UTF8.GetBytes("context"); 110byte[] label = Encoding.UTF8.GetBytes("label"); 111byte[] contextHeader = Encoding.UTF8.GetBytes("contextHeader"); 112byte[] context = Encoding.UTF8.GetBytes("context"); 134byte[] label = Encoding.UTF8.GetBytes("label"); 135byte[] contextHeader = Encoding.UTF8.GetBytes("contextHeader"); 136byte[] context = Encoding.UTF8.GetBytes("context");
Microsoft.AspNetCore.Diagnostics (1)
src\Shared\Diagnostics\BaseView.cs (1)
66Output = new StreamWriter(Response.Body, Encoding.UTF8, 4096, leaveOpen: true);
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
src\Shared\Diagnostics\BaseView.cs (1)
66Output = new StreamWriter(Response.Body, Encoding.UTF8, 4096, leaveOpen: true);
Microsoft.AspNetCore.Diagnostics.HealthChecks (3)
HealthCheckResponseWriters.cs (3)
12private static readonly byte[] DegradedBytes = Encoding.UTF8.GetBytes(HealthStatus.Degraded.ToString()); 13private static readonly byte[] HealthyBytes = Encoding.UTF8.GetBytes(HealthStatus.Healthy.ToString()); 14private static readonly byte[] UnhealthyBytes = Encoding.UTF8.GetBytes(HealthStatus.Unhealthy.ToString());
Microsoft.AspNetCore.Diagnostics.Tests (1)
ExceptionDetailsProviderTest.cs (1)
311using (var writer = new StreamWriter(_stream, Encoding.UTF8, 1024, leaveOpen: true))
Microsoft.AspNetCore.Grpc.JsonTranscoding (6)
Internal\JsonRequestHelpers.cs (3)
58if (encoding == null || encoding.CodePage == Encoding.UTF8.CodePage) 63var stream = Encoding.CreateTranscodingStream(innerStream, encoding, Encoding.UTF8, leaveOpen: true); 73return Encoding.UTF8;
Internal\JsonTranscodingServerCallContext.cs (2)
32public Encoding RequestEncoding { get; private set; } = Encoding.UTF8; 52RequestEncoding = JsonRequestHelpers.GetEncodingFromCharset(charset) ?? Encoding.UTF8;
src\Grpc\JsonTranscoding\src\Shared\AuthContextHelpers.cs (1)
67values.Add(AuthProperty.Create(name, Encoding.UTF8.GetBytes(value)));
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (20)
ConverterTests\JsonConverterWriteTests.cs (1)
191BytesValue = ByteString.CopyFrom(Encoding.UTF8.GetBytes("Hello world")),
ServerStreamingServerCallHandlerTests.cs (3)
217Data = ByteString.CopyFrom(Encoding.UTF8.GetBytes($"<message>Hello {r.Name} 1</message>")) 223Data = ByteString.CopyFrom(Encoding.UTF8.GetBytes($"<message>Hello {r.Name} 2</message>")) 297return Encoding.UTF8.GetString(line);
TestObjects\Services\HttpBodyService.cs (1)
19Data = ByteString.CopyFrom(Encoding.UTF8.GetBytes(@"<message>Hello world</message>"))
UnaryServerCallHandlerTests.cs (15)
202httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonFormatter.Default.Format(new HelloRequest 240httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonFormatter.Default.Format(new HelloRequest.Types.SubMessage 290httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 340httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 390httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 440httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 490httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 740httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(json)); 778httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(json)); 1142httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestContent)); 1149Assert.Equal(requestContent, Encoding.UTF8.GetString(requestData!)); 1264httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestJson)); 1325httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestContent)); 1338Assert.Equal(requestContent, Encoding.UTF8.GetString(request!.Sub.Data.ToByteArray())); 1724httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestJson));
Microsoft.AspNetCore.Http (1)
Features\FormFeature.cs (1)
340return Encoding.UTF8;
Microsoft.AspNetCore.Http.Abstractions (2)
Extensions\HttpResponseWritingExtensions.cs (2)
31return response.WriteAsync(text, Encoding.UTF8, cancellationToken); 92if (encoding == Encoding.UTF8)
Microsoft.AspNetCore.Http.Abstractions.Tests (9)
HttpResponseWritingExtensionsTests.cs (1)
81{ Encoding.UTF8 }
HttpValidationProblemDetailsJsonConverterTest.cs (2)
59var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json)); 102var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json));
ProblemDetailsJsonConverterTest.cs (6)
25var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json)); 42var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json)); 137var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json)); 185var actual = Encoding.UTF8.GetString(stream.ToArray()); 209var actual = Encoding.UTF8.GetString(stream.ToArray()); 240var actual = Encoding.UTF8.GetString(stream.ToArray());
Microsoft.AspNetCore.Http.Connections.Tests (57)
HttpConnectionDispatcherTests.cs (36)
70var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 95var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 122var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 159var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 187var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 215var bytes = Encoding.UTF8.GetBytes("EXTRADATA Hi"); 245Assert.Equal("Hi", Encoding.UTF8.GetString(result.Buffer.ToArray())); 274var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 322Assert.Equal("No Connection with that ID", Encoding.UTF8.GetString(strm.ToArray())); 363Assert.Equal("No Connection with that ID", Encoding.UTF8.GetString(strm.ToArray())); 401Assert.Equal("POST requests are not allowed for WebSocket connections.", Encoding.UTF8.GetString(strm.ToArray())); 585var bytes = Encoding.UTF8.GetBytes("Hello World"); 613Assert.Equal("Hello World", Encoding.UTF8.GetString(result.Buffer.ToArray())); 649var bytes = Encoding.UTF8.GetBytes("Hello World"); 796var buffer = Encoding.UTF8.GetBytes("Hello World"); 871Assert.Equal("Connection ID required", Encoding.UTF8.GetString(strm.ToArray())); 945Assert.Equal("Connection ID required", Encoding.UTF8.GetString(strm.ToArray())); 1655var buffer = Encoding.UTF8.GetBytes("Hello World"); 1690var buffer = Encoding.UTF8.GetBytes("Hello World"); 1731var buffer = Encoding.UTF8.GetBytes("Hello World"); 1775await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello, World")); 1863await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Unblock")).AsTask().DefaultTimeout(); 1915await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Unblock")).AsTask().DefaultTimeout(); 2045Assert.Equal("Cannot terminate this connection using the DELETE endpoint.", Encoding.UTF8.GetString(ms.ToArray())); 2223await c.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Message1")).DefaultTimeout(); 2226await c.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Message2")).DefaultTimeout(); 2242Assert.Equal("Message1", Encoding.UTF8.GetString(ms.ToArray())); 2252Assert.Equal("Message2", Encoding.UTF8.GetString(ms.ToArray())); 2276var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 2302var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 2331var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 2360var negotiateResponse = JsonConvert.DeserializeObject<JObject>(Encoding.UTF8.GetString(ms.ToArray())); 2575var buffer = Encoding.UTF8.GetBytes("Hello, world"); 2635var buffer = Encoding.UTF8.GetBytes("Hello, world"); 2692var buffer = Encoding.UTF8.GetBytes("Hello, world"); 3723Assert.Equal($"{transportType} transport not supported by this end point type", Encoding.UTF8.GetString(strm.ToArray()));
LongPollingTests.cs (6)
75await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello World")); 81Assert.Equal("Hello World", Encoding.UTF8.GetString(ms.ToArray())); 98await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello")); 99await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes(" ")); 100await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("World")); 109Assert.Equal("Hello World", Encoding.UTF8.GetString(payload));
NegotiateProtocolTests.cs (5)
31var responseData = Encoding.UTF8.GetBytes(json); 60var responseData = Encoding.UTF8.GetBytes(payload); 80var responseData = Encoding.UTF8.GetBytes(payload); 94string json = Encoding.UTF8.GetString(writer.ToArray()); 113string json = Encoding.UTF8.GetString(writer.ToArray());
ServerSentEventsMessageFormatterTests.cs (4)
20var buffer = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(payload)); 25Assert.Equal(encoded, Encoding.UTF8.GetString(output.ToArray())); 32var buffer = ReadOnlySequenceFactory.SegmentPerByteFactory.CreateWithContent(Encoding.UTF8.GetBytes(payload)); 37Assert.Equal(encoded, Encoding.UTF8.GetString(output.ToArray()));
ServerSentEventsTests.cs (2)
124await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes(message)); 130Assert.Equal(expected, Encoding.UTF8.GetString(ms.ToArray()));
WebSocketsTests.cs (4)
48buffer: new ArraySegment<byte>(Encoding.UTF8.GetBytes("Hello")), 56Assert.Equal("Hello", Encoding.UTF8.GetString(buffer.ToArray())); 95await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello")); 106Assert.Equal("Hello", Encoding.UTF8.GetString(clientSummary.Received[0].Buffer));
Microsoft.AspNetCore.Http.Extensions (5)
HttpRequestJsonExtensions.cs (3)
317if (encoding == null || encoding.CodePage == Encoding.UTF8.CodePage) 322var inputStream = Encoding.CreateTranscodingStream(httpContext.Request.Body, encoding, Encoding.UTF8, leaveOpen: true); 332return Encoding.UTF8;
SessionExtensions.cs (2)
54session.Set(key, Encoding.UTF8.GetBytes(value)); 69return Encoding.UTF8.GetString(data);
Microsoft.AspNetCore.Http.Extensions.Tests (64)
HttpRequestJsonExtensionsTests.cs (7)
70context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("1")); 85context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 106context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2]")); 173context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("1")); 217context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 238context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 260context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]"));
HttpResponseJsonExtensionsTests.cs (9)
53var data = Encoding.UTF8.GetString(body.ToArray()); 73var data = Encoding.UTF8.GetString(body.ToArray()); 157var data = Encoding.UTF8.GetString(body.ToArray()); 194var data = Encoding.UTF8.GetString(body.ToArray()); 238var data = Encoding.UTF8.GetString(body.ToArray()); 274Assert.Equal("[1,2]", Encoding.UTF8.GetString(body.ToArray())); 299Assert.Equal("[1,2]", Encoding.UTF8.GetString(body.ToArray())); 462var data = Encoding.UTF8.GetString(body.ToArray()); 483var data = Encoding.UTF8.GetString(body.ToArray());
ProblemDetailsServiceTest.cs (3)
33Assert.Equal("\"SecondWriter\"", Encoding.UTF8.GetString(stream.ToArray())); 60Assert.Equal("\"SecondWriter\"", Encoding.UTF8.GetString(stream.ToArray())); 110Assert.Equal(string.Empty, Encoding.UTF8.GetString(stream.ToArray()));
RequestDelegateFactoryTests.cs (12)
1483var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 1591var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 1790var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 1820var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 1850var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 1877var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 1917var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 2181var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 2227var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 2295var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 2390var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 2427var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray());
RequestDelegateGenerator\CompileTimeCreationTests.cs (10)
56project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 57project = project.AddDocument("OtherTestMapActions.cs", SourceText.From(otherSource, Encoding.UTF8)).Project; 82project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 83project = project.AddDocument("OtherTestMapActions.cs", SourceText.From(otherSource, Encoding.UTF8)).Project; 165project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8), filePath: Path.Combine(currentDirectory, "TestMapActions.cs")).Project; 232project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 286project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 333project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 669project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 726project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
137var encoding = text.Encoding ?? Encoding.UTF8; 306var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
RequestDelegateGenerator\RequestDelegateCreationTests.Filters.cs (1)
225var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream");
RequestDelegateGenerator\RequestDelegateCreationTests.Forms.cs (16)
25var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 60var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 95var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 133var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 169var fileContent1 = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 170var fileContent2 = new StringContent("there", Encoding.UTF8, "application/octet-stream"); 212var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 249var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 285var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 358var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 392var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 441var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 481var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 818var fileContent = new StringContent("hello", Encoding.UTF8, "application/octet-stream"); 964httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(new string('x', 2049))); 1001httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(new string('x', 2049)));
RequestDelegateGenerator\RequestDelegateCreationTests.Logging.cs (2)
599httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{")); 639httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{"));
RequestDelegateGenerator\RequestDelegateCreationTests.QueryParameters.cs (1)
78var decodedResponseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray());
ValidationEndpointConventionBuilderExtensionsTests.cs (1)
59Assert.Equal("Validation disabled here.", Encoding.UTF8.GetString(ms.ToArray()));
Microsoft.AspNetCore.Http.Microbenchmarks (3)
RequestDelegateGeneratorBenchmarks.cs (1)
32project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
137var encoding = text.Encoding ?? Encoding.UTF8; 306var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
Microsoft.AspNetCore.Http.Results (1)
HttpResultsHelper.cs (1)
20private static readonly Encoding DefaultEncoding = Encoding.UTF8;
Microsoft.AspNetCore.Http.Results.Tests (31)
AcceptedAtRouteOfTResultTests.cs (1)
59var response = Encoding.UTF8.GetString(stream.ToArray());
AcceptedOfTResultTests.cs (1)
28var response = Encoding.UTF8.GetString(stream.ToArray());
BadRequestOfTResultTests.cs (1)
81Assert.Equal("\"Hello\"", Encoding.UTF8.GetString(stream.ToArray()));
ConflictOfTResultTests.cs (1)
80Assert.Equal("\"Hello\"", Encoding.UTF8.GetString(stream.ToArray()));
CreatedOfTResultTests.cs (1)
93var response = Encoding.UTF8.GetString(stream.ToArray());
InternalServerErrorOfTResultTests.cs (1)
81Assert.Equal("\"Hello\"", Encoding.UTF8.GetString(stream.ToArray()));
JsonResultTests.cs (2)
72Assert.Equal("\"Hello\"", Encoding.UTF8.GetString(stream.ToArray())); 109Assert.Equal(JsonSerializer.Serialize(value, options: jsonOptions), Encoding.UTF8.GetString(stream.ToArray()));
OkOfTResultTests.cs (1)
62Assert.Equal("\"Hello\"", Encoding.UTF8.GetString(stream.ToArray()));
PushStreamResultTests.cs (4)
15var result = new PushStreamHttpResult(body => body.WriteAsync(Encoding.UTF8.GetBytes("Hello World").AsMemory()).AsTask(), contentType: null); 26Assert.Equal("Hello World", Encoding.UTF8.GetString(ms.ToArray())); 37var callback = (Stream body) => body.WriteAsync(Encoding.UTF8.GetBytes("Hello World").AsMemory()).AsTask(); 55var callback = (Stream body) => body.WriteAsync(Encoding.UTF8.GetBytes("Hello World").AsMemory()).AsTask();
ResultsTests.cs (2)
541var encoding = Encoding.UTF8; 558var encoding = Encoding.UTF8;
ServerSentEventsResultTests.cs (11)
51var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 72var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 89var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 118var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 153var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 170var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 198var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 215var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 244var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 299var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray()); 318var responseBody = Encoding.UTF8.GetString(((MemoryStream)httpContext.Response.Body).ToArray());
src\Shared\ResultsTests\FileStreamResultTestBase.cs (1)
425var readStream = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!"));
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (1)
443var sourceStream = new MemoryStream(Encoding.UTF8.GetBytes(expectedData));
TypedResultsTests.cs (2)
537var encoding = Encoding.UTF8; 554var encoding = Encoding.UTF8;
UnprocessableEntityOfTResultTests.cs (1)
79Assert.Equal("\"Hello\"", Encoding.UTF8.GetString(stream.ToArray()));
Microsoft.AspNetCore.Http.Tests (26)
Features\FormFeatureTests.cs (26)
38var formContent = Encoding.UTF8.GetBytes("foo=bar&baz=2"); 51var formContent = Encoding.UTF8.GetBytes("foo=bar&baz=2"); 86var formContent = Encoding.UTF8.GetBytes("foo=bar&baz=2"); 201var formContent = Encoding.UTF8.GetBytes(EmptyMultipartForm); 236var formContent = Encoding.UTF8.GetBytes(MultipartFormWithField); 273var formContent = Encoding.UTF8.GetBytes(MultipartFormWithFile); 321var formContent = Encoding.UTF8.GetBytes(MultipartFormWithSpecialCharacters); 358var formContent = Encoding.UTF8.GetBytes(MultipartFormWithEncodedFilename); 406var formContent = Encoding.UTF8.GetBytes(MultipartFormWithFieldAndFile); 454formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFileNonFormOrFileContentDispositionValue)); 455formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFileNonFormOrFileContentDispositionValue)); 456formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFileNonFormOrFileContentDispositionValue)); 457formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormEnd)); 478formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormField)); 479formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormField)); 480formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormField)); 481formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormEnd)); 502formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFile)); 503formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFile)); 504formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFile)); 505formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormEnd)); 526formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormField)); 527formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFile)); 528formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormFileNonFormOrFileContentDispositionValue)); 529formContent.AddRange(Encoding.UTF8.GetBytes(MultipartFormEnd)); 598var formContent = Encoding.UTF8.GetBytes(MultipartFormWithInvalidContentDispositionValue);
Microsoft.AspNetCore.HttpLogging (7)
MediaTypeHelpers.cs (1)
15Encoding.UTF8,
MediaTypeOptions.cs (6)
25options.AddText("application/json", Encoding.UTF8); 26options.AddText("application/*+json", Encoding.UTF8); 27options.AddText("application/xml", Encoding.UTF8); 28options.AddText("application/*+xml", Encoding.UTF8); 29options.AddText("text/*", Encoding.UTF8); 38mediaType.Encoding ??= Encoding.UTF8;
Microsoft.AspNetCore.HttpLogging.Tests (11)
HttpLoggingMiddlewareTests.cs (11)
299httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Hello World")); 330httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 358httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 386httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 422httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 458httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 483httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 509httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 548httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 588httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 1964httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("test"));
Microsoft.AspNetCore.Identity (7)
DefaultPasskeyHandler.cs (1)
533var originalRpIdHash = SHA256.HashData(Encoding.UTF8.GetBytes(originalRpId ?? string.Empty));
IdentityApiEndpointRouteBuilderExtensions.cs (4)
154code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); 215code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); 242var code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(resetRequest.ResetCode)); 400code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Passkeys\BufferSource.cs (2)
40var buffer = Encoding.UTF8.GetBytes(value); 124return Encoding.UTF8.GetString(span);
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (1)
src\Identity\test\Shared\MockHelpers.cs (1)
75return Convert.ToBase64String(Encoding.UTF8.GetBytes(i)).ToUpperInvariant();
Microsoft.AspNetCore.Identity.InMemory.Test (2)
FunctionalTest.cs (1)
420using (var writer = XmlWriter.Create(memory, new XmlWriterSettings { Encoding = Encoding.UTF8 }))
src\Identity\test\Shared\MockHelpers.cs (1)
75return Convert.ToBase64String(Encoding.UTF8.GetBytes(i)).ToUpperInvariant();
Microsoft.AspNetCore.Identity.Test (7)
Passkeys\DefaultPasskeyHandlerAssertionTest.cs (3)
462credentialJson["response"]!["userHandle"] = Base64Url.EncodeToString(Encoding.UTF8.GetBytes(newUserId)); 1239RpIdHash = SHA256.HashData(Encoding.UTF8.GetBytes(RpId ?? string.Empty)), 1251var clientDataJsonBytes = Encoding.UTF8.GetBytes(clientDataJson?.ToString() ?? string.Empty);
Passkeys\DefaultPasskeyHandlerAttestationTest.cs (2)
910test.AttestationObject.Transform(bytes => Encoding.UTF8.GetBytes("Not a CBOR map")); 1241RpIdHash = SHA256.HashData(Encoding.UTF8.GetBytes(RpId ?? string.Empty)),
Passkeys\JsonHelpers.cs (1)
20=> value is null ? "null" : $"\"{Base64Url.EncodeToString(Encoding.UTF8.GetBytes(value))}\"";
src\Identity\test\Shared\MockHelpers.cs (1)
75return Convert.ToBase64String(Encoding.UTF8.GetBytes(i)).ToUpperInvariant();
Microsoft.AspNetCore.Identity.UI (20)
Areas\Identity\Pages\V4\Account\ConfirmEmail.cshtml.cs (1)
56code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
Areas\Identity\Pages\V4\Account\ConfirmEmailChange.cshtml.cs (1)
58code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
Areas\Identity\Pages\V4\Account\ExternalLogin.cshtml.cs (1)
201code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V4\Account\ForgotPassword.cshtml.cs (1)
76code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V4\Account\Manage\Email.cshtml.cs (2)
141code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); 174code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V4\Account\Register.cshtml.cs (1)
141code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V4\Account\RegisterConfirmation.cshtml.cs (1)
77code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V4\Account\ResendEmailConfirmation.cshtml.cs (1)
88code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V4\Account\ResetPassword.cshtml.cs (1)
100Code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code))
Areas\Identity\Pages\V5\Account\ConfirmEmail.cshtml.cs (1)
56code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
Areas\Identity\Pages\V5\Account\ConfirmEmailChange.cshtml.cs (1)
58code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
Areas\Identity\Pages\V5\Account\ExternalLogin.cshtml.cs (1)
201code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V5\Account\ForgotPassword.cshtml.cs (1)
76code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V5\Account\Manage\Email.cshtml.cs (2)
141code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); 174code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V5\Account\Register.cshtml.cs (1)
141code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V5\Account\RegisterConfirmation.cshtml.cs (1)
77code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V5\Account\ResendEmailConfirmation.cshtml.cs (1)
88code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
Areas\Identity\Pages\V5\Account\ResetPassword.cshtml.cs (1)
100Code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code))
Microsoft.AspNetCore.Mvc.Core (16)
Formatters\StringOutputFormatter.cs (1)
20SupportedEncodings.Add(Encoding.UTF8);
Formatters\SystemTextJsonInputFormatter.cs (2)
128if (encoding.CodePage == Encoding.UTF8.CodePage) 133var inputStream = Encoding.CreateTranscodingStream(httpContext.Request.Body, encoding, Encoding.UTF8, leaveOpen: true);
Formatters\SystemTextJsonOutputFormatter.cs (3)
28SupportedEncodings.Add(Encoding.UTF8); 86if (selectedEncoding.CodePage == Encoding.UTF8.CodePage) 107var transcodingStream = Encoding.CreateTranscodingStream(httpContext.Response.Body, selectedEncoding, Encoding.UTF8, leaveOpen: true);
Formatters\TextOutputFormatter.cs (2)
44cache.Add(mediaType, MediaType.ReplaceEncoding(mediaType, Encoding.UTF8)); 183if (string.Equals(encoding.WebName, Encoding.UTF8.WebName, StringComparison.OrdinalIgnoreCase) &&
Infrastructure\ContentResultExecutor.cs (1)
44(DefaultContentType, Encoding.UTF8),
Infrastructure\IHttpRequestStreamReaderFactory.cs (1)
19/// <param name="encoding">The <see cref="Encoding"/>, usually <see cref="Encoding.UTF8"/>.</param>
Infrastructure\IHttpResponseStreamWriterFactory.cs (1)
19/// <param name="encoding">The <see cref="Encoding"/>, usually <see cref="Encoding.UTF8"/>.</param>
Infrastructure\SystemTextJsonResultExecutor.cs (4)
20Encoding = Encoding.UTF8 46(DefaultContentType, Encoding.UTF8), 64if (resolvedContentTypeEncoding.CodePage == Encoding.UTF8.CodePage) 77var transcodingStream = Encoding.CreateTranscodingStream(response.Body, resolvedContentTypeEncoding, Encoding.UTF8, leaveOpen: true);
src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (1)
353return Encoding.UTF8;
Microsoft.AspNetCore.Mvc.Core.Test (74)
ControllerBaseTest.cs (2)
2217var actualContentResult = controller.Content("TestContent", "text/plain", Encoding.UTF8); 2222Assert.Same(Encoding.UTF8, MediaType.GetEncoding(actualContentResult.ContentType));
Formatters\JsonInputFormatterTestBase.cs (22)
38var contentBytes = Encoding.UTF8.GetBytes("content"); 70var contentBytes = Encoding.UTF8.GetBytes(content); 91var contentBytes = Encoding.UTF8.GetBytes(content); 136var contentBytes = Encoding.UTF8.GetBytes(content); 164var contentBytes = Encoding.UTF8.GetBytes(content); 191var contentBytes = Encoding.UTF8.GetBytes(content); 218var contentBytes = Encoding.UTF8.GetBytes(content); 239var contentBytes = Encoding.UTF8.GetBytes(content); 261var contentBytes = Encoding.UTF8.GetBytes(content); 293var contentBytes = Encoding.UTF8.GetBytes(content); 314var contentBytes = Encoding.UTF8.GetBytes(content); 341var contentBytes = Encoding.UTF8.GetBytes(content); 367var contentBytes = Encoding.UTF8.GetBytes(content); 393var contentBytes = Encoding.UTF8.GetBytes(content); 420var contentBytes = Encoding.UTF8.GetBytes(content); 450var contentBytes = Encoding.UTF8.GetBytes(content); 474var contentBytes = Encoding.UTF8.GetBytes(content); 500var contentBytes = Encoding.UTF8.GetBytes(content); 524var contentBytes = Encoding.UTF8.GetBytes(content); 544var contentBytes = Encoding.UTF8.GetBytes(content); 567var contentBytes = Encoding.UTF8.GetBytes(content); 591var contentBytes = Encoding.UTF8.GetBytes(content);
Formatters\JsonOutputFormatterTestBase.cs (2)
150await Record.ExceptionAsync(() => jsonFormatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.UTF8)); 158var content = new StreamReader(body, Encoding.UTF8).ReadToEnd();
Formatters\ResponseContentTypeHelperTest.cs (3)
111(defaultContentType, Encoding.UTF8), 131(defaultContentType, Encoding.UTF8), 138Assert.Equal(Encoding.UTF8, resolvedContentTypeEncoding);
Formatters\StringOutputFormatterTests.cs (1)
132Encoding encoding = Encoding.UTF8;
Formatters\SystemTextJsonInputFormatterTest.cs (5)
71var contentBytes = Encoding.UTF8.GetBytes(content); 95var contentBytes = Encoding.UTF8.GetBytes("{\"dateValue\":\"not-a-date\"}"); 116var contentBytes = Encoding.UTF8.GetBytes("{\"shortValue\":\"32768\"}"); 144var contentBytes = Encoding.UTF8.GetBytes(content); 166var contentBytes = Encoding.UTF8.GetBytes("{");
Formatters\TextInputFormatterTest.cs (6)
91formatter.SupportedEncodings.Add(Encoding.UTF8); 106Assert.Equal(Encoding.UTF8, result); 117formatter.SupportedEncodings.Add(Encoding.UTF8); 132Assert.Equal(Encoding.UTF8, result); 184formatter.SupportedEncodings.Add(Encoding.UTF8); 200Assert.Equal(Encoding.UTF8, result);
Formatters\TextOutputFormatterTests.cs (2)
111formatter.SupportedEncodings.Add(Encoding.UTF8); 142formatter.SupportedEncodings.Add(Encoding.UTF8);
Infrastructure\DefaultOutputFormatterSelectorTest.cs (3)
399SupportedEncodings.Add(Encoding.UTF8); 415SupportedEncodings.Add(Encoding.UTF8); 430SupportedEncodings.Add(Encoding.UTF8);
Infrastructure\JsonResultExecutorTestBase.cs (9)
26var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 46var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 111var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 135var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 161var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 182var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize( 313var expected = Encoding.UTF8.GetBytes("null"); 342Assert.Equal(expected, Encoding.UTF8.GetString(written)); 349var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new[] { 1, 2 }));
Infrastructure\ObjectResultExecutorTest.cs (3)
506SupportedEncodings.Add(Encoding.UTF8); 526SupportedEncodings.Add(Encoding.UTF8); 541SupportedEncodings.Add(Encoding.UTF8);
Infrastructure\ValidationProblemDetailsJsonConverterTest.cs (4)
26var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json)); 68var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json)); 152var json = Encoding.UTF8.GetString(stream.ToArray()); 185var json = Encoding.UTF8.GetString(stream.ToArray());
ModelBinding\Binders\BodyModelBinderTests.cs (9)
253httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 301httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 330httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 372httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 401httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 448httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data!")); 483httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data!")); 512httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data")); 730SupportedEncodings.Add(Encoding.UTF8);
ModelBinding\Validation\DefaultObjectValidatorTests.cs (1)
1200var model = new MemoryStream(Encoding.UTF8.GetBytes("Hello!"));
src\Shared\ResultsTests\FileStreamResultTestBase.cs (1)
425var readStream = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!"));
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (1)
443var sourceStream = new MemoryStream(Encoding.UTF8.GetBytes(expectedData));
Microsoft.AspNetCore.Mvc.Formatters.Xml (2)
XmlDataContractSerializerOutputFormatter.cs (1)
68SupportedEncodings.Add(Encoding.UTF8);
XmlSerializerOutputFormatter.cs (1)
67SupportedEncodings.Add(Encoding.UTF8);
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (54)
ProblemDetailsWrapperTest.cs (2)
29new MemoryStream(Encoding.UTF8.GetBytes(xml))); 90var res = new StreamReader(outputStream, Encoding.UTF8).ReadToEnd();
SerializableErrorWrapperTests.cs (2)
67new MemoryStream(Encoding.UTF8.GetBytes(serializableErrorXml))); 120var res = new StreamReader(outputStream, Encoding.UTF8).ReadToEnd();
ValidationProblemDetailsWrapperTest.cs (5)
33new MemoryStream(Encoding.UTF8.GetBytes(xml))); 89new MemoryStream(Encoding.UTF8.GetBytes(xml))); 127new MemoryStream(Encoding.UTF8.GetBytes(xml))); 179var res = new StreamReader(outputStream, Encoding.UTF8).ReadToEnd(); 217var res = new StreamReader(outputStream, Encoding.UTF8).ReadToEnd();
XmlDataContractSerializerInputFormatterTest.cs (23)
71var contentBytes = Encoding.UTF8.GetBytes("content"); 98var contentBytes = Encoding.UTF8.GetBytes(input); 146var contentBytes = Encoding.UTF8.GetBytes(input); 178var contentBytes = Encoding.UTF8.GetBytes(input); 210var contentBytes = Encoding.UTF8.GetBytes(input); 244var contentBytes = Encoding.UTF8.GetBytes(input); 277var contentBytes = Encoding.UTF8.GetBytes(input); 308var contentBytes = Encoding.UTF8.GetBytes(input); 336var contentBytes = Encoding.UTF8.GetBytes(input); 374var contentBytes = Encoding.UTF8.GetBytes(input); 400var contentBytes = Encoding.UTF8.GetBytes(input); 422var contentBytes = Encoding.UTF8.GetBytes(input); 438var contentBytes = Encoding.UTF8.GetBytes(input); 462var contentBytes = Encoding.UTF8.GetBytes(input); 505var inputBytes = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + 533var sampleStringBytes = Encoding.UTF8.GetBytes(sampleString); 534var inputStart = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Environment.NewLine + 537var inputEnd = Encoding.UTF8.GetBytes("</SampleString></TestLevelTwo>"); 557Assert.Equal(expectedBytes, Encoding.UTF8.GetBytes(model.SampleString)); 611var contentBytes = Encoding.UTF8.GetBytes(input); 643var contentBytes = Encoding.UTF8.GetBytes(input); 670var contentBytes = Encoding.UTF8.GetBytes(input); 702var contentBytes = Encoding.UTF8.GetBytes(input);
XmlDataContractSerializerOutputFormatterTest.cs (1)
778Assert.Contains("<int>1</int><int>2</int>", Encoding.UTF8.GetString(body.ToArray()));
XmlSerializerInputFormatterTest.cs (20)
51var contentBytes = Encoding.UTF8.GetBytes(input); 88var contentBytes = Encoding.UTF8.GetBytes(input); 124var contentBytes = Encoding.UTF8.GetBytes(input); 160var contentBytes = Encoding.UTF8.GetBytes(input); 202var contentBytes = Encoding.UTF8.GetBytes(input); 249var contentBytes = Encoding.UTF8.GetBytes("content"); 277var contentBytes = Encoding.UTF8.GetBytes("content"); 295var contentBytes = Encoding.UTF8.GetBytes(input); 344var contentBytes = Encoding.UTF8.GetBytes(input); 378var contentBytes = Encoding.UTF8.GetBytes(input); 407var contentBytes = Encoding.UTF8.GetBytes(input); 434var contentBytes = Encoding.UTF8.GetBytes(input); 455var contentBytes = Encoding.UTF8.GetBytes(input); 479var contentBytes = Encoding.UTF8.GetBytes(input); 526var inputBytes = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + 553var sampleStringBytes = Encoding.UTF8.GetBytes(sampleString); 554var inputStart = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Environment.NewLine + 557var inputEnd = Encoding.UTF8.GetBytes("</SampleString></TestLevelTwo>"); 577Assert.Equal(expectedBytes, Encoding.UTF8.GetBytes(model.SampleString)); 633var contentBytes = Encoding.UTF8.GetBytes(input);
XmlSerializerOutputFormatterTest.cs (1)
560Assert.Contains("<int>1</int><int>2</int>", Encoding.UTF8.GetString(body.ToArray()));
Microsoft.AspNetCore.Mvc.FunctionalTests (48)
ApiBehaviorTest.cs (1)
105Content = new StringContent("some content", Encoding.UTF8, "text/css"),
ConsumesAttributeTestsBase.cs (5)
102request.Content = new StringContent(input, Encoding.UTF8, requestContentType); 123request.Content = new StringContent(input, Encoding.UTF8, requestContentType); 147request.Content = new StringContent(input, Encoding.UTF8, "application/xml"); 168request.Content = new StringContent(input, Encoding.UTF8, "application/vnd.example+json"); 191request.Content = new StringContent(input, Encoding.UTF8, "application/vnd.example+xml");
ContentNegotiationTest.cs (1)
403var content = new StringContent("1234", Encoding.UTF8, "application/custom");
DoNotRespectBrowserAcceptHeaderTests.cs (2)
100request.Content = new StringContent(requestData, Encoding.UTF8, "application/xml"); 131request.Content = new StringContent(requestData, Encoding.UTF8, "application/xml");
FiltersTest.cs (1)
89Content = new StringContent("Test", Encoding.UTF8, "application/json"),
HtmlGenerationTest.cs (1)
618requestMessage.Content = new StringContent(content, Encoding.UTF8, "application/json");
Infrastructure\ResourceFile.cs (1)
102var bytes = Encoding.UTF8.GetBytes(text);
InputFormatterTests.cs (2)
45var content = new StringContent(input, Encoding.UTF8, "application/xml"); 78var content = new StringContent("Test Content", Encoding.UTF8, contentType);
InputObjectValidationTests.cs (12)
75var content = new StringContent(input, Encoding.UTF8, "application/xml"); 97var content = new StringContent(input, Encoding.UTF8, "application/json"); 118var content = new StringContent("{\"Alias\":\"xyz\"}", Encoding.UTF8, "application/json"); 134var content = new StringContent(requestData, Encoding.UTF8, "application/json"); 164var content = new StringContent(requestContent, Encoding.UTF8, "application/json"); 204var content = new StringContent(invalidRequestData, Encoding.UTF8, "application/json"); 225var content = new StringContent(invalidRequestData, Encoding.UTF8, "application/json"); 245var content = new StringContent(invalidRequestData, Encoding.UTF8, "application/json"); 270Content = new StringContent(@"{ ""Id"": ""S-1-5-21-1004336348-1177238915-682003330-512"" }", Encoding.UTF8, "application/json"), 291Content = new StringContent(input, Encoding.UTF8, "application/json"), 320Content = new StringContent(input, Encoding.UTF8, "application/json"), 352Content = new StringContent(input, Encoding.UTF8, "application/xml"),
InputParentValidationTests.cs (1)
88return new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
JsonInputFormatterTestBase.cs (6)
47var content = new StringContent(input, Encoding.UTF8, requestContentType); 66var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType); 84var content = new StringContent(input, Encoding.UTF8, "application/json"); 100var content = new StringContent(expected, Encoding.UTF8, "application/json"); 203var content = new StringContent(jsonInput, Encoding.UTF8, "application/json"); 222var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType);
JsonOutputFormatterTestBase.cs (1)
53request.Content = new StringContent(input, Encoding.UTF8, "application/xml");
JsonPatchInputFormatterTest.cs (1)
167Content = new StringContent(body, Encoding.UTF8, "application/json-patch+json"),
NewtonsoftJsonInputFormatterTest.cs (3)
16var content = new StringContent("{", Encoding.UTF8, "application/json"); 35var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType); 52var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType);
RequestSizeLimitTest.cs (1)
83request.Content = new StringContent(expected, Encoding.UTF8, "text/json");
RoutingFallbackTest.cs (1)
138Content = new StringContent("some plaintext", Encoding.UTF8, "text/plain"),
SerializableErrorTests.cs (3)
74Content = new StringContent(expectedXml, Encoding.UTF8, acceptHeader) 122request.Content = new StringContent(inputXml, Encoding.UTF8, acceptHeader); 163request.Content = new StringContent(inputXml, Encoding.UTF8, acceptHeader);
XmlDataContractSerializerInputFormatterTest.cs (3)
40var content = new StringContent(input, Encoding.UTF8, "application/xml-dcs"); 59request.Content = new StringContent(input, Encoding.UTF8, "application/xml-dcs"); 87request.Content = new StringContent(input, Encoding.UTF8, "application/xml-dcs");
XmlSerializerInputFormatterTests.cs (2)
41var content = new StringContent(input, Encoding.UTF8, "application/xml-xmlser"); 58var content = new StringContent(input, Encoding.UTF8, "application/xml-xmlser");
Microsoft.AspNetCore.Mvc.IntegrationTests (41)
BindingSourceMetadataProviderIntegrationTest.cs (1)
138var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(data));
BodyValidationIntegrationTests.cs (19)
36request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 77request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 111request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 161request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 202request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 242request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 278request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 323request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 371request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 413request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 447request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 527request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ \"Number\": 5 }")); 554request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ \"Number\": \"not a number\" }")); 620request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 665request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 717request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText)); 776request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText)); 821request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText)); 867request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText));
ComplexRecordIntegrationTest.cs (1)
4229var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(content));
ComplexTypeIntegrationTestBase.cs (1)
3728var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(content));
FormCollectionModelBindingIntegrationTest.cs (1)
161var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(data));
FormFileModelBindingIntegrationTest.cs (1)
1273var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(data));
JQueryFormatModelBindingIntegrationTest.cs (1)
68request.Body = new MemoryStream(Encoding.UTF8.GetBytes(
SimpleTypeModelBinderIntegrationTest.cs (1)
294request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input));
TryUpdateModelIntegrationTest.cs (1)
1284var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(data));
ValidationIntegrationTests.cs (7)
98request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 15,\"amount\": 250.0}")); 140request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 40,\"amount\": 250.0}")); 1737request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 1791request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1881request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1928request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello There\" }")); 1986request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(input)));
ValidationWithRecordIntegrationTests.cs (7)
90request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 15,\"amount\": 250.0}")); 132request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 40,\"amount\": 250.0}")); 1540request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 1594request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1684request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1731request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello There\" }")); 1781request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(input)));
Microsoft.AspNetCore.Mvc.NewtonsoftJson (3)
NewtonsoftJsonOutputFormatter.cs (1)
69SupportedEncodings.Add(Encoding.UTF8);
NewtonsoftJsonResultExecutor.cs (2)
24Encoding = Encoding.UTF8 80(DefaultContentType, Encoding.UTF8),
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (75)
JsonResultTest.cs (1)
24var expected = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value));
NewtonsoftJsonInputFormatterTest.cs (14)
38var contentBytes = Encoding.UTF8.GetBytes(content); 74var contentBytes = Encoding.UTF8.GetBytes(content); 110var contentBytes = Encoding.UTF8.GetBytes(content); 160var contentBytes = Encoding.UTF8.GetBytes("{ \"UserName\" : \"John\"}"); 237var contentBytes = Encoding.UTF8.GetBytes(content); 262var contentBytes = Encoding.UTF8.GetBytes(content); 292var contentBytes = Encoding.UTF8.GetBytes("{"); 325var contentBytes = Encoding.UTF8.GetBytes("{"); 357var contentBytes = Encoding.UTF8.GetBytes("{\"dateValue\":\"not-a-date\"}"); 388var contentBytes = Encoding.UTF8.GetBytes("{\"ShortValue\":\"32768\"}"); 419var contentBytes = Encoding.UTF8.GetBytes("{ \"Complex\": { \"WithPrimitives\": [ { \"ShortValue\":\"32768\" } ] } }"); 452var content = Encoding.UTF8.GetBytes("\"Hello world\""); 502var contentBytes = Encoding.UTF8.GetBytes(content); 545var contentBytes = Encoding.UTF8.GetBytes(content);
NewtonsoftJsonOutputFormatterTest.cs (19)
80await jsonFormatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.UTF8); 112await jsonFormatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.UTF8); 136await jsonFormatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.UTF8); 144var content = new StreamReader(body, Encoding.UTF8).ReadToEnd(); 159await jsonFormatter.WriteResponseBodyAsync(outputFormatterContext1, Encoding.UTF8); 168await jsonFormatter.WriteResponseBodyAsync(outputFormatterContext2, Encoding.UTF8); 176var content = new StreamReader(body, Encoding.UTF8).ReadToEnd(); 211await formatter.WriteResponseBodyAsync(context, Encoding.UTF8); 219var content = new StreamReader(body, Encoding.UTF8).ReadToEnd(); 263await formatter.WriteResponseBodyAsync(context, Encoding.UTF8); 271var content = new StreamReader(body, Encoding.UTF8).ReadToEnd(); 299await formatter.WriteResponseBodyAsync(context, Encoding.UTF8); 307var content = new StreamReader(body, Encoding.UTF8).ReadToEnd(); 334await formatter.WriteResponseBodyAsync(context, Encoding.UTF8); 342var content = new StreamReader(body, Encoding.UTF8).ReadToEnd(); 360await formatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.UTF8); 390await formatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.UTF8); 421await formatter.WriteResponseBodyAsync(context, Encoding.UTF8); 429var content = new StreamReader(body, Encoding.UTF8).ReadToEnd();
NewtonsoftJsonPatchInputFormatterTest.cs (7)
36var contentBytes = Encoding.UTF8.GetBytes(content); 73var contentBytes = Encoding.UTF8.GetBytes(content); 110var contentBytes = Encoding.UTF8.GetBytes(content); 134var contentBytes = Encoding.UTF8.GetBytes(content); 163var contentBytes = Encoding.UTF8.GetBytes(content); 184var contentBytes = Encoding.UTF8.GetBytes(content); 209var contentBytes = Encoding.UTF8.GetBytes(content);
NewtonsoftJsonResultExecutorTest.cs (1)
49Assert.Equal(expected, Encoding.UTF8.GetString(written));
src\Mvc\Mvc.Core\test\Formatters\JsonInputFormatterTestBase.cs (22)
38var contentBytes = Encoding.UTF8.GetBytes("content"); 70var contentBytes = Encoding.UTF8.GetBytes(content); 91var contentBytes = Encoding.UTF8.GetBytes(content); 136var contentBytes = Encoding.UTF8.GetBytes(content); 164var contentBytes = Encoding.UTF8.GetBytes(content); 191var contentBytes = Encoding.UTF8.GetBytes(content); 218var contentBytes = Encoding.UTF8.GetBytes(content); 239var contentBytes = Encoding.UTF8.GetBytes(content); 261var contentBytes = Encoding.UTF8.GetBytes(content); 293var contentBytes = Encoding.UTF8.GetBytes(content); 314var contentBytes = Encoding.UTF8.GetBytes(content); 341var contentBytes = Encoding.UTF8.GetBytes(content); 367var contentBytes = Encoding.UTF8.GetBytes(content); 393var contentBytes = Encoding.UTF8.GetBytes(content); 420var contentBytes = Encoding.UTF8.GetBytes(content); 450var contentBytes = Encoding.UTF8.GetBytes(content); 474var contentBytes = Encoding.UTF8.GetBytes(content); 500var contentBytes = Encoding.UTF8.GetBytes(content); 524var contentBytes = Encoding.UTF8.GetBytes(content); 544var contentBytes = Encoding.UTF8.GetBytes(content); 567var contentBytes = Encoding.UTF8.GetBytes(content); 591var contentBytes = Encoding.UTF8.GetBytes(content);
src\Mvc\Mvc.Core\test\Formatters\JsonOutputFormatterTestBase.cs (2)
150await Record.ExceptionAsync(() => jsonFormatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.UTF8)); 158var content = new StreamReader(body, Encoding.UTF8).ReadToEnd();
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (9)
26var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 46var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 111var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 135var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 161var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 182var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize( 313var expected = Encoding.UTF8.GetBytes("null"); 342Assert.Equal(expected, Encoding.UTF8.GetString(written)); 349var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new[] { 1, 2 }));
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (1)
RuntimeViewCompiler.cs (1)
374var sourceText = SourceText.From(compilationContent, Encoding.UTF8);
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.Test (2)
CompilerFailedExceptionFactoryTest.cs (1)
310var stream = new MemoryStream(Encoding.UTF8.GetBytes(template));
TestInfrastructure\TestRazorProjectItem.cs (1)
38var stream = new MemoryStream(Encoding.UTF8.GetBytes(Content));
Microsoft.AspNetCore.Mvc.Razor.Test (2)
RazorPageTest.cs (2)
1360var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8); 1412writer = writer ?? new ViewBufferTextWriter(buffer, Encoding.UTF8);
Microsoft.AspNetCore.Mvc.RazorPages.Test (4)
PageModelTest.cs (2)
1602var actualContentResult = pageModel.Content("TestContent", "text/plain", Encoding.UTF8); 1607Assert.Same(Encoding.UTF8, MediaType.GetEncoding(actualContentResult.ContentType));
PageTest.cs (2)
1592var actualContentResult = page.Content("TestContent", "text/plain", Encoding.UTF8); 1597Assert.Same(Encoding.UTF8, MediaType.GetEncoding(actualContentResult.ContentType));
Microsoft.AspNetCore.Mvc.TagHelpers (5)
Cache\CacheTagKey.cs (1)
180var contentBytes = Encoding.UTF8.GetBytes(key);
Cache\DistributedCacheTagHelperFormatter.cs (2)
28var serialized = Encoding.UTF8.GetBytes(context.Html.ToString()); 37var content = Encoding.UTF8.GetString(value);
Cache\DistributedCacheTagHelperService.cs (1)
83var serializedKey = Encoding.UTF8.GetBytes(key.GenerateKey());
PartialTagHelper.cs (1)
142using (var writer = new ViewBufferTextWriter(viewBuffer, Encoding.UTF8))
Microsoft.AspNetCore.Mvc.TagHelpers.Test (11)
DefaultFileVersionProviderTest.cs (2)
173var stream = new TestableMemoryStream(Encoding.UTF8.GetBytes("Hello World!")); 309.Returns(() => new MemoryStream(Encoding.UTF8.GetBytes("Hello World!")));
DistributedCacheTagHelperTest.cs (2)
35var value = Encoding.UTF8.GetBytes("ok"); 77var value = Encoding.UTF8.GetBytes(childContent);
ImageTagHelperTest.cs (1)
367.Returns(() => new MemoryStream(Encoding.UTF8.GetBytes("Hello World!")));
JavaScriptResourcesTest.cs (4)
17var stream = new MemoryStream(Encoding.UTF8.GetBytes(resource)); 34var stream = new MemoryStream(Encoding.UTF8.GetBytes(resource)); 54var stream = new MemoryStream(Encoding.UTF8.GetBytes(resource)); 79var stream = new MemoryStream(Encoding.UTF8.GetBytes(resource));
LinkTagHelperTest.cs (1)
1177.Returns(() => new MemoryStream(Encoding.UTF8.GetBytes("Hello World!")));
ScriptTagHelperTest.cs (1)
1144.Returns(() => new MemoryStream(Encoding.UTF8.GetBytes("Hello World!")));
Microsoft.AspNetCore.Mvc.Testing.Tasks (1)
GenerateMvcTestManifestTask.cs (1)
47using var writer = JsonReaderWriterFactory.CreateJsonWriter(fileStream, Encoding.UTF8, ownsStream: false, indent: true);
Microsoft.AspNetCore.Mvc.ViewFeatures (3)
HtmlHelper.cs (1)
453using (var writer = new ViewBufferTextWriter(viewBuffer, Encoding.UTF8))
ViewComponentResultExecutor.cs (1)
89(ViewExecutor.DefaultContentType, Encoding.UTF8),
ViewExecutor.cs (1)
192(DefaultContentType, Encoding.UTF8),
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (17)
Buffers\ViewBufferTextWriterTest.cs (7)
20var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8); 42var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8); 67var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8); 87var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8, new HtmlTestEncoder(), inner.Object); 110var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8); 126var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8); 147var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8);
ControllerUnitTestabilityTests.cs (4)
147Assert.Equal(content, Encoding.UTF8.GetString(fileContentResult.FileContents)); 180using (var stream = new StreamReader(fileStreamResult.FileStream, Encoding.UTF8)) 765var contentArray = Encoding.UTF8.GetBytes(content); 771var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(content));
CookieTempDataProviderTest.cs (1)
20private static readonly byte[] Bytes = Encoding.UTF8.GetBytes("test value");
SessionStateTempDataProviderTest.cs (1)
13private static readonly byte[] Bytes = Encoding.UTF8.GetBytes("test value");
ViewComponentResultTest.cs (1)
601ContentType = new MediaTypeHeaderValue("text/html") { Encoding = Encoding.UTF8 }.ToString(),
ViewExecutorTest.cs (3)
156Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray())); 247Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray())); 286Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray()));
Microsoft.AspNetCore.Mvc.Views.TestCommon (4)
TestFileInfo.cs (2)
28Length = Encoding.UTF8.GetByteCount(Content); 39var bytes = Encoding.UTF8.GetBytes(Content);
TestRazorCompiledItem.cs (2)
49var bytes = SHA1.HashData(Encoding.UTF8.GetBytes(content)); 55var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(content));
Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests (3)
SnapshotTestHelper.cs (3)
81var xmlText = Encoding.UTF8.GetString(xmlStream.ToArray()); 124var encoding = text.Encoding ?? Encoding.UTF8; 566return SourceText.From(text, Encoding.UTF8);
Microsoft.AspNetCore.OpenApi.Tests (5)
Extensions\OpenApiEndpointRouteBuilderExtensionsTests.cs (4)
101var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 132Assert.Equal("No OpenAPI document with the name 'v2' was found.", Encoding.UTF8.GetString(responseBodyStream.ToArray())); 181var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 222var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray());
Services\OpenApiDocumentServiceTestsBase.cs (1)
105SupportedEncodings.Add(Encoding.UTF8);
Microsoft.AspNetCore.OutputCaching (4)
FormatterBinaryReader.cs (1)
143var s = Encoding.UTF8.GetString(MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref _root, _offset), bytes));
FormatterBinaryWriter.cs (3)
89var bytes = Encoding.UTF8.GetByteCount(value); 93var actual = Encoding.UTF8.GetBytes(value, AvailableBuffer); 101var actual = Encoding.UTF8.GetBytes(value, target);
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (3)
RedisOutputCacheStore.cs (3)
83_valueKeyPrefix = (RedisKey)Encoding.UTF8.GetBytes(_options.InstanceName + "__MSOCV_"); 84_tagKeyPrefix = (RedisKey)Encoding.UTF8.GetBytes(_options.InstanceName + "__MSOCT_"); 85_tagMasterKey = (RedisKey)Encoding.UTF8.GetBytes(_options.InstanceName + "__MSOCT");
Microsoft.AspNetCore.OutputCaching.Tests (5)
OutputCacheMiddlewareTests.cs (3)
911Assert.Equal("Hello1", Encoding.UTF8.GetString(memoryStream1.ToArray())); 912Assert.Equal("Hello2", Encoding.UTF8.GetString(memoryStream2.ToArray())); 1054var response = Encoding.UTF8.GetString(responseStream.GetBuffer());
TestUtils.cs (2)
86Encoding.UTF8.GetBytes(uniqueId, context.Response.BodyWriter); 282var data = Encoding.UTF8.GetBytes(text);
Microsoft.AspNetCore.Owin (1)
WebSockets\WebSocketAdapter.cs (1)
109string description = Encoding.UTF8.GetString(buffer.Array, buffer.Offset + 2, buffer.Count - 2);
Microsoft.AspNetCore.Razor (1)
TagHelpers\DefaultTagHelperContent.cs (1)
309return Encoding.UTF8;
Microsoft.AspNetCore.RequestDecompression.Tests (1)
RequestDecompressionMiddlewareTests.cs (1)
28return Encoding.UTF8.GetBytes(input);
Microsoft.AspNetCore.ResponseCaching.Tests (1)
TestUtils.cs (1)
268byte[] data = Encoding.UTF8.GetBytes(text);
Microsoft.AspNetCore.Rewrite (1)
UrlActions\CustomResponseAction.cs (1)
36var content = Encoding.UTF8.GetBytes(StatusDescription);
Microsoft.AspNetCore.Routing (1)
src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (1)
353return Encoding.UTF8;
Microsoft.AspNetCore.Routing.Tests (7)
Builder\RequestDelegateEndpointRouteBuilderExtensionsTest.cs (4)
105var responseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 141var responseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 169var responseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray()); 285var responseBody = Encoding.UTF8.GetString(responseBodyStream.ToArray());
EndpointRoutingMiddlewareFormOptionsTest.cs (3)
32httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("foo=bar")); 64httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("foo=bar")); 136httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("foo=bar"));
Microsoft.AspNetCore.Server.HttpSys (4)
HttpSysOptions.cs (1)
249/// Defaults to <c>false</c>, in which case <see cref="Encoding.UTF8"/> will be used. />.
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
88int maxAlloc = checked(Encoding.UTF8.GetMaxByteCount(myString.Length) + 1); 90length = Encoding.UTF8.GetBytes(myString, buffer);
src\Shared\HttpSys\RequestProcessing\HeaderEncoding.cs (1)
20header = new ReadOnlySpan<byte>(pBytes, byteCount).GetAsciiOrUTF8String(Encoding.UTF8);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (14)
Http2Tests.cs (4)
193await h2Connection.SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 209Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span)); 257await h2Connection.SendDataAsync(1, Encoding.UTF8.GetBytes("Hello World"), endStream: true); 273Assert.Equal("Hello World", Encoding.UTF8.GetString(dataFrame.Payload.Span));
HttpsTests.cs (2)
42byte[] body = Encoding.UTF8.GetBytes("Hello World"); 59var body = Encoding.UTF8.GetBytes("Hello World");
Listener\RequestHeaderTests.cs (4)
25Task responseTask = SendRequestAsync(address, "Custom-Header", customValues, Encoding.UTF8); 66Task responseTask = SendRequestAsync(address, "Custom-Header", customValues, Encoding.UTF8); 162Task responseTask = SendRequestAsync(address, "If-None-Match", customValues, Encoding.UTF8); 187Task responseTask = SendRequestAsync(address, "Custom-Header", customValues, Encoding.UTF8);
RequestTests.cs (1)
392var statusCode = Encoding.UTF8.GetString(response).Substring(9);
ResponseBodyTests.cs (2)
408var data = Encoding.UTF8.GetBytes("hello, world"); 431Assert.Equal("hello, world", Encoding.UTF8.GetString(payload));
ResponseHeaderTests.cs (1)
128var socketsHttpHandler = new SocketsHttpHandler() { ResponseHeaderEncodingSelector = (_, _) => Encoding.UTF8 };
Microsoft.AspNetCore.Server.IIS (6)
Core\IISHttpContext.cs (3)
614var headerValueBytes = Encoding.UTF8.GetBytes(headerValue); 620var headerNameBytes = Encoding.UTF8.GetBytes(headerPair.Key); 659var headerValueBytes = Encoding.UTF8.GetBytes(headerValue);
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
88int maxAlloc = checked(Encoding.UTF8.GetMaxByteCount(myString.Length) + 1); 90length = Encoding.UTF8.GetBytes(myString, buffer);
src\Shared\HttpSys\RequestProcessing\HeaderEncoding.cs (1)
20header = new ReadOnlySpan<byte>(pBytes, byteCount).GetAsciiOrUTF8String(Encoding.UTF8);
Microsoft.AspNetCore.Server.Kestrel.Core (5)
Internal\Http\PathDecoder.cs (1)
33return Encoding.UTF8.GetString(path.Slice(0, pathLength));
Internal\Infrastructure\KestrelEventSource.cs (2)
195var applicationProtocol = feature == null ? string.Empty : Encoding.UTF8.GetString(feature.ApplicationProtocol.Span); 244var serializedConfig = Encoding.UTF8.GetString(bufferWriter.WrittenSpan);
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
88int maxAlloc = checked(Encoding.UTF8.GetMaxByteCount(myString.Length) + 1); 90length = Encoding.UTF8.GetBytes(myString, buffer);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (16)
Http1\Http1ConnectionTests.cs (5)
29var headerValue = Encoding.UTF8.GetString(headerValueBytes); 32await _application.Output.WriteAsync(Encoding.UTF8.GetBytes($"{headerName}: ")); 34await _application.Output.WriteAsync(Encoding.UTF8.GetBytes("\r\n\r\n")); 717var payload = Encoding.UTF8.GetBytes("hello, web browser" + new string(' ', 512) + "\n"); 731var payload = Encoding.UTF8.GetBytes("hello, web browser" + new string(' ', 512) + "\n");
Http2\Http2HPackEncoderTests.cs (1)
209var headers = (IHeaderDictionary)new HttpResponseHeaders(_ => Encoding.UTF8);
HttpRequestHeadersTests.cs (8)
551var prevSpan = Encoding.UTF8.GetBytes(headerValueUtf16Latin1CrossOver).AsSpan(); 672var headerValueBytes = Encoding.UTF8.GetBytes(headerValue); 682return Encoding.UTF8; 748var prevSpan = Encoding.UTF8.GetBytes(HeaderValue).AsSpan(); 796var prevSpan1 = Encoding.UTF8.GetBytes(HeaderValue1).AsSpan(); 797var prevSpan2 = Encoding.UTF8.GetBytes(HeaderValue2).AsSpan(); 850var prevSpan = Encoding.UTF8.GetBytes(prevValue).AsSpan(); 861var nextSpan = Encoding.UTF8.GetBytes(nextValue).AsSpan();
HttpResponseHeadersTests.cs (2)
190var responseHeaders = new HttpResponseHeaders(_ => Encoding.UTF8); 238var responseHeaders = new HttpResponseHeaders(_ => Encoding.UTF8);
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (5)
Http2\HPackHeaderWriterBenchmark.cs (2)
61_knownResponseHeaders.EncodingSelector = _ => Encoding.UTF8; 76_knownResponseHeaders.EncodingSelector = _ => Encoding.UTF8;
InMemoryTransportBenchmark.cs (1)
240private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
KnownStringsBenchmark.cs (1)
24static readonly byte[] _version = Encoding.UTF8.GetBytes("HTTP/1.1\r\n");
NamedPipesTransportBenchmark.cs (1)
138private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (2)
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
88int maxAlloc = checked(Encoding.UTF8.GetMaxByteCount(myString.Length) + 1); 90length = Encoding.UTF8.GetBytes(myString, buffer);
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (2)
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
88int maxAlloc = checked(Encoding.UTF8.GetMaxByteCount(myString.Length) + 1); 90length = Encoding.UTF8.GetBytes(myString, buffer);
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (4)
QuicConnectionContextTests.cs (1)
21private static readonly byte[] TestData = Encoding.UTF8.GetBytes("Hello world");
QuicConnectionListenerTests.cs (1)
25private static readonly byte[] TestData = Encoding.UTF8.GetBytes("Hello world");
QuicStreamContextTests.cs (1)
26private static readonly byte[] TestData = Encoding.UTF8.GetBytes("Hello world");
QuicTestHelpers.cs (1)
28private static readonly byte[] TestData = Encoding.UTF8.GetBytes("Hello world");
Microsoft.AspNetCore.Session (4)
CookieProtection.cs (2)
20var userData = Encoding.UTF8.GetBytes(data); 47return Encoding.UTF8.GetString(userData);
EncodedKey.cs (2)
18KeyBytes = Encoding.UTF8.GetBytes(key); 32_keyString = Encoding.UTF8.GetString(KeyBytes, 0, KeyBytes.Length);
Microsoft.AspNetCore.Shared.Tests (11)
src\Shared\HttpSys\RequestProcessing\HeaderEncoding.cs (1)
20header = new ReadOnlySpan<byte>(pBytes, byteCount).GetAsciiOrUTF8String(Encoding.UTF8);
UrlDecoderTests.cs (10)
78var source = Encoding.UTF8.GetBytes("/a%20b".ToCharArray()); 93var source = Encoding.UTF8.GetBytes("%00"); 119var source = Encoding.UTF8.GetBytes(input.ToCharArray()); 122Assert.True(source.AsSpan(0, length).SequenceEqual(Encoding.UTF8.GetBytes(input).AsSpan())); 129var source = Encoding.UTF8.GetBytes(input.ToCharArray()); 132Assert.True(source.AsSpan(0, length).SequenceEqual(Encoding.UTF8.GetBytes("/").AsSpan())); 157var source = Encoding.UTF8.GetBytes(input.ToCharArray()); 160Assert.True(source.AsSpan(0, length).SequenceEqual(Encoding.UTF8.GetBytes(input).AsSpan())); 197var input = Encoding.UTF8.GetBytes((string)x[0]); 198var expected = Encoding.UTF8.GetBytes((string)x[1]);
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (2)
HubProtocolVersionTests.cs (1)
142connectionContext.Transport.Output.Write(Encoding.UTF8.GetBytes(messageToken.ToString()));
VersionJsonHubProtocol.cs (1)
40var json = Encoding.UTF8.GetString(payload.ToArray());
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (4)
HubClientProxyGenerator.Emitter.cs (2)
123_context.AddSource("HubClientProxy.g.cs", SourceText.From(extensions.ToString(), Encoding.UTF8)); 192_context.AddSource($"HubClientProxy.{typeSpec.TypeName}.g.cs", SourceText.From(registrationMethodBody.ToString(), Encoding.UTF8));
HubServerProxyGenerator.Emitter.cs (2)
75_context.AddSource("HubServerProxy.g.cs", SourceText.From(getProxy.ToString(), Encoding.UTF8)); 163_context.AddSource($"HubServerProxy.{classSpec.ClassTypeName}.g.cs", SourceText.From(proxy.ToString(), Encoding.UTF8));
Microsoft.AspNetCore.SignalR.Client.Tests (19)
HttpConnectionTests.Transport.cs (9)
70await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello world 1")); 71await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello world 2")); 146await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello World")); 186await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello World")); 218Assert.Contains("This is a test", Encoding.UTF8.GetString(await connection.Transport.Input.ReadAllAsync())); 410Assert.Equal("This is a test", Encoding.UTF8.GetString(message.Buffer)); 412await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello world 1")); 507await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello world 1")); 550await connection.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello world 1"));
HubConnectionTests.ConnectionLifecycle.cs (1)
626await innerConnection.Application.Output.WriteAsync(Encoding.UTF8.GetBytes(new[] { '{' })).DefaultTimeout();
LongPollingTransportTests.cs (4)
145Assert.Equal(Encoding.UTF8.GetBytes("HelloWorld"), data); 305await longPollingTransport.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello World")); 501longPollingTransport.Output.Write(Encoding.UTF8.GetBytes("Hello")); 502longPollingTransport.Output.Write(Encoding.UTF8.GetBytes("World"));
SendUtilsTests.cs (1)
41await application.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello World"));
ServerSentEventsTransportTests.cs (1)
515return new(Encoding.UTF8.GetBytes(_contents[_index++], buffer.Span));
TestConnection.cs (3)
107var bytes = FormatMessageToArray(Encoding.UTF8.GetBytes(json)); 114return ReceiveBytesAsync(Encoding.UTF8.GetBytes(rawText)); 157return Encoding.UTF8.GetString(payload.ToArray());
Microsoft.AspNetCore.SignalR.Common (2)
Protocol\HandshakeProtocol.cs (1)
228return Encoding.UTF8.GetString(payload.ToArray());
src\SignalR\common\Shared\Utf8BufferTextReader.cs (1)
26_decoder = Encoding.UTF8.GetDecoder();
Microsoft.AspNetCore.SignalR.Common.Tests (63)
Internal\Formatters\BinaryMessageFormatterTests.cs (2)
32Encoding.UTF8.GetBytes("Hello,\r\nWorld!") 102var message = Encoding.UTF8.GetBytes(payload);
Internal\Formatters\BinaryMessageParserTests.cs (2)
25Assert.Equal(Encoding.UTF8.GetBytes(payload), message.ToArray()); 109Assert.Equal(Encoding.UTF8.GetBytes("Hello,\r\nWorld!"), messages[1]);
Internal\Formatters\TextMessageFormatterTests.cs (2)
19var buffer = Encoding.UTF8.GetBytes("ABC"); 22Assert.Equal("ABC\u001e", Encoding.UTF8.GetString(ms.ToArray()));
Internal\Formatters\TextMessageParserTests.cs (9)
17var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("ABC\u001e")); 20Assert.Equal("ABC", Encoding.UTF8.GetString(payload.ToArray())); 27var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("ABC")); 34var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("ABC\u001eXYZ\u001e")); 36Assert.Equal("ABC", Encoding.UTF8.GetString(payload.ToArray())); 38Assert.Equal("XYZ", Encoding.UTF8.GetString(payload.ToArray())); 44var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("ABC\u001eXYZ\u001e123")); 46Assert.Equal("ABC", Encoding.UTF8.GetString(payload.ToArray())); 48Assert.Equal("XYZ", Encoding.UTF8.GetString(payload.ToArray()));
Internal\Protocol\HandshakeProtocolTests.cs (5)
26var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(json)); 52var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(json)); 71var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("42")); 89var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(payload)); 105var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(payload));
Internal\Protocol\JsonHubProtocolTests.cs (10)
53var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 71var json = Encoding.UTF8.GetString(writer.ToArray()); 90var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 104var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 126var json = Encoding.UTF8.GetString(writer.ToArray()); 130var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(json)); 159var json = Encoding.UTF8.GetString(writer.ToArray()); 163var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(json)); 192var json = Encoding.UTF8.GetString(writer.ToArray()); 196var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(json));
Internal\Protocol\JsonHubProtocolTestsBase.cs (18)
126var json = Encoding.UTF8.GetString(writer.ToArray()); 145var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 195var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 206var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(testData)); 221var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 235var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 255var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 268var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 279var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame(input))); 294var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame(input))); 306var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame("{\"type\":1,\"invocationId\":\"42\",\"target\":\"foo\",\"arguments\":[[],{\"target\":\"foo2\"}]}"))); 319var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 350var json = Encoding.UTF8.GetString(writer.ToArray()); 441var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 473var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(message)); 489var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(message)); 500var data = Encoding.UTF8.GetBytes(input); 501return Encoding.UTF8.GetString(FormatMessageToArray(data));
Internal\Protocol\NewtonsoftJsonHubProtocolTests.cs (3)
51var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); 70var json = Encoding.UTF8.GetString(writer.ToArray()); 89var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input));
Internal\Protocol\Utf8BufferTextReaderTests.cs (5)
18var buffer = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("Hello World")); 31var buffer = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("a\u00E4\u00E4\u00a9o")); 49var buffer = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("Hello World")); 63var buffer = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("Hello World")); 95var buffer = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("\u00E4\u00E4\u00E5"));
Internal\Protocol\Utf8BufferTextWriterTests.cs (7)
105var result = Encoding.UTF8.GetString(bufferWriter.CurrentSegment.Slice(0, bufferWriter.Position).ToArray()); 142var expectedData = Encoding.UTF8.GetBytes(fourCircles); 171var expectedData = Encoding.UTF8.GetBytes(fourCircles); 233Assert.Equal("Hello", Encoding.UTF8.GetString(bufferWriter1.ToArray())); 242Assert.Equal("World", Encoding.UTF8.GetString(bufferWriter2.ToArray())); 292Assert.Equal(testString, Encoding.UTF8.GetString(bufferWriter.ToArray())); 338var result = Encoding.UTF8.GetString(data);
Microsoft.AspNetCore.SignalR.Core (3)
Internal\Utf8HashLookup.cs (3)
39var encodedValue = Encoding.UTF8.GetBytes(value); 81var count = Encoding.UTF8.GetCharCount(encodedValue); 85var encoded = Encoding.UTF8.GetChars(encodedValue, chars);
Microsoft.AspNetCore.SignalR.Microbenchmarks (16)
HandshakeProtocolBenchmark.cs (12)
30_requestMessage1 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"protocol\":\"dummy\",\"version\":1}\u001e")); 31_requestMessage2 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"protocol\":\"\",\"version\":10}\u001e")); 32_requestMessage3 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"protocol\":\"\",\"version\":10,\"unknown\":null}\u001e")); 33_requestMessage4 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("42")); 34_requestMessage5 = ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("{\"protocol\":\"dummy\",\"ver"), Encoding.UTF8.GetBytes("sion\":1}\u001e")); 36_responseMessage1 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"error\":\"dummy\"}\u001e")); 37_responseMessage2 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"error\":\"\"}\u001e")); 38_responseMessage3 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{}\u001e")); 39_responseMessage4 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"unknown\":null}\u001e")); 40_responseMessage5 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"error\":\"\",\"minorVersion\":34}\u001e")); 41_responseMessage6 = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"error\":\"flump flump flump\",\"minorVersion\":112}\u001e"));
NegotiateProtocolBenchmark.cs (4)
43_responseData1 = Encoding.UTF8.GetBytes("{\"connectionId\":\"123\",\"availableTransports\":[]}"); 44_responseData2 = Encoding.UTF8.GetBytes("{\"url\": \"http://foo.com/chat\"}"); 45_responseData3 = Encoding.UTF8.GetBytes("{\"url\": \"http://foo.com/chat\", \"accessToken\": \"token\"}"); 46_responseData4 = Encoding.UTF8.GetBytes("{\"connectionId\":\"123\",\"availableTransports\":[{\"transport\":\"test\",\"transferFormats\":[]}]}");
Microsoft.AspNetCore.SignalR.Protocols.Json (1)
src\SignalR\common\Shared\Utf8BufferTextReader.cs (1)
26_decoder = Encoding.UTF8.GetDecoder();
Microsoft.AspNetCore.SignalR.Protocols.MessagePack (1)
Protocol\MessagePackHubProtocolWorker.cs (1)
658return binder.GetTarget(span) ?? Encoding.UTF8.GetString(span);
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (2)
Protocol\NewtonsoftJsonHubProtocol.cs (1)
605writer.WriteRawValue(Encoding.UTF8.GetString(result.RawSerializedData));
src\SignalR\common\Shared\Utf8BufferTextReader.cs (1)
26_decoder = Encoding.UTF8.GetDecoder();
Microsoft.AspNetCore.SignalR.StackExchangeRedis (1)
RedisHubLifetimeManager.cs (1)
841public override Encoding Encoding => Encoding.UTF8;
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (1)
RedisProtocolTests.cs (1)
207new RedisCompletion("json", new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("{\"type\":3,\"invocationId\":\"1\",\"result\":1}"))),
Microsoft.AspNetCore.SignalR.Tests (38)
ClientProxyTests.cs (9)
33var data = Encoding.UTF8.GetBytes("Hello world"); 54var data = Encoding.UTF8.GetBytes("Hello world"); 75var data = Encoding.UTF8.GetBytes("Hello world"); 96var data = Encoding.UTF8.GetBytes("Hello world"); 117var data = Encoding.UTF8.GetBytes("Hello world"); 138var data = Encoding.UTF8.GetBytes("Hello world"); 159var data = Encoding.UTF8.GetBytes("Hello world"); 180var data = Encoding.UTF8.GetBytes("Hello world"); 201var data = Encoding.UTF8.GetBytes("Hello world");
EndToEndTests.cs (6)
102var bytes = Encoding.UTF8.GetBytes(message); 140var bytes = Encoding.UTF8.GetBytes(message); 274var bytes = Encoding.UTF8.GetBytes(message); 293Assert.Equal(message, Encoding.UTF8.GetString(await connection.Transport.Input.ReadAsync(bytes.Length).DefaultTimeout())); 331var bytes = Encoding.UTF8.GetBytes(message); 345Assert.Equal(message, Encoding.UTF8.GetString(receivedData));
HttpHeaderConnectionHandler.cs (2)
25var headerName = Encoding.UTF8.GetString(buffer.ToArray()); 28var data = Encoding.UTF8.GetBytes(string.Join(",", headerValues));
HubConnectionHandlerTests.cs (17)
339var part1 = Encoding.UTF8.GetBytes("{\"protocol\": \"json\""); 340var part2 = Encoding.UTF8.GetBytes(",\"version\": 1}"); 341var part3 = Encoding.UTF8.GetBytes("\u001e"); 382var part1 = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"1\", "); 383var part2 = Encoding.UTF8.GetBytes("\"target\": \"Echo\", \"arguments\""); 384var part3 = Encoding.UTF8.GetBytes(":[\"hello\"]}\u001e"); 423var payload = Encoding.UTF8.GetBytes("{\"protocol\": \"json\",\"version\": 1}\u001e{\"type\":1, \"invocationId\":\"1\", \"target\": \"Echo\", \"arguments\":[\"hello\"]}\u001e"); 479var payload = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"1\", \"target\": \"Echo\", \"arguments\":[\"hello\"]}\u001e"); 508var payload = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"1\", \"target\": \"Echo\", \"arguments\":[\"hello\"]}\u001e"); 538var payload1 = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"1\", \"target\": \"Echo\", \"arguments\":[\"one\"]}\u001e"); 539var payload2 = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"2\", \"target\": \"Echo\", \"arguments\":[\"two\"]}\u001e"); 540var payload3 = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"3\", \"target\": \"Echo\", \"arguments\":[\"three\"]}\u001e"); 589var payload1 = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"1\", \"target\": \"Echo\", \"arguments\":[\"one\"]}\u001e"); 590var payload2 = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"2\", \"target\": \"Echo\", \"arguments\":[\"two\"]}\u001e"); 591var payload3 = Encoding.UTF8.GetBytes("{\"type\":1, \"invocationId\":\"3\", \"target\": \"Echo\", \"arguments\":[\"three\"]}\u001e"); 668var payload = Encoding.UTF8.GetBytes("{\"protocol\": \"json\",\"ver"); 3566await client.Connection.Application.Output.WriteAsync(Encoding.UTF8.GetBytes(new[] { '{' })).DefaultTimeout();
WebSocketsTransportTests.cs (4)
112await webSocketsTransport.Output.WriteAsync(Encoding.UTF8.GetBytes("User-Agent")); 119var userAgent = Encoding.UTF8.GetString(result.Buffer.ToArray()); 143await webSocketsTransport.Output.WriteAsync(Encoding.UTF8.GetBytes(HeaderNames.XRequestedWith)); 150var headerValue = Encoding.UTF8.GetString(result.Buffer.ToArray());
Microsoft.AspNetCore.SpaProxy (1)
SpaProxyMiddleware.cs (1)
62await using var writer = new StreamWriter(context.Response.Body, Encoding.UTF8);
Microsoft.AspNetCore.StaticAssets.Tests (1)
StaticAssetsIntegrationTests.cs (1)
561var hash = SHA256.HashData(Encoding.UTF8.GetBytes(content));
Microsoft.AspNetCore.StaticFiles (1)
HtmlDirectoryFormatter.cs (1)
204byte[] bytes = Encoding.UTF8.GetBytes(data);
Microsoft.AspNetCore.TestHost.Tests (15)
ClientHandlerTests.cs (2)
129var contentBytes = Encoding.UTF8.GetBytes("This is a content!"); 191var contentBytes = Encoding.UTF8.GetBytes("This is a content!");
HttpContextBuilderTests.cs (2)
126var bytes = Encoding.UTF8.GetBytes("BodyStarted" + Environment.NewLine); 130bytes = Encoding.UTF8.GetBytes("BodyFinished");
TestClientTests.cs (11)
219Assert.Equal("STARTED", Encoding.UTF8.GetString(buffer, 0, length)); 222await requestStream.WriteAsync(Encoding.UTF8.GetBytes("Hello world")).AsTask().DefaultTimeout(); 228Assert.Equal("Hello world POST Response", Encoding.UTF8.GetString(buffer, 0, length)); 282Assert.Equal("SENT", Encoding.UTF8.GetString(serverBuffer, 0, serverLength)); 326await requestStream.WriteAsync(Encoding.UTF8.GetBytes("SENT")).AsTask().DefaultTimeout(); 379Assert.Equal("POST Response", Encoding.UTF8.GetString(buffer, 0, length)); 386await requestStream.WriteAsync(Encoding.UTF8.GetBytes(new string('!', 1024 * 1024 * 50))).AsTask().DefaultTimeout(); 544() => requestStream.WriteAsync(Encoding.UTF8.GetBytes("Hello world")).AsTask(), 616var hello = Encoding.UTF8.GetBytes("hello"); 618var world = Encoding.UTF8.GetBytes("world!"); 808var hello = Encoding.UTF8.GetBytes("hello");
Microsoft.AspNetCore.Tests (1)
WebApplicationTests.cs (1)
1263static Stream CreateStreamFromString(string data) => new MemoryStream(Encoding.UTF8.GetBytes(data));
Microsoft.AspNetCore.WebSockets (1)
HandshakeHelpers.cs (1)
61Encoding.UTF8.GetBytes(requestKey, mergedBytes);
Microsoft.AspNetCore.WebSockets.Tests (12)
SendReceiveTests.cs (4)
17var sendBuffer = Encoding.UTF8.GetBytes(message); 25Assert.Equal(message, Encoding.UTF8.GetString(receiveBuffer, 0, result.Count)); 34var sendBuffer = Encoding.UTF8.GetBytes(message); 42Assert.Equal(message, Encoding.UTF8.GetString(receiveBuffer, 0, result.Count));
WebSocketMiddlewareTests.cs (8)
89var originalData = Encoding.UTF8.GetBytes("Hello World"); 114var originalData = Encoding.UTF8.GetBytes(new string('a', 130)); 140var originalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); 170var originalData = Encoding.UTF8.GetBytes("Hello World"); 220var originalData = Encoding.UTF8.GetBytes("Hello World"); 245var originalData = Encoding.UTF8.GetBytes(new string('a', 130)); 270var originalData = Encoding.UTF8.GetBytes(new string('a', 0x1FFFF)); 303var originalData = Encoding.UTF8.GetBytes("Hello World");
Microsoft.AspNetCore.WebUtilities (9)
BufferedReadStream.cs (1)
416return Encoding.UTF8.GetString(builder.GetBuffer(), 0, (int)length);
FormPipeReader.cs (5)
44: this(pipeReader, Encoding.UTF8) 64if (_encoding != Encoding.UTF8 && _encoding != Encoding.ASCII) 392else if (_encoding == Encoding.UTF8 || _encoding == Encoding.ASCII) 424if (_encoding == Encoding.UTF8 || _encoding == Encoding.ASCII) 436if (_encoding == Encoding.UTF8 || _encoding == Encoding.ASCII)
FormReader.cs (1)
74: this(stream, Encoding.UTF8, ArrayPool<char>.Shared)
MultipartBoundary.cs (1)
18_boundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary);
MultipartSectionStreamExtensions.cs (1)
43streamEncoding = Encoding.UTF8;
Microsoft.AspNetCore.WebUtilities.Microbenchmarks (8)
FormPipeReaderInternalsBenchmark.cs (3)
15private readonly byte[] _singleUtf8 = Encoding.UTF8.GetBytes("foo=bar&baz=boo&haha=hehe&lol=temp"); 16private readonly byte[] _firstUtf8 = Encoding.UTF8.GetBytes("foo=bar&baz=bo"); 17private readonly byte[] _secondUtf8 = Encoding.UTF8.GetBytes("o&haha=hehe&lol=temp");
FormReaderBenchmark.cs (2)
16var bytes = Encoding.UTF8.GetBytes("foo=bar&baz=boo"); 31var bytes = Encoding.UTF8.GetBytes("foo=bar&baz=boo");
HttpRequestStreamReaderReadLineBenchmark.cs (2)
25_stream = new MemoryStream(Encoding.UTF8.GetBytes(data)); 50return new HttpRequestStreamReader(_stream, Encoding.UTF8);
MultipartReaderBenchmark.cs (1)
90_stream = new MemoryStream(Encoding.UTF8.GetBytes(data));
Microsoft.AspNetCore.WebUtilities.Tests (89)
FileBufferingWriteStreamTests.cs (2)
24var input = Encoding.UTF8.GetBytes("Hello world"); 139var input = Encoding.UTF8.GetBytes("Hello world");
FormPipeReaderTests.cs (29)
114Assert.Equal(Encoding.UTF8.GetBytes(content), readResult.Buffer.ToArray()); 129Assert.Equal(Encoding.UTF8.GetBytes(content), readResult.Buffer.ToArray()); 157Assert.Equal(Encoding.UTF8.GetBytes(content), readResult.Buffer.ToArray()); 185Assert.Equal(Encoding.UTF8.GetBytes(content), readResult.Buffer.ToArray()); 196await bodyPipe.Writer.WriteAsync(Encoding.UTF8.GetBytes(content1)); 202await bodyPipe.Writer.WriteAsync(Encoding.UTF8.GetBytes(content2)); 210Assert.Equal(Encoding.UTF8.GetBytes("baz=12345678901"), readResult.Buffer.ToArray()); 431var readOnlySequence = ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("foo=bar&"), Encoding.UTF8.GetBytes("baz=boo")); 448var readOnlySequence = ReadOnlySequenceFactory.SingleSegmentFactory.CreateWithContent(Encoding.UTF8.GetBytes("foo=bar&baz=boo&t=")); 462var readOnlySequence = ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("fo=bar&ba"), Encoding.UTF8.GetBytes("z=boo&t=")); 476var readOnlySequence = ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("foo=bar&baz=boo&t=")); 490var readOnlySequence = ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("foo=ba&baz=bo"), Encoding.UTF8.GetBytes("o&t=")); 504var readOnlySequence = ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("foo=ba&baz=bo"), Encoding.UTF8.GetBytes("o&asdfasdfasd=")); 518var readOnlySequence = ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("foo=ba&baz=bo"), Encoding.UTF8.GetBytes("o&t=asdfasdfasd")); 534var bytes = Encoding.UTF8.GetBytes("foo=bar&baz=boo"); 602{ ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("fo=bar&b"), Encoding.UTF8.GetBytes("a")) }, 603{ new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("fo=bar&ba")) } 609{ ReadOnlySequenceFactory.CreateSegments(Encoding.UTF8.GetBytes("fo=bar&b"), Encoding.UTF8.GetBytes("=")) }, 610{ new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes("fo=bar&b=")) } 616{ Encoding.UTF8 }, 629var formContent = Encoding.UTF8.GetBytes(text); 648return Encoding.UTF8.GetBytes(keyValue);
FormReaderTests.cs (1)
217var formContent = Encoding.UTF8.GetBytes(text);
HttpRequestStreamReaderTest.cs (16)
45var reader = new HttpRequestStreamReader(GetLargeStream(), Encoding.UTF8); 57var reader = new HttpRequestStreamReader(stream, Encoding.UTF8); 102var reader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8); 198var reader = new HttpRequestStreamReader(stream, Encoding.UTF8); 222var reader = new HttpRequestStreamReader(stream, Encoding.UTF8, 10); 241var reader = new HttpRequestStreamReader(stream, Encoding.UTF8); 259var reader = new HttpRequestStreamReader(stream, Encoding.UTF8); 359var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, size, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 370var httpRequestStreamReader = new HttpRequestStreamReader(mockStream.Object, Encoding.UTF8, 1, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 378var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 391var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 400return new HttpRequestStreamReader(stream, Encoding.UTF8); 406return new HttpRequestStreamReader(stream, Encoding.UTF8, bufferSize); 441yield return new object?[] { null, Encoding.UTF8, ArrayPool<byte>.Shared, ArrayPool<char>.Shared }; 443yield return new object?[] { new MemoryStream(), Encoding.UTF8, null, ArrayPool<char>.Shared }; 444yield return new object?[] { new MemoryStream(), Encoding.UTF8, ArrayPool<byte>.Shared, null };
HttpResponseStreamWriterTest.cs (33)
38var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 54var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 73var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 94var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 111var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 130var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 149var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 168var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 189var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 214var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 238var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 260var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 293var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 317var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 341var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 364var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 383using var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 419var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 439var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 479var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 501var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 523var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 547var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 586var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 608var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); 686var encoding = Encoding.UTF8; 747var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, size, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 758var httpRequestStreamReader = new HttpRequestStreamReader(mockStream.Object, Encoding.UTF8, 1, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 766var httpResponseStreamWriter = new HttpResponseStreamWriter(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 779var httpResponseStreamWriter = new HttpResponseStreamWriter(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 848yield return new object?[] { null, Encoding.UTF8, ArrayPool<byte>.Shared, ArrayPool<char>.Shared }; 850yield return new object?[] { new MemoryStream(), Encoding.UTF8, null, ArrayPool<char>.Shared }; 851yield return new object?[] { new MemoryStream(), Encoding.UTF8, ArrayPool<byte>.Shared, null };
MultipartReaderTests.cs (5)
98return new MemoryStream(Encoding.UTF8.GetBytes(text)); 398var bytes = Encoding.UTF8.GetBytes(body1); 404bytes = Encoding.UTF8.GetBytes(body2); 433var bytes = Encoding.UTF8.GetBytes(body1); 439bytes = Encoding.UTF8.GetBytes(body2);
PagedByteBufferTest.cs (3)
16var input = Encoding.UTF8.GetBytes("Hello world"); 32var input1 = Encoding.UTF8.GetBytes("Hello"); 33var input2 = Encoding.UTF8.GetBytes("world");
Microsoft.Build.Framework (5)
EncodingUtilities.cs (4)
118return SimilarToEncoding(encoding, Encoding.UTF8); 128return StartsWithPreamble(stream, Encoding.UTF8.GetPreamble()); 277Console.OutputEncoding = Encoding.UTF8; 279Console.InputEncoding = Encoding.UTF8;
Telemetry\ActivityExtensions.cs (1)
78byte[] bytes = Encoding.UTF8.GetBytes(text);
Microsoft.Build.Tasks.CodeAnalysis (3)
src\Compilers\Core\MSBuildTask\ManagedCompiler.cs (1)
474return (Utf8Output) ? Encoding.UTF8 : base.StandardOutputEncoding;
src\Compilers\Shared\BuildServerConnection.cs (1)
575var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(pipeNameInput));
src\Compilers\Shared\CompilerServerLogger.cs (1)
157byte[] bytes = Encoding.UTF8.GetBytes(output);
Microsoft.Build.Tasks.CodeAnalysis.Sdk (3)
src\Compilers\Core\MSBuildTask\ManagedCompiler.cs (1)
474return (Utf8Output) ? Encoding.UTF8 : base.StandardOutputEncoding;
src\Compilers\Shared\BuildServerConnection.cs (1)
575var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(pipeNameInput));
src\Compilers\Shared\CompilerServerLogger.cs (1)
157byte[] bytes = Encoding.UTF8.GetBytes(output);
Microsoft.CodeAnalysis (22)
CommandLine\CommonCompiler.cs (2)
372using (var reader = new StreamReader(data, Encoding.UTF8)) 1755var bytes = Encoding.UTF8.GetBytes(key);
DiaSymReader\Writer\SymUnmanagedWriterImpl.cs (3)
386byte[] bytes = Encoding.UTF8.GetBytes(value); 388value = Encoding.UTF8.GetString(bytes, 0, bytes.Length); 392encodedLength = Encoding.UTF8.GetByteCount(value);
InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
MetadataReader\PEModule.cs (1)
4013private StringTableDecoder() : base(System.Text.Encoding.UTF8) { }
PEWriter\MetadataWriter.cs (1)
40internal static readonly Encoding s_utf8Encoding = Encoding.UTF8;
PEWriter\PeWriter.cs (1)
365return path + new string('\0', Math.Max(0, minLength - Encoding.UTF8.GetByteCount(path) - 1));
SourceGeneration\GeneratorContexts.cs (2)
82public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 274public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8));
SourceGeneration\IncrementalContexts.cs (3)
124public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 144public void AddEmbeddedAttributeDefinition() => AddSource("Microsoft.CodeAnalysis.EmbeddedAttribute", SourceText.From(_embeddedAttributeDefinition, encoding: Encoding.UTF8)); 171public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8));
src\Dependencies\CodeAnalysis.Debugging\CustomDebugInfoReader.cs (1)
867return Encoding.UTF8.GetString(block, 0, block.Length);
Syntax\SyntaxNode.cs (1)
321/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default.
Text\SourceText.cs (6)
98/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 124/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 163/// <see cref="Encoding.UTF8"/> if not specified. 235/// <see cref="Encoding.UTF8"/> if not specified. 392/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 1249return Encoding.UTF8;
Microsoft.CodeAnalysis.Analyzers (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.CodeAnalysis.AnalyzerUtilities (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.CodeAnalysis.BannedApiAnalyzers (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.CodeAnalysis.CodeStyle (7)
src\Analyzers\Core\Analyzers\Helpers\DiagnosticHelper.cs (1)
231return Encoding.UTF8.GetString(jsonBytes, 0, jsonBytes.Length);
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities (2)
src\Features\DiagnosticsTestUtilities\CodeActions\CodeFixVerifierHelper.cs (2)
103return explicitEditorConfig is object ? SourceText.From(explicitEditorConfig, Encoding.UTF8) : null; 132return SourceText.From(analyzerConfig.ToString(), Encoding.UTF8);
Microsoft.CodeAnalysis.Compiler.Test.Resources (1)
ResourceLoader.cs (1)
67using (var streamReader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true))
Microsoft.CodeAnalysis.CSharp (2)
Syntax\CSharpSyntaxTree.Dummy.cs (1)
46get { return Encoding.UTF8; }
Syntax\SyntaxFactory.cs (1)
1924return SourceText.From(text, Encoding.UTF8).GetSubText(offset);
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (8)
CommandLineTests.cs (7)
2296byte[] slContent = Encoding.UTF8.GetBytes(@"{ ""documents"" : {} }"); 2514var sourceStr = Encoding.UTF8.GetString(sourceBlob.Array, sourceBlob.Offset, sourceBlob.Count); 2533var content = File.ReadAllText(file, encoding ?? Encoding.UTF8); 7674var explicitManifestStream = new MemoryStream(Encoding.UTF8.GetBytes(explicitManifest)); 9055return new TestStream(backingStream: new MemoryStream(Encoding.UTF8.GetBytes(@" 9243var actual = new string(Encoding.UTF8.GetChars(bytes)); 14031context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha1));
src\Compilers\Test\Resources\Core\ResourceLoader.cs (1)
67using (var streamReader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true))
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (31)
Debugging\ProximityExpressionsGetterTests.cs (1)
31using var reader = new StreamReader(stream, Encoding.UTF8);
PdbSourceDocument\AbstractPdbSourceDocumentTests.cs (1)
198var sourceText = SourceText.From(source, encoding: encoding ?? Encoding.UTF8);
PdbSourceDocument\ImplementationAssemblyLookupServiceTests.cs (17)
42var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 80var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 122var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 160var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 184sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 221var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 244sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 282var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 305sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 337var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 360sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 388var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 411sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 453var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 476sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 511var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 534var typeForwardSourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
PdbSourceDocument\PdbSourceDocumentLoaderServiceTests.cs (2)
48var result = await service.LoadSourceDocumentAsync(path, sourceDocument, Encoding.UTF8, new TelemetryMessage(CancellationToken.None), useExtendedTimeout: false, CancellationToken.None); 80var result = await service.LoadSourceDocumentAsync(path, sourceDocument, Encoding.UTF8, new TelemetryMessage(CancellationToken.None), useExtendedTimeout: false, CancellationToken.None);
PdbSourceDocument\PdbSourceDocumentTests.cs (10)
408var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 438var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 474var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 521var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 547sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 724CompileTestSource(path, SourceText.From(source2, Encoding.UTF8), project, Location.OnDisk, Location.OnDisk, buildReferenceAssembly: false, windowsPdb: false); 757File.WriteAllText(GetSourceFilePath(path), source2, Encoding.UTF8); 875var sourceText = SourceText.From(source, Encoding.UTF8); 926var sourceText1 = SourceText.From(source1, Encoding.UTF8); 927var sourceText2 = SourceText.From(source2, Encoding.UTF8);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (6)
Emit\CompilationEmitTests.cs (6)
290Encoding.UTF8.GetString(xmlDocBytes)); 336Encoding.UTF8.GetString(xmlDocBytes)); 390Encoding.UTF8.GetString(xmlDocBytes)); 446Encoding.UTF8.GetString(xmlDocBytes)); 499Encoding.UTF8.GetString(xmlDocBytes)); 548Encoding.UTF8.GetString(xmlDocBytes));
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (16)
Emit\EditAndContinue\EditAndContinueTests.cs (3)
19892AFB1C33C5229BFF7EF739BA44DA795A2B68A49E06001C07C5B026CAA6C6322BB: {BitConverter.ToString(Encoding.UTF8.GetBytes("0123456789X"))}-00-00-00-00-00-00-00 19991ACE59E7D984CCEB2D860A056A3386344236CE5C42C978E26ECE3F35956DAC3AD: {BitConverter.ToString(Encoding.UTF8.GetBytes("0123456789X"))}-00 2015084D89877F0D4041EFB6BF91A16F0248F2FD573E6AF05C19F96BEDB9F882F7882: {BitConverter.ToString(Encoding.UTF8.GetBytes("0123456789"))}-00-00
PDB\CheckSumTest.cs (2)
34var tree1 = SyntaxFactory.ParseSyntaxTree(StringText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), path: "sha1.cs"); 35var tree256 = SyntaxFactory.ParseSyntaxTree(StringText.From(source256, Encoding.UTF8, SourceHashAlgorithm.Sha256), path: "sha256.cs");
PDB\CSharpDeterministicBuildCompilationTests.cs (3)
109", filename: "a.cs", options: parseOptions, encoding: Encoding.UTF8); 169", filename: "a.cs", options: parseOptions, encoding: Encoding.UTF8); 233", filename: "a.cs", options: parseOptions, encoding: Encoding.UTF8);
PDB\PDBSourceLinkTests.cs (2)
43var sourceLinkBlob = Encoding.UTF8.GetBytes(@" 74var sourceLinkBlob = Encoding.UTF8.GetBytes(@"
PDB\PDBTests.cs (3)
48var tree4 = SyntaxFactory.ParseSyntaxTree("class D { }", encoding: Encoding.UTF8, path: "Baz.cs"); 104context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256)); 12307var tree = SyntaxFactory.ParseSyntaxTree(source, encoding: Encoding.UTF8, path: "HIDDEN.cs");
PDB\PortablePdbTests.cs (2)
293var sourceLinkBlob = Encoding.UTF8.GetBytes(@" 335var sourceLinkBlob = Encoding.UTF8.GetBytes(@"
PDB\TypeDefinitionDocumentTests.cs (1)
463var trees = sources.Select((s, i) => SyntaxFactory.ParseSyntaxTree(s, path: $"{i + 1}.cs", encoding: Encoding.UTF8)).ToArray();
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (18)
Attributes\AttributeTests_CallerInfoAttributes.cs (15)
4169SyntaxFactory.ParseSyntaxTree(source1, path: @"C:\filename", encoding: Encoding.UTF8), 4170SyntaxFactory.ParseSyntaxTree(source2, path: @"a\b\..\c\d", encoding: Encoding.UTF8), 4171SyntaxFactory.ParseSyntaxTree(source3, path: @"*", encoding: Encoding.UTF8), 4172SyntaxFactory.ParseSyntaxTree(source4, path: @" ", encoding: Encoding.UTF8), 4211SyntaxFactory.ParseSyntaxTree(source1, options: TestOptions.Regular9, path: @"C:\filename", encoding: Encoding.UTF8) 4264SyntaxFactory.ParseSyntaxTree(source1, path: @"C:\filename", encoding: Encoding.UTF8), 4265SyntaxFactory.ParseSyntaxTree(source2, path: @"a\b\..\c\d.cs", encoding: Encoding.UTF8), 4266SyntaxFactory.ParseSyntaxTree(source3, path: @"*", encoding: Encoding.UTF8), 4267SyntaxFactory.ParseSyntaxTree(source4, path: @"C:\x.cs", encoding: Encoding.UTF8), 4268SyntaxFactory.ParseSyntaxTree(source5, path: @"C:\x.cs", encoding: Encoding.UTF8), 5171new[] { SyntaxFactory.ParseSyntaxTree(source, path: @"C:\filename", encoding: Encoding.UTF8) }, 5222new[] { SyntaxFactory.ParseSyntaxTree(source, options: TestOptions.Regular7, path: @"C:\filename", encoding: Encoding.UTF8) }, 5555new[] { SyntaxFactory.ParseSyntaxTree(source, path: @"C:\filename", encoding: Encoding.UTF8) }, 5615new[] { SyntaxFactory.ParseSyntaxTree(source, path: @"C:\filename", encoding: Encoding.UTF8) }, 5670new[] { SyntaxFactory.ParseSyntaxTree(csSource, path: @"C:\filename", encoding: Encoding.UTF8) },
Attributes\AttributeTests_MarshalAs.cs (2)
1039{ "CustomMarshaler6", new byte[] { 0x2c, 0x00, 0x00, 0x60 }.Append(Encoding.UTF8.GetBytes("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\0")) }, 1041{ "CustomMarshaler8", new byte[] { 0x2c, 0x00, 0x00, 0x59 }.Append(Encoding.UTF8.GetBytes("System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\0")) },
Attributes\AttributeTests_Security.cs (1)
1488string hexFileContent = PermissionSetAttributeWithFileReference.ConvertToHex(new MemoryStream(Encoding.UTF8.GetBytes(text)));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (10)
ScriptTests.cs (10)
48var script = CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")), ScriptOptions); 144var script = CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")), ScriptOptions); 861var opts = ScriptOptions.WithEmitDebugInformation(true).WithFilePath("debug.csx").WithFileEncoding(Encoding.UTF8); 875var opts = ScriptOptions.WithEmitDebugInformation(false).WithFilePath("debug.csx").WithFileEncoding(Encoding.UTF8); 884return VerifyStackTraceAsync(() => CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts), line: 1, column: 1, filename: "debug.csx"); 891return VerifyStackTraceAsync(() => CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts)); 906var opts = ScriptOptions.WithEmitDebugInformation(true).WithFileEncoding(Encoding.UTF8); 920var opts = ScriptOptions.WithEmitDebugInformation(false).WithFileEncoding(Encoding.UTF8); 929return VerifyStackTraceAsync(() => CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts), line: 1, column: 1, filename: ""); 936return VerifyStackTraceAsync(() => CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts));
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (34)
Semantics\TopLevelStatementsTests.cs (2)
8789var newText = SourceText.From(text2, Encoding.UTF8, SourceHashAlgorithms.Default); 8795var tree = CSharpSyntaxTree.Create(compilationUnit, TestOptions.RegularDefault, path: "", Encoding.UTF8, SourceHashAlgorithms.Default);
SourceGeneration\AdditionalSourcesCollectionTests.cs (18)
54asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8)); 70asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8)); 110var exception = Assert.Throws<ArgumentException>(nameof(hintName), () => asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8))); 120asc.Add("file3.cs", SourceText.From("", Encoding.UTF8)); 121asc.Add("file1.cs", SourceText.From("", Encoding.UTF8)); 122asc.Add("file2.cs", SourceText.From("", Encoding.UTF8)); 123asc.Add("file5.cs", SourceText.From("", Encoding.UTF8)); 124asc.Add("file4.cs", SourceText.From("", Encoding.UTF8)); 144asc.Add(names[i], SourceText.From("", Encoding.UTF8)); 166asc.Add(hintName1, SourceText.From("", Encoding.UTF8)); 167var exception = Assert.Throws<ArgumentException>("hintName", () => asc.Add(hintName2, SourceText.From("", Encoding.UTF8))); 176asc.Add("hintName1", SourceText.From("", Encoding.UTF8)); 177asc.Add("hintName2", SourceText.From("", Encoding.UTF8)); 180asc2.Add("hintName3", SourceText.From("", Encoding.UTF8)); 181asc2.Add("hintName1", SourceText.From("", Encoding.UTF8)); 200asc.Add(addHintName, SourceText.From("", Encoding.UTF8)); 212asc.Add(addHintName, SourceText.From("", Encoding.UTF8)); 224asc.Add("file1.cs", SourceText.From("", Encoding.UTF8));
SourceGeneration\GeneratorDriverTests.cs (11)
460sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 463Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 466Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 491spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 494Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 497Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 504spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 586var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("test", SourceText.From("public class D {}", Encoding.UTF8)); }); 616var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("test", SourceText.From("public class D {}", Encoding.UTF8)); sgc.AddSource("test2", SourceText.From("public class E {}", Encoding.UTF8)); }); 756e.AddSource("a", SourceText.From("public class E {}", Encoding.UTF8));
SourceGeneration\SyntaxAwareGeneratorTests.cs (3)
420onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 510onExecute: (e) => { receiver = e.SyntaxReceiver; e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 2052onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); }
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (4)
Compilation\CompilationAPITests.cs (2)
2263var appConfig = new MemoryStream(Encoding.UTF8.GetBytes( 2323var appConfig = new MemoryStream(Encoding.UTF8.GetBytes(
Symbols\CompilationCreationTests.cs (1)
2793new[] { SyntaxFactory.ParseSyntaxTree(@"#r ""bar""", TestOptions.Script, "a.csx", Encoding.UTF8) },
Symbols\CovariantReturnTests.cs (1)
451return comp.AddSyntaxTrees(CSharpSyntaxTree.ParseText(assignments, (CSharpParseOptions)comp.SyntaxTrees[0].Options, path: "assignments.cs", encoding: Encoding.UTF8));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (4)
Syntax\Mocks\MockCSharpSyntaxTree.cs (1)
29_sourceText = source ?? SourceText.From("", Encoding.UTF8, SourceHashAlgorithm.Sha256);
Syntax\SyntaxTreeTests.cs (3)
86SyntaxTreeFactoryKind.ParseText => CSharpSyntaxTree.ParseText(SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 87SyntaxTreeFactoryKind.Subclass => new MockCSharpSyntaxTree(root, SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 89SyntaxTreeFactoryKind.ParsedTreeWithPath => WithInitializedDirectives(CSharpSyntaxTree.Create(root, options: parseOptions, path: "old path", Encoding.UTF8)).WithFilePath("new path"),
Microsoft.CodeAnalysis.CSharp.Test.Utilities (2)
CSharpTestBase.cs (1)
2335string text = Encoding.UTF8.GetString(stream.ToArray());
CSharpTestSource.cs (1)
41var stringText = SourceText.From(text, encoding ?? Encoding.UTF8, checksumAlgorithm);
Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests (2)
Metadata\WinMdDumpTest.cs (2)
468var expected = Encoding.UTF8.GetString(TestResources.WinRt.Windows_dump); 478var expected = Encoding.UTF8.GetString(TestResources.WinRt.WinMDPrefixing_dump);
Microsoft.CodeAnalysis.Debugging.Package (1)
CustomDebugInfoReader.cs (1)
867return Encoding.UTF8.GetString(block, 0, block.Length);
Microsoft.CodeAnalysis.EditorFeatures (1)
Workspaces\EditorTextFactoryService.cs (1)
85return buffer.CurrentSnapshot.AsRoslynText(_textBufferCloneService, reader.CurrentEncoding ?? Encoding.UTF8, checksumAlgorithm);
Microsoft.CodeAnalysis.EditorFeatures.Text (2)
Extensions.cs (2)
96/// Note that this will return <see cref="Encoding.UTF8"/> if the <see cref="ITextBuffer"/> 104: Encoding.UTF8;
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (6)
EditAndContinue\EditAndContinueLanguageServiceTests.cs (4)
352var sourceFile = dir.CreateFile("test.cs").WriteAllText(source1, Encoding.UTF8); 367loader: new WorkspaceFileTextLoader(workspace.Services.SolutionServices, sourceFile.Path, Encoding.UTF8), 379File.WriteAllText(sourceFile.Path, source2, Encoding.UTF8); 386Text = SourceText.From(source3, Encoding.UTF8, SourceHashAlgorithm.Sha1)
Workspaces\TextFactoryTests.cs (2)
71.. Encoding.UTF8.GetPreamble(), 75expectedEncoding: Encoding.UTF8);
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (4)
CustomTypeInfo.cs (2)
150return new ReadOnlyCollection<byte>(Encoding.UTF8.GetBytes(str)); 157var str = Encoding.UTF8.GetString(array, 0, length);
PDB\MethodDebugInfo.Portable.cs (2)
243return Encoding.UTF8.GetString(bytes, 0, bytes.Length); 262return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider (2)
src\ExpressionEvaluator\Core\Source\ExpressionCompiler\CustomTypeInfo.cs (2)
150return new ReadOnlyCollection<byte>(Encoding.UTF8.GetBytes(str)); 157var str = Encoding.UTF8.GetString(array, 0, length);
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.Utilities (2)
src\ExpressionEvaluator\Core\Source\ExpressionCompiler\CustomTypeInfo.cs (2)
150return new ReadOnlyCollection<byte>(Encoding.UTF8.GetBytes(str)); 157var str = Encoding.UTF8.GetString(array, 0, length);
Microsoft.CodeAnalysis.Features (7)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs (1)
109var emptyText = SourceText.From("", Encoding.UTF8, SourceHashAlgorithms.Default);
EditAndContinue\TraceLog.cs (1)
117using var writer = new StreamWriter(file, text.Encoding ?? Encoding.UTF8);
MetadataAsSource\MetadataAsSourceGeneratedFileInfo.cs (1)
48public static Encoding Encoding => Encoding.UTF8;
PdbSourceDocument\PdbSourceDocumentMetadataAsSourceFileProvider.cs (1)
257var encoding = defaultEncoding ?? Encoding.UTF8;
SemanticSearch\SemanticSearchUtilities.cs (1)
69=> SourceText.From(query, Encoding.UTF8, SourceHashAlgorithm.Sha256);
src\Analyzers\Core\Analyzers\Helpers\DiagnosticHelper.cs (1)
231return Encoding.UTF8.GetString(jsonBytes, 0, jsonBytes.Length);
src\Dependencies\CodeAnalysis.Debugging\CustomDebugInfoReader.cs (1)
867return Encoding.UTF8.GetString(block, 0, block.Length);
Microsoft.CodeAnalysis.Features.Test.Utilities (11)
EditAndContinue\ActiveStatementTestHelpers.cs (1)
42static (source, path) => SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: Encoding.UTF8, SourceHashAlgorithms.Default), path: path),
EditAndContinue\EditAndContinueWorkspaceTestBase.cs (4)
154=> projectDirectory?.CreateFile(fileName).WriteAllText(content, Encoding.UTF8).Path ?? Path.Combine(TempRoot.Root, fileName); 364encoding ??= Encoding.UTF8; 450=> SourceText.From(source, Encoding.UTF8, SourceHashAlgorithms.Default); 455return SourceText.From(stream, Encoding.UTF8, SourceHashAlgorithms.Default);
EditAndContinue\Extensions.cs (3)
91SourceText.From(source, Encoding.UTF8, SourceHashAlgorithms.Default), 98Assert.True(Encoding.UTF8.GetByteCount(projectName) <= 20, "Use shorter project names in tests"); 99return BlobContentId.FromHash(Encoding.UTF8.GetBytes(projectName.PadRight(20, '\0'))).Guid;
Snippets\AbstractSnippetProviderTests.cs (3)
44SourceText.From(markupBeforeCommit, Encoding.UTF8, SourceHashAlgorithms.Default), 51SourceText.From(editorconfig, Encoding.UTF8, SourceHashAlgorithms.Default), 132var document = project.AddDocument("TestDocument", SourceText.From(markup, Encoding.UTF8, SourceHashAlgorithms.Default));
Microsoft.CodeAnalysis.Features.UnitTests (45)
EditAndContinue\ActiveStatementsMapTests.cs (3)
118.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 173.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 224.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution;
EditAndContinue\EditAndContinueWorkspaceServiceTests.cs (34)
47var encodingE = Encoding.UTF8; 59var sourceBytesD1 = Encoding.UTF8.GetBytesWithPreamble(sourceD1); 394var sourceFilePath = dir.CreateFile(sourceFileName).WriteAllText(source, Encoding.UTF8).Path; 413solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 433solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 573var sourceFile = dir.CreateFile("a.cs").WriteAllText(source1, Encoding.UTF8); 626var sourceFile = dir.CreateFile("a.cs").WriteAllText(source1, Encoding.UTF8); 632AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 684var sourceFileA = Temp.CreateFile().WriteAllText(sourceA, Encoding.UTF8); 685var sourceFileB = Temp.CreateFile().WriteAllText(sourceB, Encoding.UTF8); 749var sourceFileA = Temp.CreateFile().WriteAllText(sourceA, Encoding.UTF8); 750var sourceFileB = Temp.CreateFile().WriteAllText(sourceB, Encoding.UTF8); 781var sourceFile1 = Temp.CreateFile().WriteAllText(source1, Encoding.UTF8); 797var sourceFile2 = Temp.CreateFile().WriteAllText(source2, Encoding.UTF8); 852sourceFile.WriteAllText(source1, Encoding.UTF8); 1234sourceFile.WriteAllText(source1, Encoding.UTF8); 1267sourceFile.WriteAllText(source0, Encoding.UTF8); 1328var sourceFile = dir.CreateFile("a.cs").WriteAllText(source1, Encoding.UTF8); 1371var sourceFile = dir.CreateFile("a.cs").WriteAllText(source1, Encoding.UTF8); 1495File.WriteAllText(sourceFilePath, source3, Encoding.UTF8); 1911context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256)); 1984var sourceFileA = dir.CreateFile("a.cs").WriteAllText(sourceA1, Encoding.UTF8); 1985var sourceFileB = dir.CreateFile("b.cs").WriteAllText(sourceB1, Encoding.UTF8); 2322var sourceFile = dir.CreateFile("test.cs").WriteAllText(source1, Encoding.UTF8); 2360sourceFile.WriteAllText(source2, Encoding.UTF8); 2409var sourceFile = dir.CreateFile("test.cs").WriteAllText(source2, Encoding.UTF8); 2456sourceFile.WriteAllText(source1, Encoding.UTF8); 2481var sourceFile = dir.CreateFile("test.cs").WriteAllText(source1, Encoding.UTF8); 2542var sourceFile = dir.CreateFile("test.cs").WriteAllText(sourceOnDisk, Encoding.UTF8); 3678var sourcePath = dir.CreateFile("Lib.cs").WriteAllText(source1, Encoding.UTF8).Path; 3738File.WriteAllText(sourcePath, source2, Encoding.UTF8); 3775var sourcePath = dir.CreateFile("Lib.cs").WriteAllText(source1, Encoding.UTF8).Path; 4856var sourceFileA = dir.CreateFile("A.cs").WriteAllText(source1, Encoding.UTF8); 4870loader: new WorkspaceFileTextLoader(solution.Services, sourceFileA.Path, Encoding.UTF8),
EditAndContinue\EditSessionActiveStatementsTests.cs (1)
81var text = SourceText.From(SourceMarkers.Clear(markedSources[i]), Encoding.UTF8);
EditAndContinue\EmitSolutionUpdateResultsTests.cs (1)
77AddDocument(sourcePath, SourceText.From("class C {}", Encoding.UTF8), filePath: Path.Combine(TempRoot.Root, sourcePath));
EditAndContinue\RemoteEditAndContinueServiceTests.cs (1)
81.AddDocument(documentId, "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs")
EditAndContinue\UnitTestingHotReloadServiceTests.cs (2)
31var sourceFileA = dir.CreateFile("A.cs").WriteAllText(source1, Encoding.UTF8); 47loader: new WorkspaceFileTextLoader(solution.Services, sourceFileA.Path, Encoding.UTF8),
EditAndContinue\WatchHotReloadServiceTests.cs (3)
57var sourceFileA = dir.CreateFile("A.cs").WriteAllText(source1, Encoding.UTF8); 72loader: new WorkspaceFileTextLoader(solution.Services, sourceFileA.Path, Encoding.UTF8), 197context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256));
Microsoft.CodeAnalysis.LanguageServer (1)
FileBasedPrograms\VirtualProjectXmlProvider.cs (1)
114byte[] bytes = Encoding.UTF8.GetBytes(text);
Microsoft.CodeAnalysis.LanguageServer.Protocol (2)
Features\Diagnostics\DiagnosticDataExtensions.cs (1)
39using var stream = new MemoryStream(Encoding.UTF8.GetBytes(indicesProperty));
Handler\DocumentChanges\DidOpenHandler.cs (1)
36var sourceText = SourceText.From(request.TextDocument.Text, System.Text.Encoding.UTF8, SourceHashAlgorithms.OpenDocumentChecksumAlgorithm);
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (3)
Workspaces\LspWorkspaceManagerTests.cs (3)
88await testLspServer.TestWorkspace.ChangeDocumentAsync(firstDocument.Id, SourceText.From($"Some more text{markupOne}", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 122await testLspServer.TestWorkspace.ChangeDocumentAsync(secondDocument.Id, SourceText.From("Two is now three!", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 224var newSolution = testLspServer.TestWorkspace.CurrentSolution.AddDocument(newDocumentId, "NewDoc.cs", SourceText.From("New Doc", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default), filePath: @"C:\NewDoc.cs");
Microsoft.CodeAnalysis.LanguageServer.UnitTests (1)
VirtualProjectXmlProviderTests.cs (1)
63globalJsonFile.WriteAllBytes(Encoding.UTF8.GetBytes("""
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.CodeAnalysis.PublicApiAnalyzers (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.CodeAnalysis.Rebuild (1)
CompilationOptionsReader.cs (1)
119? Encoding.UTF8
Microsoft.CodeAnalysis.Rebuild.UnitTests (8)
BasicDeterministicKeyBuilderTests.cs (3)
32SourceText.From(content, checksumAlgorithm: hashAlgorithm, encoding: Encoding.UTF8), 83var additionalText = new TestAdditionalText(content, Encoding.UTF8, path: "file.txt", HashAlgorithm); 318var json = Encoding.UTF8.GetString(keyFile.Contents.ToArray());
CSharpDeterministicKeyBuilderTests.cs (3)
32encoding: Encoding.UTF8, 192var additionalText = new TestAdditionalText(content, Encoding.UTF8, path: "file.txt", HashAlgorithm); 502var json = Encoding.UTF8.GetString(keyFile.Contents.ToArray());
OptionRoundTripTests.cs (1)
53encoding: Encoding.UTF8,
RoundTripUtil.cs (1)
210return Encoding.UTF8.GetString(stream.ToArray());
Microsoft.CodeAnalysis.ResxSourceGenerator (12)
AbstractResxGenerator.cs (4)
209var errorText = SourceText.From(text, Encoding.UTF8, SourceHashAlgorithm.Sha256); 323OutputText = SourceText.From("", Encoding.UTF8); 347OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256); 706OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256);
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests (4)
Verifiers\CSharpSourceGeneratorVerifier`1+Test.cs (2)
122using var reader = new StreamReader(resourceStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); 124TestState.GeneratedSources.Add((typeof(TSourceGenerator), name, SourceText.From(reader.ReadToEnd(), Encoding.UTF8, SourceHashAlgorithm.Sha256)));
Verifiers\VisualBasicSourceGeneratorVerifier`1+Test.cs (2)
107using var reader = new StreamReader(resourceStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); 109TestState.GeneratedSources.Add((typeof(VisualBasicResxGenerator), name, SourceText.From(reader.ReadToEnd(), Encoding.UTF8, SourceHashAlgorithm.Sha256)));
Microsoft.CodeAnalysis.Scripting.TestUtilities (2)
TestConsoleIO.cs (2)
58public override Encoding Encoding => Encoding.UTF8; 108public override Encoding Encoding => Encoding.UTF8;
Microsoft.CodeAnalysis.Test.Utilities (11)
Metadata\MetadataReaderUtils.cs (1)
238builder.AddRange(System.Text.Encoding.UTF8.GetBytes(str));
Mocks\TestSourceReferenceResolver.cs (1)
52return new MemoryStream((data is string) ? Encoding.UTF8.GetBytes((string)data) : (byte[])data);
ResourceLoader.cs (1)
59using (var streamReader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true))
SourceGeneration\TestGenerators.cs (4)
40context.AddSource(hintName, SourceText.From(content, Encoding.UTF8)); 98: SourceText.From(source, Encoding.UTF8))); 109: SourceText.From(source, Encoding.UTF8))); 145_content = SourceText.From(content, Encoding.UTF8);
Syntax\SourceUtilities.cs (1)
27public override Encoding Encoding => Encoding.UTF8;
TempFiles\TempFile.cs (1)
94return WriteAllTextAsync(content, Encoding.UTF8);
TestableFile.cs (1)
70Contents.AddRange(Encoding.UTF8.GetBytes(contents));
Win32Res.cs (1)
75encoding = Encoding.UTF8;
Microsoft.CodeAnalysis.TestAnalyzerReference (3)
HelloWorldGenerator.cs (3)
36""", encoding: Encoding.UTF8)); 46""", encoding: Encoding.UTF8)); 57""", encoding: Encoding.UTF8));
Microsoft.CodeAnalysis.UnitTests (32)
Diagnostics\SarifErrorLoggerTests.cs (3)
47string actual = Encoding.UTF8.GetString(stream.ToArray()); 87string actual = Encoding.UTF8.GetString(stream.ToArray()); 130Encoding.UTF8.GetString(buffer, 0, buffer.Length),
EmbeddedTextTests.cs (11)
42Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From(new byte[0], 0, Encoding.UTF8, canBeEmbedded: false))); 43Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From(new MemoryStream(new byte[0]), Encoding.UTF8, canBeEmbedded: false))); 116var bytes = Encoding.UTF8.GetBytes(SmallSource); 130var bytes = Encoding.UTF8.GetBytes(SmallSource); 145var source = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 152AssertEx.Equal(Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(SmallSource)), text.Blob.Skip(4)); 200var expected = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 203var actual = SourceText.From(new StringReader(SmallSource), SmallSource.Length, Encoding.UTF8, SourceHashAlgorithm.Sha1); 215var expected = SourceText.From(LargeSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 218var actual = SourceText.From(new StringReader(LargeSource), LargeSource.Length, Encoding.UTF8, SourceHashAlgorithm.Sha1);
Text\LargeTextTests.cs (4)
22using (StreamWriter sw = new StreamWriter(stream, encoding ?? Encoding.UTF8, bufferSize: 1024, leaveOpen: true)) 33return LargeText.Decode(stream, encoding ?? Encoding.UTF8, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true, canBeEmbedded: false); 38return LargeText.Decode(reader, length, encoding ?? Encoding.UTF8, SourceHashAlgorithm.Sha1); 115using (StreamWriter sw = new StreamWriter(stream, Encoding.UTF8, bufferSize: 1024, leaveOpen: true))
Text\SourceTextTests.cs (3)
22private static readonly Encoding s_utf8 = Encoding.UTF8; 332var encoding = Encoding.UTF8; 412TestTryReadByteOrderMark(expectedEncoding: Encoding.UTF8, expectedPreambleLength: 3, data: new byte[] { 0xef, 0xBB, 0xBF });
Text\StringTextDecodingTests.cs (2)
134var data = CreateMemoryStreamBasedEncodedText("", Encoding.UTF8, readEncodingOpt: null, algorithm: SourceHashAlgorithm.Sha256); 197Assert.Equal(Encoding.UTF8.EncodingName, sourceText.Encoding.EncodingName);
Text\StringTextTest.cs (8)
46var data = SourceText.From("goo", Encoding.UTF8); 69Assert.Throws<ArgumentNullException>(() => SourceText.From((string)null, Encoding.UTF8)); 75Assert.Throws<ArgumentNullException>(() => SourceText.From((Stream)null, Encoding.UTF8)); 76Assert.Throws<ArgumentException>(() => SourceText.From(new TestStream(canRead: false, canSeek: true), Encoding.UTF8)); 77Assert.Throws<NotImplementedException>(() => SourceText.From(new TestStream(canRead: true, canSeek: false), Encoding.UTF8)); 83var data = SourceText.From(string.Empty, Encoding.UTF8); 224var data = SourceText.From("The quick brown fox jumps over the lazy dog", Encoding.UTF8); 259var bytes = Encoding.UTF8.GetBytes("\u1234");
Text\TextChangeTests.cs (1)
613return new LargeText(ImmutableArray.Create(chunks), Encoding.UTF8, default(ImmutableArray<byte>), SourceHashAlgorithms.Default, default(ImmutableArray<byte>));
Microsoft.CodeAnalysis.VisualBasic (4)
Symbols\EmbeddedSymbols\EmbeddedSymbolManager.vb (1)
23Return VisualBasicSyntaxTree.ParseText(SourceText.From(text, Encoding.UTF8, SourceHashAlgorithms.Default))
Symbols\Source\SynthesizedMyGroupCollectionPropertyAccessorSymbol.vb (1)
74Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(codeToParse, Encoding.UTF8, SourceHashAlgorithms.Default))
Syntax\SyntaxNodeFactories.vb (1)
288Return SourceText.From(text, Encoding.UTF8).GetSubText(offset)
Syntax\VisualBasicSyntaxTree.DummySyntaxTree.vb (1)
39Return Encoding.UTF8
Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests (3)
CommandLineTests.vb (3)
3426Dim sourceStr = Encoding.UTF8.GetString(sourceBlob.Array, sourceBlob.Offset, sourceBlob.Count) 9633backingStream:=New MemoryStream(Encoding.UTF8.GetBytes(" 10927Dim content = File.ReadAllText(fileName, If(encoding, Encoding.UTF8))
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (16)
Attributes\AttributeTests_MarshalAs.vb (2)
884{"CustomMarshaler6", New Byte() {&H2C, &H0, &H0, &H60}.Append(Encoding.UTF8.GetBytes("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" & ChrW(0)))}, 886{"CustomMarshaler8", New Byte() {&H2C, &H0, &H0, &H59}.Append(Encoding.UTF8.GetBytes("System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" & ChrW(0)))},
Emit\CompilationEmitTests.vb (7)
346Encoding.UTF8.GetString(xmlDocBytes)) 392Encoding.UTF8.GetString(xmlDocBytes)) 441Encoding.UTF8.GetString(xmlDocBytes)) 491Encoding.UTF8.GetString(xmlDocBytes)) 540Encoding.UTF8.GetString(xmlDocBytes)) 589Encoding.UTF8.GetString(xmlDocBytes)) 3579Dim hexFileContent = PermissionSetAttributeWithFileReference.ConvertToHex(New MemoryStream(Encoding.UTF8.GetBytes(text)))
PDB\PDBTests.vb (1)
28Dim tree4 = SyntaxFactory.ParseSyntaxTree("Class D : End Class", path:="Baz.vb", encoding:=Encoding.UTF8)
PDB\PortablePdbTests.vb (2)
190Dim sourceLinkBlob = Encoding.UTF8.GetBytes(" 226Dim sourceLinkBlob = Encoding.UTF8.GetBytes("
PDB\TypeDefinitionDocumentTests.vb (1)
345Dim trees = sources.Select(Function(s, i) SyntaxFactory.ParseSyntaxTree(s, path:=$"{i + 1}.vb", encoding:=Encoding.UTF8)).ToArray()
PDB\VisualBasicDeterministicBuildCompilationTests.vb (3)
77End Class", fileName:="one.vb", options:=compilationOptions.ParseOptions, encoding:=Encoding.UTF8) 120End Class", fileName:="one.vb", options:=compilationOptions.ParseOptions, encoding:=Encoding.UTF8) 177Yield emitOptions.WithDefaultSourceFileEncoding(Encoding.UTF8)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (9)
Semantics\OptionalArgumentTests.vb (9)
2023SyntaxFactory.ParseSyntaxTree(source1, path:="C:\filename", encoding:=Encoding.UTF8), 2024SyntaxFactory.ParseSyntaxTree(source2, path:="a\b\..\c\d", encoding:=Encoding.UTF8), 2025SyntaxFactory.ParseSyntaxTree(source3, path:="*", encoding:=Encoding.UTF8), 2026SyntaxFactory.ParseSyntaxTree(source4, path:=" ", encoding:=Encoding.UTF8) 2103SyntaxFactory.ParseSyntaxTree(source1, path:="C:\filename", encoding:=Encoding.UTF8), 2104SyntaxFactory.ParseSyntaxTree(source2, path:="a\b\..\c\d.vb", encoding:=Encoding.UTF8), 2105SyntaxFactory.ParseSyntaxTree(source3, path:="*", encoding:=Encoding.UTF8), 2106SyntaxFactory.ParseSyntaxTree(source4, path:="C:\x.vb", encoding:=Encoding.UTF8), 2107SyntaxFactory.ParseSyntaxTree(source5, path:="C:\x.vb", encoding:=Encoding.UTF8)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (2)
IncrementalParser\IncrementalParser.vb (1)
1714Dim oldTree2 = VisualBasicSyntaxTree.Create(DirectCast(oldRoot2, VisualBasicSyntaxNode), DirectCast(tempTree2.Options, VisualBasicParseOptions), tempTree2.FilePath, Encoding.UTF8)
Syntax\SyntaxFactsTest.vb (1)
18Using stream = New StreamReader(GetType(SyntaxFactsTests).Assembly.GetManifestResourceStream("AllInOne.vb"), Encoding.UTF8)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (5)
BasicTestSource.vb (1)
22Dim sourceTest = SourceText.From(text, If(encoding, Encoding.UTF8), checksumAlgorithm)
CompilationTestUtils.vb (2)
635Return VisualBasicSyntaxTree.ParseText(SourceText.From(FilterString(programElement.Value), Encoding.UTF8, SourceHashAlgorithms.Default), path:=If(programElement.@name, "")) 652Dim text = SourceText.From(codeWithoutMarker, Encoding.UTF8)
ParserTestUtilities.vb (1)
107encoding = Encoding.UTF8
VBParser.vb (1)
18Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(code, Encoding.UTF8, SourceHashAlgorithms.Default), _options, path:="")
Microsoft.CodeAnalysis.Workspaces (13)
Log\AnalyzerNameForTelemetry.cs (1)
16return Convert.ToBase64String(sha256.ComputeHash(Encoding.UTF8.GetBytes(name)));
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Storage\SQLite\Interop\NativeMethods.cs (1)
143/// <paramref name="val"><see cref="Encoding.UTF8"/> encoded bytes of a text value. Span
Storage\SQLite\v2\Interop\SqlConnection.cs (2)
50var length = Encoding.UTF8.GetByteCount(value); 54var wrote = Encoding.UTF8.GetBytes(value, 0, value.Length, byteArray, 0);
Storage\SQLite\v2\Interop\SqlStatement.cs (2)
78var utf8ByteCount = Encoding.UTF8.GetByteCount(value); 90Contract.ThrowIfFalse(Encoding.UTF8.GetBytes(charsPtr, value.Length, bytesPtr, utf8ByteCount) == utf8ByteCount);
Workspace\Solution\TextLoader.cs (1)
161SourceText.From(string.Empty, Encoding.UTF8),
Microsoft.CodeAnalysis.Workspaces.MSBuild (1)
MSBuild\MSBuildWorkspace.cs (1)
485this.SaveDocumentText(info.Id, fullPath, text, text.Encoding ?? Encoding.UTF8);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (2)
MSBuild\ProjectFile\ProjectFileLoader.cs (1)
46var stream = new MemoryStream(Encoding.UTF8.GetBytes(projectContent));
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (2)
GenerateFileForEachAdditionalFileWithContentsCommented.cs (1)
35return SourceText.From(generatedText.ToString(), encoding: Encoding.UTF8);
Workspaces\TestHostDocument.cs (1)
190=> Task.FromResult(TextAndVersion.Create(SourceText.From(_text, encoding: Encoding.UTF8, options.ChecksumAlgorithm), VersionStamp.Create(), _hostDocument.FilePath));
Microsoft.CodeAnalysis.Workspaces.UnitTests (34)
SolutionTests\SolutionTests.cs (32)
58.AddDocument(DocumentId.CreateNewId(projectId), "goo.cs", SourceText.From("public class Goo { }", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "goo.cs")) 59.AddAdditionalDocument(DocumentId.CreateNewId(projectId), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default)) 60.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From(editorConfig ?? "#empty", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")))); 80.AddDocument(DocumentId.CreateNewId(projectId1), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 81.AddAdditionalDocument(DocumentId.CreateNewId(projectId1), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "add.txt") 82.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId1), "editorcfg", SourceText.From("config", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "/a/b") 84.AddDocument(DocumentId.CreateNewId(projectId2), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 85.AddAdditionalDocument(DocumentId.CreateNewId(projectId2), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "add.txt") 86.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId2), "editorcfg", SourceText.From("config", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "/a/b"))); 841.AddDocument(DocumentId.CreateNewId(projectId1), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 843.AddDocument(DocumentId.CreateNewId(projectId2), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs"))); 1091.AddDocument(d1, "d1.cs", SourceText.From("class D1;", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "d1.cs")) 1092.AddDocument(d2, "d2.cs", SourceText.From("class D2;", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "d2.cs")) 1093.AddAdditionalDocument(a1, "a1.txt", SourceText.From("text1", Encoding.UTF8, SourceHashAlgorithms.Default)) 1094.AddAdditionalDocument(a2, "a2.txt", SourceText.From("text2", Encoding.UTF8, SourceHashAlgorithms.Default)) 1095.AddAnalyzerConfigDocument(c1, "c1", SourceText.From("#empty1", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")) 1096.AddAnalyzerConfigDocument(c2, "c2", SourceText.From("#empty2", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")); 1115loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD3;", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1134loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1153loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1244Assert.Same(Encoding.UTF8, newText3.Encoding); 1265Assert.Same(Encoding.UTF8, newAddText3.Encoding); 1286Assert.Same(Encoding.UTF8, newConfigText3.Encoding); 3317var file = Temp.CreateFile().WriteAllText(text1, Encoding.UTF8); 3327.AddDocument(did, "x", new WorkspaceFileTextLoader(workspace.Services.SolutionServices, file.Path, Encoding.UTF8)); 3371var file = Temp.CreateFile().WriteAllText(text, Encoding.UTF8); 3376.AddDocument(did, "x", new WorkspaceFileTextLoader(workspace.Services.SolutionServices, file.Path, Encoding.UTF8)); 3438var file = Temp.CreateFile().WriteAllText(text, Encoding.UTF8); 3443.AddDocument(did, "x", new WorkspaceFileTextLoader(workspace.Services.SolutionServices, file.Path, Encoding.UTF8)); 3799.AddDocument(did, "test", SourceText.From(language == LanguageNames.CSharp ? "class C {}" : "Class C : End Class", Encoding.UTF8, SourceHashAlgorithm.Sha256), filePath: "old path"); 3938.AddDocument(did, "x", new WorkspaceFileTextLoader(solution.Services, @"C:\doesnotexist.cs", Encoding.UTF8)) 4548var loader = new TestSmallFileTextLoader(file.Path, Encoding.UTF8);
SolutionTests\SolutionWithSourceGeneratorTests.cs (1)
620var differentOpenTextContainer = SourceText.From("// StaticContent", Encoding.UTF8).Container;
UtilityTest\XmlDocumentationProviderTests.cs (1)
21var documentationProvider = XmlDocumentationProvider.CreateFromBytes(Encoding.UTF8.GetBytes("""
Microsoft.Data.Analysis (6)
DataFrame.IO.cs (1)
584WrappedStreamReaderOrStringReader wrappedStreamReaderOrStringReader = new WrappedStreamReaderOrStringReader(csvStream, encoding ?? Encoding.UTF8);
DataFrameColumns\ArrowStringDataFrameColumn.cs (5)
262return Encoding.UTF8.GetString(data, bytes.Length); 541ret.Append(IsValid(i) ? GetBytes(i) : Encoding.UTF8.GetBytes(value)); 601ReadOnlySpan<byte> bytes = value != null ? Encoding.UTF8.GetBytes(value) : default(ReadOnlySpan<byte>); 642ReadOnlySpan<byte> bytes = value != null ? Encoding.UTF8.GetBytes(value) : default(ReadOnlySpan<byte>); 687Encoding encoding = Encoding.UTF8;
Microsoft.Data.Analysis.Tests (1)
ArrowStringColumnTests.cs (1)
41byte[] bytes = Encoding.UTF8.GetBytes(data);
Microsoft.DotNet.Arcade.Sdk (6)
src\DownloadFile.cs (1)
87var decodedToken = System.Text.Encoding.UTF8.GetString(encodedTokenBytes);
src\GenerateSourcePackageSourceLinkTargetsFile.cs (2)
38File.WriteAllText(OutputPath, GetOutputFileContent(), Encoding.UTF8); 110hash = BitConverter.ToString(hashAlg.ComputeHash(Encoding.UTF8.GetBytes(packageId)), 0, 20).Replace("-", "");
src\InstallDotNetCore.cs (1)
57var bytes = Encoding.UTF8.GetBytes(jsonContent);
src\ValidateLicense.cs (2)
38var actualLines = File.ReadAllLines(LicensePath, Encoding.UTF8); 39var expectedLines = File.ReadAllLines(ExpectedLicensePath, Encoding.UTF8);
Microsoft.DotNet.Build.Tasks.Feed (5)
src\common\GeneralUtils.cs (2)
273StandardOutputEncoding = Encoding.UTF8, 274StandardErrorEncoding = Encoding.UTF8
src\CreateAzureDevOpsFeed.cs (1)
149createFeedMessage.Content = new StringContent(createBody, Encoding.UTF8, "application/json");
src\model\SetupTargetFeedConfigV3.cs (1)
88return Encoding.UTF8.GetString(Convert.FromBase64String(value));
src\model\SetupTargetFeedConfigV4.cs (1)
87return Encoding.UTF8.GetString(Convert.FromBase64String(value));
Microsoft.DotNet.Build.Tasks.Installers (9)
src\BuildFPMToolPreReqs.cs (1)
43string jsonFileText = File.ReadAllText(ConfigJsonFile, Encoding.UTF8);
src\GenerateGuidFromName.cs (1)
26var nameBytes = System.Text.Encoding.UTF8.GetBytes(Name ?? string.Empty);
src\RpmBuilder.cs (1)
272using StreamReader reader = new(file.DataStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: -1, leaveOpen: true);
src\RpmHeader.cs (4)
164entries.Add(new Entry(entry.Tag, entry.Type, Encoding.UTF8.GetString(store, entry.Offset, length))); 178strings[i] = Encoding.UTF8.GetString(store, offset, length); 271byte[] bytes = Encoding.UTF8.GetBytes((string)entry.Value); 286byte[] bytes = Encoding.UTF8.GetBytes(str);
src\RpmLead.cs (2)
40lead.Name = Encoding.UTF8.GetString(name, 0, Array.IndexOf<byte>(name, 0)); 58Encoding.UTF8.GetBytes(Name, 0, Name.Length, name, 0);
Microsoft.DotNet.Build.Tasks.Packaging (2)
GenerateNuSpec.cs (2)
138var oldSource = Encoding.UTF8.GetString(File.ReadAllBytes(OutputFileName)); 145newSource = Encoding.UTF8.GetString(stream.ToArray());
Microsoft.DotNet.Build.Tasks.VisualStudio (8)
OptProf\GenerateTrainingInputFiles.cs (2)
50config = OptProfTrainingConfiguration.Deserialize(File.ReadAllText(ConfigurationFile, Encoding.UTF8)); 105using (var reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 2048, leaveOpen: true))
OptProf\GenerateTrainingPropsFile.cs (1)
61</Project>", Encoding.UTF8);
OptProf\GetRunSettingsSessionConfiguration.cs (2)
55var buildDropName = GetTestsDropName(File.ReadAllText(BootstrapperInfoPath, Encoding.UTF8)); 56var (testContainersString, testCaseFilterString) = GetTestContainersAndFilters(File.ReadAllText(ConfigurationFile, Encoding.UTF8), ConfigurationFile);
Vsix\FinalizeInsertionVsixFile.cs (2)
115using (var reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 2048, leaveOpen: true)) 128using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 2048, leaveOpen: false))
Vsix\GetPkgDefAssemblyDependencyGuid.cs (1)
54fullHash = sha2.ComputeHash(Encoding.UTF8.GetBytes(value));
Microsoft.DotNet.Build.Tasks.Workloads (4)
Msi\MsiPayloadPackageProject.wix.cs (1)
55Utils.StringReplace(msiCsproj, ReplacementTokens, Encoding.UTF8);
Swix\MsiSwixProject.wix.cs (1)
111Utils.StringReplace(swixProj, ReplacementTokens, Encoding.UTF8);
Swix\SwixProjectBase.cs (1)
88Utils.StringReplace(path, ReplacementTokens, Encoding.UTF8);
Utils.cs (1)
24byte[] bytes = Encoding.UTF8.GetBytes(value);
Microsoft.DotNet.Deployment.Tasks.Links (1)
Microsoft.DotNet.Helix.Client (7)
generated-code\Aggregate.cs (1)
1260_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
generated-code\Analysis.cs (1)
114_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
generated-code\Job.cs (1)
135_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
generated-code\Machine.cs (1)
90_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
generated-code\Storage.cs (2)
159_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body))); 245_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
generated-code\Telemetry.cs (1)
132_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
Microsoft.DotNet.Helix.JobSender (2)
Payloads\SingleFilePayload.cs (1)
19: this(name, content, Encoding.UTF8)
StorageHelpers\ContainerBase.cs (1)
45byte[] bytes = Encoding.UTF8.GetBytes(text);
Microsoft.DotNet.Helix.Sdk (4)
AzureDevOpsTask.cs (1)
67Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes("unused:" + AccessToken))),
CreateFailedTestsForFailedWorkItems.cs (1)
63Encoding.UTF8,
StartAzurePipelinesTestRun.cs (1)
48Encoding.UTF8,
StopAzurePipelinesTestRun.cs (1)
35Encoding.UTF8,
Microsoft.DotNet.Internal.SymbolHelper (2)
SymbolPromotionHelper.cs (2)
152Content = new StringContent(payload.ToString(), Encoding.UTF8, "application/json") 269Content = new StringContent(extensionPayload.ToString(), Encoding.UTF8, "application/json")
Microsoft.DotNet.SignCheckLibrary (2)
Utils.cs (1)
31byte[] bytes = Encoding.UTF8.GetBytes(value);
Verification\Jar\JarManifestFileBase.cs (1)
102using (var manifestStreamReader = new StreamReader(manifestStream, Encoding.UTF8))
Microsoft.Extensions.AI (2)
ChatCompletion\ChatResponse{T}.cs (2)
99var utf8ByteLength = Encoding.UTF8.GetByteCount(json); 103var utf8SpanLength = Encoding.UTF8.GetBytes(json, 0, json.Length, buffer, 0);
Microsoft.Extensions.AI.Abstractions (1)
Contents\DataUriParser.cs (1)
200Encoding.UTF8.GetBytes(WebUtility.UrlDecode(Data.ToString()));
Microsoft.Extensions.AI.Evaluation.Reporting (1)
Formats\Html\HtmlReportWriter.cs (1)
46using var writer = new StreamWriter(stream, Encoding.UTF8);
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (2)
ResponseCacheTester.cs (2)
17private static readonly byte[] _responseA = Encoding.UTF8.GetBytes("Content A"); 19private static readonly byte[] _responseB = Encoding.UTF8.GetBytes("Content B");
Microsoft.Extensions.AI.Integration.Tests (4)
PromptBasedFunctionCallingChatClient.cs (1)
108var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(toolCall));
VerbatimHttpHandler.cs (1)
38ByteArrayContent newContent = new(Encoding.UTF8.GetBytes(actualInput));
VerbatimMultiPartHttpHandler.cs (2)
78using var reader = new StreamReader(stream, Encoding.UTF8); 143return new() { Content = new StringContent(sentJsonOutput, Encoding.UTF8, "application/json") };
Microsoft.Extensions.AI.OpenAI (4)
src\Shared\ServerSentEvents\Helpers.cs (3)
65int maxByteCount = Encoding.UTF8.GetMaxByteCount(value.Length); 75bytesWritten = Encoding.UTF8.GetBytes(chars, value.Length, bytes, maxByteCount); 122Encoding.UTF8.GetString(ptr, bytes.Length);
src\Shared\ServerSentEvents\SseParser.cs (1)
27/// that decodes the data of each event using <see cref="Encoding.UTF8"/>'s GetString method.
Microsoft.Extensions.Caching.Abstractions (4)
DistributedCacheExtensions.cs (4)
75cache.Set(key, Encoding.UTF8.GetBytes(value), options); 107return cache.SetAsync(key, Encoding.UTF8.GetBytes(value), options, token); 123return Encoding.UTF8.GetString(data, 0, data.Length); 140return Encoding.UTF8.GetString(data, 0, data.Length);
Microsoft.Extensions.Caching.Hybrid (4)
Internal\InbuiltTypeSerializer.cs (4)
39return Encoding.UTF8.GetString(segment.Array, segment.Offset, segment.Count); 45string s = Encoding.UTF8.GetString(oversized, 0, length); 56int length = Encoding.UTF8.GetByteCount(value); 58int actual = Encoding.UTF8.GetBytes(value, 0, value.Length, oversized, 0);
Microsoft.Extensions.Caching.Hybrid.Tests (1)
SerializerTests.cs (1)
294return Encoding.UTF8.GetString(value.ToArray());
Microsoft.Extensions.Caching.SqlServer.Tests (20)
SqlServerCacheWithDatabaseTest.cs (20)
77var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 99var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 126var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 166var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 208var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 235Encoding.UTF8.GetBytes("Hello, World!"), 259var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 291var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 318Encoding.UTF8.GetBytes("Hello, World!"), 341Encoding.UTF8.GetBytes("Hello, World!"), 364var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 393var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 420var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 489var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 521var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 577var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 606var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 636Encoding.UTF8.GetBytes("Hello, World!"), 653var expectedValue = Encoding.UTF8.GetBytes("Hello, World!"); 676Encoding.UTF8.GetBytes("Hello, World!"),
Microsoft.Extensions.Caching.StackExchangeRedis (1)
RedisCache.cs (1)
109_instancePrefix = (RedisKey)Encoding.UTF8.GetBytes(instanceName);
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (1)
RedisCacheSetAndRemoveTests.cs (1)
176static string Hex(string value) => Hex(Encoding.UTF8.GetBytes(value));
Microsoft.Extensions.Configuration.KeyPerFile.Tests (1)
KeyPerFileTests.cs (1)
544: new MemoryStream(Encoding.UTF8.GetBytes(_contents));
Microsoft.Extensions.FileProviders.Embedded.Tests (1)
TestAssembly.cs (1)
19using (var writer = new StreamWriter(ManifestStream, Encoding.UTF8, 1024, leaveOpen: true))
Microsoft.Extensions.Hosting.Systemd (2)
ServiceState.cs (2)
34_data = Encoding.UTF8.GetBytes(state); 42=> _data == null ? string.Empty : Encoding.UTF8.GetString(_data);
Microsoft.Extensions.Http.Diagnostics (2)
Logging\Internal\HttpRequestBodyReader.cs (1)
103return Encoding.UTF8.GetString(memory[..charsWritten].Span);
Logging\Internal\HttpResponseBodyReader.cs (1)
160return Encoding.UTF8.GetString(memory[..bytesRead].Span);
Microsoft.Extensions.Http.Diagnostics.Tests (49)
Logging\AcceptanceTests.cs (3)
204return Encoding.UTF8.GetString(buffer); 256var responseString = Encoding.UTF8.GetString(buffer); 278responseString = Encoding.UTF8.GetString(buffer);
Logging\HttpClientLoggerTest.cs (19)
87Content = new StringContent(input, Encoding.UTF8, TextPlain) 125Content = new StringContent(input, Encoding.UTF8, TextPlain) 187Content = new StringContent(requestContent, Encoding.UTF8, TextPlain) 196Content = new StringContent(responseContent, Encoding.UTF8, TextPlain), 283Content = new StringContent(requestContent, Encoding.UTF8, TextPlain) 290Content = new StringContent(responseContent, Encoding.UTF8, TextPlain), 388Content = new StringContent(requestContent, Encoding.UTF8, TextPlain) 396Content = new StringContent(responseContent, Encoding.UTF8, TextPlain), 484Content = new StringContent(requestContent, Encoding.UTF8, TextPlain) 492Content = new StringContent(responseContent, Encoding.UTF8, TextPlain), 599Content = new StringContent(requestContent, Encoding.UTF8, TextPlain) 606Content = new StringContent(responseContent, Encoding.UTF8, TextPlain), 691Content = new StringContent(_fixture.Create<string>(), Encoding.UTF8, TextPlain) 734Content = new StringContent(_fixture.Create<string>(), Encoding.UTF8, TextPlain) 772Content = new StringContent(_fixture.Create<string>(), Encoding.UTF8, TextPlain) 816Content = new StringContent(_fixture.Create<string>(), Encoding.UTF8, TextPlain) 859using var requestContent = new StreamContent(new NotSeekableStream(new(Encoding.UTF8.GetBytes(requestInput)))); 870using var responseContent = new StreamContent(new NotSeekableStream(new(Encoding.UTF8.GetBytes(responseInput)))); 961Content = new StringContent("request_content", Encoding.UTF8, TextPlain)
Logging\HttpRequestBodyReaderTest.cs (6)
41Content = new StringContent(input, Encoding.UTF8, "text/plain"), 85Content = new StringContent(input, Encoding.UTF8, contentType), 106Content = new StringContent(input, Encoding.UTF8, "text/plain"), 134Content = new StringContent(input, Encoding.UTF8, "text/plain"), 158Content = new StringContent(input, Encoding.UTF8, "text/plain"), 232Content = new StringContent("content", Encoding.UTF8, "text/plain"),
Logging\HttpRequestReaderTest.cs (15)
84Content = new StringContent(requestContent, Encoding.UTF8) 93Content = new StringContent(responseContent, Encoding.UTF8) 147Content = new StringContent(requestContent, Encoding.UTF8) 153Content = new StringContent(responseContent, Encoding.UTF8) 210Content = new StringContent(requestContent, Encoding.UTF8), 222Content = new StringContent(responseContent, Encoding.UTF8) 285Content = new StringContent(requestContent, Encoding.UTF8), 297Content = new StringContent(responseContent, Encoding.UTF8) 357Content = new StringContent(requestContent, Encoding.UTF8), 415Content = new StringContent(requestContent, Encoding.UTF8), 427Content = new StringContent(responseContent, Encoding.UTF8) 486Content = new StringContent(requestContent, Encoding.UTF8), 494Content = new StringContent(responseContent, Encoding.UTF8) 553Content = new StringContent(requestContent, Encoding.UTF8), 562Content = new StringContent(responseContent, Encoding.UTF8)
Logging\HttpResponseBodyReaderTest.cs (6)
50Content = new StringContent(expectedContentBody, Encoding.UTF8, TextPlain) 86Content = new StringContent(string.Empty, Encoding.UTF8, TextPlain) 111Content = new StringContent(expectedContentBody, Encoding.UTF8, contentType) 131Content = new StringContent(input, Encoding.UTF8, TextPlain) 155Content = new StreamContent(new NotSeekableStream(new(Encoding.UTF8.GetBytes(bigContent)))) 182Content = new StreamContent(new NotSeekableStream(new(Encoding.UTF8.GetBytes(bigContent))))
Microsoft.Extensions.Http.Resilience.Tests (1)
Resilience\RequestMessageSnapshotTests.cs (1)
60Content = new StringContent("{\"name\":\"John Doe\",\"age\":33}", Encoding.UTF8, "application/json")
Microsoft.Extensions.Logging.Console (2)
JsonConsoleFormatter.cs (2)
106var logMessageBuffer = ArrayPool<char>.Shared.Rent(Encoding.UTF8.GetMaxCharCount(messageBytes.Length)); 110var charsWritten = Encoding.UTF8.GetChars(messageBytes, logMessageBuffer);
Microsoft.Extensions.Logging.EventSource (1)
EventSourceLogger.cs (1)
275return Encoding.UTF8.GetString(buffer.Array!, buffer.Offset, buffer.Count);
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Roslyn3.11.cs (1)
39context.AddSource("LoggerMessage.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Extensions.Options.SourceGeneration (1)
Generator.cs (1)
56context.AddSource("Validators.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Extensions.SecretManager.Tools.Tests (5)
SecretManagerTests.cs (4)
219File.WriteAllText(secretsFile, @"{ ""AzureAd"": { ""ClientSecret"": ""abcd郩˙î""} }", Encoding.UTF8); 232File.WriteAllText(secretsFile, @"{ ""AzureAd"": { ""ClientSecret"": ""abcd郩˙î""} }", Encoding.UTF8); 248File.WriteAllText(secretsFile, @"{ ""AzureAd"": { ""ClientSecret"": ""abcd郩˙î""} }", Encoding.UTF8); 254var fileContents = File.ReadAllText(secretsFile, Encoding.UTF8);
TemporaryFileProvider.cs (1)
21File.WriteAllText(Path.Combine(Root, filename), contents, Encoding.UTF8);
Microsoft.Extensions.ServiceDiscovery.Dns.Tests (1)
Resolver\LoopbackDnsServer.cs (1)
228var encodedLabels = name.Split('.', StringSplitOptions.RemoveEmptyEntries).Select(label => (ReadOnlyMemory<byte>)Encoding.UTF8.GetBytes(s_idnMapping.GetAscii(label)))
Microsoft.Extensions.ServiceDiscovery.Dns.Tests.Fuzzing (1)
Fuzzers\WriteDomainNameRoundTripFuzzer.cs (1)
20string domainName = Encoding.UTF8.GetString(data);
Microsoft.Extensions.Telemetry.Tests (1)
Latency\Internal\LatencyConsoleExporterTests.cs (1)
160public override Encoding Encoding => Encoding.UTF8;
Microsoft.Extensions.Validation.GeneratorTests (2)
ValidationsGeneratorTestBase.cs (2)
142var encoding = text.Encoding ?? Encoding.UTF8; 582var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(requestData));
Microsoft.Extensions.Validation.ValidationsGenerator (1)
Emitters\ValidationsGenerator.Emitter.cs (1)
26context.AddSource("ValidatableInfoResolver.g.cs", SourceText.From(source, Encoding.UTF8));
Microsoft.Gen.ComplianceReports (1)
ComplianceReportsGenerator.cs (1)
112File.WriteAllText(Path.Combine(_directory, _fileName), report, Encoding.UTF8);
Microsoft.Gen.Logging (1)
LoggingGenerator.cs (1)
49context.AddSource("Logging.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.MetadataExtractor (3)
MetadataReportsGenerator.cs (1)
110File.WriteAllText(Path.Combine(path, _fileName), reportStringBuilder.ToString(), Encoding.UTF8);
src\Generators\Microsoft.Gen.ComplianceReports\ComplianceReportsGenerator.cs (1)
112File.WriteAllText(Path.Combine(_directory, _fileName), report, Encoding.UTF8);
src\Generators\Microsoft.Gen.MetricsReports\MetricsReportsGenerator.cs (1)
86File.WriteAllText(Path.Combine(path, _fileName), report, Encoding.UTF8);
Microsoft.Gen.Metrics (2)
MetricsGenerator.cs (2)
40context.AddSource("Factory.g.cs", SourceText.From(factory, Encoding.UTF8)); 44context.AddSource("Metrics.g.cs", SourceText.From(metrics, Encoding.UTF8));
Microsoft.Gen.MetricsReports (1)
MetricsReportsGenerator.cs (1)
86File.WriteAllText(Path.Combine(path, _fileName), report, Encoding.UTF8);
Microsoft.JSInterop (3)
Infrastructure\DotNetDispatcher.cs (3)
222var count = Encoding.UTF8.GetByteCount(arguments); 226var receivedBytes = Encoding.UTF8.GetBytes(arguments, buffer); 308var utf8JsonBytes = Encoding.UTF8.GetBytes(arguments);
Microsoft.JSInterop.Tests (8)
JSRuntimeTest.cs (8)
59var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes("null")); 114var bytes = Encoding.UTF8.GetBytes("\"my result\""); 136var bytes = Encoding.UTF8.GetBytes("{\"id\":10, \"name\": \"Test\"}"); 160var bytes = Encoding.UTF8.GetBytes("{\"Id\":10, \"Name\": \"Test\"}"); 189var bytes = Encoding.UTF8.GetBytes("\"This is a test exception\""); 217var bytes = Encoding.UTF8.GetBytes("Not a string"); 245var firstReader = new Utf8JsonReader(Encoding.UTF8.GetBytes("\"Some data\"")); 246var secondReader = new Utf8JsonReader(Encoding.UTF8.GetBytes("\"Exception\""));
Microsoft.Maui (2)
Handlers\HybridWebView\HybridWebViewHandler.cs (1)
193 var contentBytes = Encoding.UTF8.GetBytes(json);
Services\Crc64HashAlgorithm.cs (1)
198 byte[] bytes = ComputeHash(Encoding.UTF8.GetBytes(input));
Microsoft.Maui.Controls (1)
Internals\ImageParser.cs (1)
476 string identifier = global::System.Text.Encoding.UTF8.GetString(buffer, 0, NetscapeApplicationExtensionID.Length);
Microsoft.Maui.Controls.SourceGen (4)
CodeBehindGenerator.cs (3)
295 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 377 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 640 sourceProductionContext.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8));
src\Core\src\Services\Crc64HashAlgorithm.cs (1)
198 byte[] bytes = ComputeHash(Encoding.UTF8.GetBytes(input));
Microsoft.Maui.Graphics (2)
Text\XmlAttributedTextReader.cs (1)
99 string text = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
Text\XmlAttributedTextWriter.cs (1)
32 byte[] bytes = Encoding.UTF8.GetBytes(attributedText.Text);
Microsoft.ML.AutoML.SourceGenerator (3)
EstimatorTypeGenerator.cs (1)
53context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorFactoryGenerator.cs (1)
48context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorGenerator.cs (1)
73context.AddSource(c.Item1 + ".cs", SourceText.From(c.Item2, Encoding.UTF8));
Microsoft.ML.AutoML.Tests (1)
TextFileSampleTests.cs (1)
28var eol = Encoding.UTF8.GetBytes("\r\n");
Microsoft.ML.Core (8)
Data\ModelLoadContext.cs (1)
87Reader = new BinaryReader(ent.Stream, Encoding.UTF8, leaveOpen: true);
Data\ModelLoading.cs (2)
194using (var reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true)) 337using (var reader = new BinaryReader(ent.Stream, Encoding.UTF8, leaveOpen: true))
Data\ModelSaveContext.cs (2)
100Writer = new BinaryWriter(_ent.Stream, Encoding.UTF8, leaveOpen: true); 180using (var writer = new BinaryWriter(ent.Stream, Encoding.UTF8, leaveOpen: true))
Data\ModelSaving.cs (1)
50using (var writer = new BinaryWriter(ent.Stream, Encoding.UTF8, leaveOpen: true))
Utilities\TextReaderStream.cs (2)
58/// Create a stream wrapping the given text reader, using the <see cref="Encoding.UTF8"/> 63: this(baseReader, Encoding.UTF8)
Microsoft.ML.Data (9)
Commands\SavePredictorCommand.cs (1)
153using (var writer = new BinaryWriter(binaryModelStream, Encoding.UTF8, true))
DataLoadSave\Binary\BinaryLoader.cs (2)
778_reader = new BinaryReader(_stream, Encoding.UTF8, leaveOpen); 868_reader = new BinaryReader(_stream, Encoding.UTF8, leaveOpen: false);
DataLoadSave\Binary\BinarySaver.cs (3)
326int stringLen = Encoding.UTF8.GetByteCount(metadataInfos[i].Item1); 470using (BinaryWriter writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true)) 517int nameLen = Encoding.UTF8.GetByteCount(name);
DataLoadSave\Binary\CodecFactory.cs (2)
43_encoding = Encoding.UTF8; 159using (BinaryReader reader = new BinaryReader(definitionStream, Encoding.UTF8, true))
DataLoadSave\Transpose\TransposeSaver.cs (1)
156using (var writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true))
Microsoft.ML.OnnxConverter (4)
OnnxUtils.cs (4)
262private static ByteString StringToByteString(ReadOnlyMemory<char> str) => ByteString.CopyFrom(Encoding.UTF8.GetBytes(str.ToString())); 264=> str.Select(s => ByteString.CopyFrom(Encoding.UTF8.GetBytes(s.ToString()))); 267=> str.Select(s => ByteString.CopyFrom(Encoding.UTF8.GetBytes(s))); 269private static ByteString StringToByteString(string str) => ByteString.CopyFrom(Encoding.UTF8.GetBytes(str));
Microsoft.ML.OnnxTransformer (1)
OnnxTransform.cs (1)
600dstEditor.Values[i] = slotsAttr.Strings[i].ToString(Encoding.UTF8).AsMemory();
Microsoft.ML.TestFramework (1)
BytesStreamSource.cs (1)
28: this(Encoding.UTF8.GetBytes(data))
Microsoft.ML.Tokenizers (38)
Model\BPETokenizer.cs (3)
1319int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(text.Length); 1432int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(text.Length); 1512int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(text.Length);
Model\CodeGenTokenizer.cs (5)
452int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(textSpan.Length); 1135int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(textSpan.Length); 1199int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(textSpan.Length); 1291int bytesCountToEncode = Encoding.UTF8.GetMaxByteCount(specialToken.Length); 1313string result = Encoding.UTF8.GetString(bytes, 0, bytesIndex);
Model\SentencePieceBaseModel.cs (2)
280int len = Encoding.UTF8.GetMaxCharCount(bytesCount); 618int len = Encoding.UTF8.GetMaxCharCount(bytesCount);
Model\SentencePieceBpeModel.cs (4)
228int len = Encoding.UTF8.GetMaxByteCount(text.Length - i); 528int len = Encoding.UTF8.GetMaxByteCount(text.Length - i); 791int len = Encoding.UTF8.GetMaxByteCount(text.Length - i); 1067int len = Encoding.UTF8.GetMaxByteCount(text.Length - i);
Model\SentencePieceUnigramModel.cs (2)
196if (Encoding.UTF8.GetMaxCharCount(normalizationSpan.Length) > normalizedUtf16Span.Length) 294Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) * 3 <= buffer.Length * sizeof(int));
Model\TiktokenTokenizer.cs (7)
143_decoder![specialToken.Value] = Encoding.UTF8.GetBytes(specialToken.Key); 243string decodedToken = Encoding.UTF8.GetString(tokenBytes); 323int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 440int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 605int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 731int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 899if (Encoding.UTF8.GetMaxCharCount(utf8BytesIncompleteCount + tokenBytes.Length) > tempBuffer.Length)
SentencepieceModel.cs (5)
1399private readonly static string UnkPieceDefaultValue = global::System.Text.Encoding.UTF8.GetString(global::System.Convert.FromBase64String("PHVuaz4="), 0, 5); 1425private readonly static string BosPieceDefaultValue = global::System.Text.Encoding.UTF8.GetString(global::System.Convert.FromBase64String("PHM+"), 0, 3); 1451private readonly static string EosPieceDefaultValue = global::System.Text.Encoding.UTF8.GetString(global::System.Convert.FromBase64String("PC9zPg=="), 0, 4); 1477private readonly static string PadPieceDefaultValue = global::System.Text.Encoding.UTF8.GetString(global::System.Convert.FromBase64String("PHBhZD4="), 0, 5); 1503private readonly static string UnkSurfaceDefaultValue = global::System.Text.Encoding.UTF8.GetString(global::System.Convert.FromBase64String("IOKBhyA="), 0, 5);
Utils\DoubleArrayTrie.cs (1)
746int encodingLength = Encoding.UTF8.GetByteCount(pair.Key);
Utils\Helpers.cs (2)
70Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 162Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length);
Utils\Helpers.netstandard.cs (5)
76return Encoding.UTF8.GetBytes(sourcePtr, source.Length, destPtr, destination.Length); 85if (Encoding.UTF8.GetByteCount(sourcePtr, source.Length) <= destination.Length) 87bytesWritten = Encoding.UTF8.GetBytes(sourcePtr, source.Length, destPtr, destination.Length); 100return Encoding.UTF8.GetString(sourcePtr, utf8Bytes.Length); 109return Encoding.UTF8.GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length);
Utils\OrdinalUtf8StringComparer.cs (2)
58int requiredLength1 = Encoding.UTF8.GetMaxByteCount(xLen); 59int requiredLength2 = Encoding.UTF8.GetMaxByteCount(yLen);
Microsoft.ML.Tokenizers.Tests (13)
BpeTests.cs (2)
579File.WriteAllText(fileName, JsonSerializer.Serialize<Dictionary<string, int>>(dic), Encoding.UTF8); 879using var reader = new StreamReader(jsonModelStream, Encoding.UTF8);
DoubleArrayTrieTest.cs (2)
79byte[] utf8Bytes = Encoding.UTF8.GetBytes(key); 94byte[] utf8Bytes = Encoding.UTF8.GetBytes(key);
src\Microsoft.ML.Tokenizers\Utils\DoubleArrayTrie.cs (1)
746int encodingLength = Encoding.UTF8.GetByteCount(pair.Key);
src\Microsoft.ML.Tokenizers\Utils\Helpers.cs (2)
70Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 162Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length);
src\Microsoft.ML.Tokenizers\Utils\Helpers.netcoreapp.cs (4)
56=> Encoding.UTF8.GetBytes(source, destination); 59=> Encoding.UTF8.TryGetBytes(source, destination, out bytesWritten); 62=> Encoding.UTF8.GetString(utf8Bytes); 65=> Encoding.UTF8.GetChars(bytes, chars);
src\Microsoft.ML.Tokenizers\Utils\OrdinalUtf8StringComparer.cs (2)
58int requiredLength1 = Encoding.UTF8.GetMaxByteCount(xLen); 59int requiredLength2 = Encoding.UTF8.GetMaxByteCount(yLen);
Microsoft.Net.Http.Headers (3)
ContentDispositionHeaderValue.cs (3)
547Base64.GetMaxEncodedToUtf8Length(Encoding.UTF8.GetByteCount(input.AsSpan())) + 557var contentLength = Encoding.UTF8.GetBytes(input.AsSpan(), bufferContent); 563var result = Encoding.UTF8.GetString(buffer.Slice(0, MimePrefix.Length + base64ContentLength + MimeSuffix.Length));
Microsoft.VisualBasic.Core (3)
Microsoft\VisualBasic\FileIO\FileSystem.vb (3)
300Return OpenTextFileReader(file, Encoding.UTF8) 322Return OpenTextFileWriter(file, append, Encoding.UTF8) 773WriteAllText(file, text, append, Encoding.UTF8)
Microsoft.VisualBasic.Forms (1)
Microsoft\VisualBasic\Logging\FileLogTraceListener.vb (1)
50Private _encoding As Encoding = Encoding.UTF8
Microsoft.VisualBasic.Forms.Tests (3)
System\Windows\Forms\FileLogTraceListenerTests.vb (1)
68listener.Encoding.Should.Be(Encoding.UTF8)
System\Windows\Forms\FileSystemProxyTests.vb (2)
391_fileSystem.WriteAllText(fileA, "A", append:=False, Encoding.UTF8) 392Dim text As String = _fileSystem.ReadAllText(fileA, Encoding.UTF8)
Microsoft.VisualStudio.LanguageServices (3)
Implementation\AbstractEditorFactory.cs (1)
370using var textWriter = new StreamWriter(filePath, append: false, encoding: formattedText.Encoding ?? Encoding.UTF8);
ProjectSystem\VisualStudioWorkspaceImpl.cs (2)
955using var writer = new StreamWriter(documentInfo.FilePath, append: false, encoding: text.Encoding ?? Encoding.UTF8); 999using var writer = new StreamWriter(filePath, append: false, encoding: initialText.Encoding ?? Encoding.UTF8);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
PersistentStorage\AbstractPersistentStorageTests.cs (1)
41private readonly Encoding _encoding = Encoding.UTF8;
PlaintextApp (1)
Startup.cs (1)
19private static readonly byte[] _helloWorldBytes = Encoding.UTF8.GetBytes("Hello, World!");
PresentationBuildTasks (1)
Microsoft\Build\Tasks\Windows\UpdateManifestForBrowserApplication.cs (1)
111manifestWriter = new XmlTextWriter(appManifestFile, System.Text.Encoding.UTF8)
PresentationFramework (3)
MS\Internal\WindowsRuntime\Generated\WinRT\GuidGenerator.cs (1)
137var data = wrt_pinterface_namespace.ToByteArray().Concat(UTF8Encoding.UTF8.GetBytes(sig)).ToArray();
System\Windows\Controls\DataGridClipboardHelper.cs (1)
80byte[] destinationBytes = InternalEncoding.Convert(Encoding.Unicode, Encoding.UTF8, sourceBytes);
System\Windows\Documents\FixedSchema.cs (1)
43!encoding.Equals(Encoding.UTF8.WebName, StringComparison.OrdinalIgnoreCase))
RazorBuildWebSite (1)
UpdateableFileProvider.cs (1)
102return new MemoryStream(Encoding.UTF8.GetBytes(_content));
ReachFramework (7)
AlphaFlattener\Flattener.cs (1)
457XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8)
Packaging\PartEditor.cs (1)
251_xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
Packaging\XpsFixedDocumentReaderWriter.cs (1)
1122using (XmlTextWriter writer = new XmlTextWriter(stream, System.Text.Encoding.UTF8))
PrintConfig\PrintCapabilitesWriter.cs (2)
31Encoding = Encoding.UTF8, 37this._writer = XmlWriter.Create(new StreamWriter(stream, Encoding.UTF8), settings);
PrintConfig\PrtTicket_Public_Simple.cs (1)
1403return System.Text.Encoding.UTF8.GetString(ms.ToArray());
Serialization\Manager\XpsOMPackagingPolicy.cs (1)
252_currentFixedPageXmlWriter = new XmlTextWriter(_currentFixedPagePrintStream, Encoding.UTF8);
Replay (2)
src\Compilers\Shared\BuildServerConnection.cs (1)
575var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(pipeNameInput));
src\Compilers\Shared\CompilerServerLogger.cs (1)
157byte[] bytes = Encoding.UTF8.GetBytes(output);
Roslyn.Diagnostics.Analyzers (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Roslyn.Test.PdbUtilities (4)
Reader\PdbValidation.cs (1)
589Assert.Equal(Encoding.UTF8.GetByteCount(pdbPath) + 1, paddedPathLength);
Reader\Token2SourceLineExporter.cs (3)
257value = Encoding.UTF8.GetString(_buffer, _offset, len); 268value = Encoding.UTF8.GetString(_buffer, _offset, len); 1132Encoding = Encoding.UTF8,
Roslyn.VisualStudio.Next.UnitTests (9)
Remote\SnapshotSerializationTests.cs (2)
607var sourceText = SourceText.From("Hello", Encoding.UTF8); 748private readonly Encoding _real = Encoding.UTF8;
Services\ServiceHubServicesTests.cs (7)
512=> SourceText.From(content, encoding ?? Encoding.UTF8, checksumAlgorithm); 601[("SG.cs", CreateText("X", Encoding.UTF8))]); 608[("SG.cs", CreateText("X", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha1))], 609[("SG.cs", CreateText("X", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256))]); 735return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 819return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 874return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8)));
RoutingSandbox (4)
HelloExtension\HelloMiddleware.cs (2)
21payload.AddRange(Encoding.UTF8.GetBytes("Hello")); 25payload.AddRange(Encoding.UTF8.GetBytes(_helloOptions.Greeter));
UseEndpointRoutingStartup.cs (2)
12private static readonly byte[] _plainTextPayload = Encoding.UTF8.GetBytes("Plain text!"); 68using (var writer = new StreamWriter(httpContext.Response.Body, Encoding.UTF8, 1024, leaveOpen: true))
RoutingWebSite (3)
HelloExtension\HelloMiddleware.cs (2)
21payload.AddRange(Encoding.UTF8.GetBytes("Hello")); 25payload.AddRange(Encoding.UTF8.GetBytes(_helloOptions.Greeter));
UseEndpointRoutingStartup.cs (1)
10private static readonly byte[] _plainTextPayload = Encoding.UTF8.GetBytes("Plain text!");
Security.TransportSecurity.IntegrationTests (8)
Https\HttpsTests.4.1.0.cs (6)
82CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement()); 160CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement()); 199CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8), new HttpsTransportBindingElement()); 240CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement()); 286CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement()); 327CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement());
Tcp\StreamingTests.4.1.0.cs (2)
411var reader = new StreamReader(stream, Encoding.UTF8); 418var sw = new StreamWriter(ms, Encoding.UTF8);
SecurityWebSite (1)
BearerAuth.cs (1)
15Key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128)));
SemanticSearch.BuildTask (2)
GenerateFilteredReferenceAssembliesTask.cs (2)
167oldContent = File.ReadAllText(outputFilePath, Encoding.UTF8); 191File.WriteAllText(outputFilePath, newContent, Encoding.UTF8);
ServiceBusWorker (1)
Consumer.cs (1)
20logger.LogInformation("Received message: {Message}", Encoding.UTF8.GetString(args.Message.Body));
Shared (4)
ServerSentEvents\Helpers.cs (3)
65int maxByteCount = Encoding.UTF8.GetMaxByteCount(value.Length); 70bytesWritten = Encoding.UTF8.GetBytes(value, buffer); 116return Encoding.UTF8.GetString(bytes);
ServerSentEvents\SseParser.cs (1)
27/// that decodes the data of each event using <see cref="Encoding.UTF8"/>'s GetString method.
SignalRSamples (3)
ConnectionHandlers\MessagesConnectionHandler.cs (3)
35var text = Encoding.UTF8.GetString(buffer.ToArray()); 37await Broadcast(Encoding.UTF8.GetBytes(text)); 60return Broadcast(Encoding.UTF8.GetBytes(text));
SocialWeather (2)
Pipe\PipeWeatherStreamFormatter.cs (2)
55var utf8 = Encoding.UTF8; 57var convertedBytes = Encoding.Convert(Encoding.UTF8, Encoding.ASCII, encodedBytes);
System.CodeDom (7)
Microsoft\CSharp\CSharpCodeGenerator.cs (2)
3024using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) 3059using (var sw = new StreamWriter(fs, Encoding.UTF8))
System\CodeDom\Compiler\CodeCompiler.cs (3)
148using (var sw = new StreamWriter(fs, Encoding.UTF8)) 189using (var sw = new StreamWriter(fs, Encoding.UTF8)) 209using (var sw = new StreamWriter(fs, Encoding.UTF8))
System\CodeDom\Compiler\Executor.cs (2)
50using (var outputWriter = new StreamWriter(CreateInheritedFile(outputName), Encoding.UTF8)) 51using (var errorWriter = new StreamWriter(CreateInheritedFile(errorName), Encoding.UTF8))
System.ComponentModel.TypeConverter (2)
System\ComponentModel\Design\DesigntimeLicenseContextSerializer.cs (2)
40using (BinaryWriter writer = new BinaryWriter(o, encoding: Text.Encoding.UTF8, leaveOpen: true)) 172using (BinaryReader reader = new BinaryReader(wrappedStream, encoding: Text.Encoding.UTF8, leaveOpen: true))
System.Configuration.ConfigurationManager (2)
System\Configuration\BaseConfigurationRecord.cs (1)
3705StreamEncoding = Encoding.UTF8;
System\Configuration\ImplicitMachineConfigHost.cs (1)
68stream = new MemoryStream(Encoding.UTF8.GetBytes(ImplicitMachineConfig));
System.Console (3)
System\ConsolePal.Unix.cs (3)
1125data = stackalloc byte[Encoding.UTF8.GetMaxByteCount(value.Length)]; 1126int bytesToWrite = Encoding.UTF8.GetBytes(value, data); 1131data = Encoding.UTF8.GetBytes(value);
System.Diagnostics.Process (7)
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcFsStat.TryReadStatusFile.cs (1)
155contents = Encoding.UTF8.GetString(bytes, 0, count);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ForkAndExecProcess.cs (2)
67int byteLength = Encoding.UTF8.GetByteCount(str); 70int bytesWritten = Encoding.UTF8.GetBytes(str, new Span<byte>(arrPtr[i], byteLength));
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (1)
57return Encoding.UTF8.GetString(spanBuffer.Slice(0, resultLength));
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
26int maxSize = checked(Encoding.UTF8.GetMaxByteCount(value.Length) + 1); 35int byteCount = Encoding.UTF8.GetBytes(value, _bytes);
System\Diagnostics\Process.Linux.cs (1)
349string argString = Encoding.UTF8.GetString(arg.Slice(nameStart));
System.Formats.Tar (15)
System\Formats\Tar\TarHeader.Read.cs (2)
750key = Encoding.UTF8.GetString(keySlice); 751value = Encoding.UTF8.GetString(valueSlice);
System\Formats\Tar\TarHeader.Write.cs (12)
362private bool IsLinkNameTooLongForRegularField() => _linkName != null && (Encoding.UTF8.GetByteCount(_linkName) + 1) > FieldLengths.LinkName; 366private bool IsNameTooLongForRegularField() => (Encoding.UTF8.GetByteCount(_name)) > FieldLengths.Name; 442data.Write(Encoding.UTF8.GetBytes(text)); 592int encoded = Encoding.UTF8.GetBytes(_name, encodingBuffer); 885int length = 3 + Encoding.UTF8.GetByteCount(attribute) + Encoding.UTF8.GetByteCount(value); 893Debug.Assert(length == CountDigits(length) + 3 + Encoding.UTF8.GetByteCount(attribute) + Encoding.UTF8.GetByteCount(value)); 909bytesWritten += Encoding.UTF8.GetBytes(attribute, span.Slice(bytesWritten)); 911bytesWritten += Encoding.UTF8.GetBytes(value, span.Slice(bytesWritten)); 1184int encoded = Encoding.UTF8.GetBytes(text, buffer); 1226=> Encoding.UTF8.GetByteCount(text);
System\Formats\Tar\TarHelpers.cs (1)
307internal static string GetTrimmedUtf8String(ReadOnlySpan<byte> buffer) => GetTrimmedString(buffer, Encoding.UTF8);
System.IO.Compression (4)
System\IO\Compression\ZipArchive.cs (1)
211get => (EntryNameAndCommentEncoding ?? Encoding.UTF8).GetString(_archiveComment);
System\IO\Compression\ZipArchiveEntry.cs (2)
380? Encoding.UTF8 381: _archive?.EntryNameAndCommentEncoding ?? Encoding.UTF8;
System\IO\Compression\ZipHelper.cs (1)
29return Encoding.UTF8;
System.IO.FileSystem.Watcher (1)
System\IO\FileSystemWatcher.Linux.cs (1)
879Encoding.UTF8.GetString(_buffer, position, lengthWithoutNullTerm) :
System.IO.MemoryMappedFiles (2)
System\IO\MemoryMappedFiles\MemoryMappedFile.Unix.cs (2)
211Debug.Fail($"shm_open failed with ENAMETOOLONG for {Encoding.UTF8.GetByteCount(mapName)} byte long name."); 269Debug.Assert(Encoding.UTF8.GetByteCount(span) <= MaxNameLength); // the standard uses Utf8
System.IO.Packaging (3)
System\IO\Packaging\InternalRelationshipCollection.cs (1)
461using (XmlWriter writer = XmlWriter.Create(s, new XmlWriterSettings { Encoding = System.Text.Encoding.UTF8 }))
System\IO\Packaging\PartBasedPackageProperties.cs (1)
687_xmlWriter = XmlWriter.Create(writerStream, new XmlWriterSettings { Encoding = System.Text.Encoding.UTF8 });
System\IO\Packaging\ZipPackage.cs (1)
911using (XmlWriter writer = XmlWriter.Create(s, new XmlWriterSettings { Encoding = System.Text.Encoding.UTF8 }))
System.Memory.Data (2)
System\BinaryData.cs (2)
144_bytes = Encoding.UTF8.GetBytes(data); 430return Encoding.UTF8.GetString(ptr, span.Length);
System.Net.Http (10)
System\Net\Http\Headers\ContentDispositionHeaderValue.cs (1)
439byte[] buffer = Encoding.UTF8.GetBytes(input);
System\Net\Http\Headers\HeaderUtilities.cs (2)
71byte[] utf8bytes = ArrayPool<byte>.Shared.Rent(Encoding.UTF8.GetMaxByteCount(input.Length)); 72int utf8length = Encoding.UTF8.GetBytes(input, 0, input.Length, utf8bytes, 0);
System\Net\Http\HttpContent.cs (3)
25internal static readonly Encoding DefaultStringEncoding = Encoding.UTF8; 41AssertEncodingConstants(Encoding.UTF8, UTF8CodePage, UTF8Preamble); 729encoding = Encoding.UTF8;
System\Net\Http\SocketsHttpHandler\AuthenticationHelper.cs (1)
182string base64AuthString = Convert.ToBase64String(Encoding.UTF8.GetBytes(authString));
System\Net\Http\SocketsHttpHandler\AuthenticationHelper.Digest.cs (1)
216byte[] dataBytes = Encoding.UTF8.GetBytes(data);
System\Net\Http\SocketsHttpHandler\SocksHelper.cs (2)
324return checked((byte)Encoding.UTF8.GetBytes(chars, buffer)); 328Debug.Assert(Encoding.UTF8.GetByteCount(chars) > 255);
System.Net.Http.Json (5)
System\Net\Http\Json\HttpContentJsonExtensions.cs (1)
136return JsonHelpers.GetEncoding(content) is Encoding sourceEncoding && sourceEncoding != Encoding.UTF8
System\Net\Http\Json\HttpContentJsonExtensions.netcoreapp.cs (1)
20return Encoding.CreateTranscodingStream(contentStream, innerStreamEncoding: sourceEncoding, outerStreamEncoding: Encoding.UTF8);
System\Net\Http\Json\JsonContent.cs (2)
117return targetEncoding != null && targetEncoding != Encoding.UTF8 126Stream transcodingStream = Encoding.CreateTranscodingStream(targetStream, targetEncoding, Encoding.UTF8, leaveOpen: true);
System\Net\Http\Json\JsonContent.netcoreapp.cs (1)
16if (JsonHelpers.GetEncoding(this) is Encoding targetEncoding && targetEncoding != Encoding.UTF8)
System.Net.HttpListener (4)
src\libraries\Common\src\System\Net\WebSockets\WebSocketValidate.cs (2)
85Encoding.UTF8.GetMaxByteCount(statusDescription.Length) > MaxControlFramePayloadLength && 86Encoding.UTF8.GetByteCount(statusDescription) > MaxControlFramePayloadLength)
System\Net\Managed\HttpListenerContext.Managed.cs (1)
69string authString = Encoding.UTF8.GetString(Convert.FromBase64String(headerValue));
System\Net\WebSockets\HttpWebSocket.cs (1)
22byte[] toHash = Encoding.UTF8.GetBytes(acceptString);
System.Net.Mail (6)
System\Net\BufferBuilder.cs (2)
77int byteCount = Encoding.UTF8.GetByteCount(value, offset, count); 79Encoding.UTF8.GetBytes(value, offset, count, _buffer, _offset);
System\Net\Mail\SmtpLoginAuthenticationModule.cs (2)
39return new Authorization(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(userName)), false); 45return new Authorization(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(cachedCredential.Password)), true);
System\Net\Mail\SmtpReplyReaderFactory.cs (1)
302builder.Append(Encoding.UTF8.GetString(_byteBuffer, start, actual));
System\Net\Mime\MimeBasePart.cs (1)
23encoding == Encoding.Unicode || encoding == Encoding.UTF8 || encoding == Encoding.UTF32 || encoding == Encoding.BigEndianUnicode;
System.Net.Ping (2)
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
26int maxSize = checked(Encoding.UTF8.GetMaxByteCount(value.Length) + 1); 35int byteCount = Encoding.UTF8.GetBytes(value, _bytes);
System.Net.Primitives (2)
src\libraries\Common\src\System\Net\NetworkInformation\InterfaceInfoPal.Unix.cs (2)
39bufferSize = Encoding.UTF8.GetByteCount(castInterfaceName) + 1; 60Encoding.UTF8.GetBytes(castInterfaceName, buffer);
System.Net.Requests (2)
System\Net\CommandStream.cs (1)
469private Encoding _encoding = Encoding.UTF8;
System\Net\FtpControlStream.cs (1)
287Encoding = Encoding.UTF8;
System.Net.Security (6)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSsl.cs (1)
622index += Encoding.UTF8.GetBytes(alg, buffer.AsSpan(index));
src\libraries\Common\src\Microsoft\Win32\SafeHandles\GssSafeHandles.cs (3)
22out minorStatus, name, Encoding.UTF8.GetByteCount(name), out retHandle); 39out minorStatus, name, Encoding.UTF8.GetByteCount(name), out retHandle); 120status = Interop.NetSecurityNative.InitiateCredWithPassword(out minorStatus, packageType, userHandle, password, Encoding.UTF8.GetByteCount(password), out retHandle);
System\Net\NegotiateAuthenticationPal.Unix.cs (1)
540return Encoding.UTF8.GetString(tokenBytes);
System\Net\Security\SslApplicationProtocol.cs (1)
12private static readonly Encoding s_utf8 = Encoding.GetEncoding(Encoding.UTF8.CodePage, EncoderFallback.ExceptionFallback, DecoderFallback.ExceptionFallback);
System.Net.ServerSentEvents (4)
System\Net\ServerSentEvents\Helpers.cs (2)
48int maxByteCount = Encoding.UTF8.GetMaxByteCount(value.Length); 53bytesWritten = Encoding.UTF8.GetBytes(value, buffer);
System\Net\ServerSentEvents\SseParser.cs (2)
26/// that decodes the data of each event using <see cref="Encoding.UTF8"/>'s GetString method. 56return Encoding.UTF8.GetString(bytes);
System.Net.Sockets (3)
System\Net\Sockets\UnixDomainSocketEndPoint.cs (3)
40int bufferLength = Encoding.UTF8.GetByteCount(path); 56int bytesEncoded = Encoding.UTF8.GetBytes(path, 0, path.Length, _encodedPath, 0); 89_path = Encoding.UTF8.GetString(_encodedPath, 0, length);
System.Net.WebClient (2)
System\Net\WebClient.cs (2)
510formHeaderBytes = Encoding.UTF8.GetBytes(formHeader); 1086private static readonly Encoding[] s_knownEncodings = { Encoding.UTF8, Encoding.UTF32, Encoding.Unicode, Encoding.BigEndianUnicode };
System.Net.WebSockets (2)
src\libraries\Common\src\System\Net\WebSockets\WebSocketValidate.cs (2)
85Encoding.UTF8.GetMaxByteCount(statusDescription.Length) > MaxControlFramePayloadLength && 86Encoding.UTF8.GetByteCount(statusDescription) > MaxControlFramePayloadLength)
System.Net.WebSockets.Client (2)
src\libraries\Common\src\System\Net\WebSockets\WebSocketValidate.cs (2)
85Encoding.UTF8.GetMaxByteCount(statusDescription.Length) > MaxControlFramePayloadLength && 86Encoding.UTF8.GetByteCount(statusDescription) > MaxControlFramePayloadLength)
System.Private.CoreLib (119)
src\libraries\Common\src\Internal\VersionResilientHashCode.cs (1)
31byte[] src = Encoding.UTF8.GetBytes(name);
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcFsStat.TryReadStatusFile.cs (1)
155contents = Encoding.UTF8.GetString(bytes, 0, count);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadDir.cs (2)
43ReadOnlySpan<char> result = !Encoding.UTF8.TryGetChars(nameBytes, buffer, out int charsWritten) 44? Encoding.UTF8.GetString(nameBytes) // Fallback to allocation since this is a rare case
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (1)
57return Encoding.UTF8.GetString(spanBuffer.Slice(0, resultLength));
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
26int maxSize = checked(Encoding.UTF8.GetMaxByteCount(value.Length) + 1); 35int byteCount = Encoding.UTF8.GetBytes(value, _bytes);
src\libraries\System.Private.CoreLib\src\Internal\Console.Unix.cs (2)
15byte[] bytes = Encoding.UTF8.GetBytes(s); 27byte[] bytes = Encoding.UTF8.GetBytes(s);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs (2)
1336string key = Text.Encoding.UTF8.GetString(data, dataStart, keyEnd - dataStart); 1337string value = Text.Encoding.UTF8.GetString(data, valueIdx, valueEnd - valueIdx);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs (2)
457return (manifestBytes == null) ? null : Encoding.UTF8.GetString(manifestBytes, 0, manifestBytes.Length); 5608return (str != "") ? Encoding.UTF8.GetBytes(str) : Array.Empty<byte>();
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\FieldMetadata.cs (2)
112this.nameSize = Encoding.UTF8.GetByteCount(this.name) + 1; 171Encoding.UTF8.GetBytes(this.name, 0, this.name.Length, metadata, pos);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\Statics.cs (2)
88int metadataSize = Encoding.UTF8.GetByteCount(name) + 3 + prefixSize + suffixSize; 93Encoding.UTF8.GetBytes(name, 0, name.Length, metadata, 2 + prefixSize);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\TraceLoggingEventSource.cs (2)
804metaData.AddRange(Encoding.UTF8.GetBytes(value.Substring(1))); 824metaData.AddRange(Encoding.UTF8.GetBytes(value));
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Utf8.cs (2)
83int sourceMaxCharCount = Encoding.UTF8.GetMaxCharCount(source.Length); 114int prefixMaxCharCount = Encoding.UTF8.GetMaxCharCount(prefix.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (2)
771Encoding.UTF8.GetBytes(s, Unsafe.BitCast<Span<TChar>, Span<byte>>(result.AppendSpan(Encoding.UTF8.GetByteCount(s))));
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormatInfo.cs (5)
373Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(amDesignatorUtf8 ??= Encoding.UTF8.GetBytes(AMDesignator)); 622Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(dateSeparatorUtf8 ??= Encoding.UTF8.GetBytes(DateSeparator)); 825Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(pmDesignatorUtf8 ??= Encoding.UTF8.GetBytes(PMDesignator)); 1007Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(timeSeparatorUtf8 ??= Encoding.UTF8.GetBytes(TimeSeparator)); 1707Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_decimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(DecimalSeparator));
src\libraries\System.Private.CoreLib\src\System\Globalization\NumberFormatInfo.cs (15)
273Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_currencyDecimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_currencyDecimalSeparator)); 365Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_currencyGroupSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_currencyGroupSeparator)); 387Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_currencySymbolUtf8 ??= Encoding.UTF8.GetBytes(_currencySymbol)); 390internal byte[]? CurrencySymbolUtf8 => _currencySymbolUtf8 ??= Encoding.UTF8.GetBytes(_currencySymbol); 433Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_nanSymbolUtf8 ??= Encoding.UTF8.GetBytes(_nanSymbol)); 518Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_negativeInfinitySymbolUtf8 ??= Encoding.UTF8.GetBytes(_negativeInfinitySymbol)); 541Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_negativeSignUtf8 ??= Encoding.UTF8.GetBytes(_negativeSign)); 577Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_numberDecimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_numberDecimalSeparator)); 598Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_numberGroupSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_numberGroupSeparator)); 635Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_positiveInfinitySymbolUtf8 ??= Encoding.UTF8.GetBytes(_positiveInfinitySymbol)); 658Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_positiveSignUtf8 ??= Encoding.UTF8.GetBytes(_positiveSign)); 694Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_percentDecimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_percentDecimalSeparator)); 715Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_percentGroupSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_percentGroupSeparator)); 736Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_percentSymbolUtf8 ??= Encoding.UTF8.GetBytes(_percentSymbol)); 758Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_perMilleSymbolUtf8 ??= Encoding.UTF8.GetBytes(_perMilleSymbol));
src\libraries\System.Private.CoreLib\src\System\IO\BinaryReader.cs (1)
31public BinaryReader(Stream input) : this(input, Encoding.UTF8, false)
src\libraries\System.Private.CoreLib\src\System\IO\BinaryWriter.cs (2)
32_encoding = Encoding.UTF8; 37public BinaryWriter(Stream output) : this(output, Encoding.UTF8, false)
src\libraries\System.Private.CoreLib\src\System\IO\Directory.Unix.cs (5)
32int tempPathByteCount = Encoding.UTF8.GetByteCount(tempPath); 33int prefixByteCount = prefix is not null ? Encoding.UTF8.GetByteCount(prefix) : 0; 37int pos = Encoding.UTF8.GetBytes(tempPath, path); 40pos += Encoding.UTF8.GetBytes(prefix, path.Slice(pos)); 56return Encoding.UTF8.GetString(path.Slice(0, path.Length - 1)); // trim off the trailing '\0'
src\libraries\System.Private.CoreLib\src\System\IO\File.cs (6)
625=> ReadAllText(path, Encoding.UTF8); 865=> ReadAllLines(path, Encoding.UTF8); 884=> ReadLines(path, Encoding.UTF8); 900=> ReadLinesAsync(path, Encoding.UTF8, cancellationToken); 1085=> ReadAllTextAsync(path, Encoding.UTF8, cancellationToken); 1293=> ReadAllLinesAsync(path, Encoding.UTF8, cancellationToken);
src\libraries\System.Private.CoreLib\src\System\IO\FileInfo.cs (1)
81=> new StreamReader(NormalizedPath, Encoding.UTF8, detectEncodingFromByteOrderMarks: true);
src\libraries\System.Private.CoreLib\src\System\IO\Path.Unix.cs (3)
103int tempPathByteCount = Encoding.UTF8.GetByteCount(tempPath); 107int pos = Encoding.UTF8.GetBytes(tempPath, path); 121return Encoding.UTF8.GetString(path.Slice(0, path.Length - 1)); // trim off the trailing '\0'
src\libraries\System.Private.CoreLib\src\System\IO\StreamReader.cs (5)
110: this(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks, DefaultBufferSize, false) 158_encoding = encoding ??= Encoding.UTF8; 186: this(path, Encoding.UTF8, detectEncodingFromByteOrderMarks, DefaultBufferSize) 206: this(path, Encoding.UTF8, true, options) 503_encoding = Encoding.UTF8;
src\libraries\System.Private.CoreLib\src\System\Net\WebUtility.cs (3)
345int byteCount = Encoding.UTF8.GetByteCount(value); 351Encoding.UTF8.GetBytes(state.value, utf8Bytes); 560return UrlDecodeInternal(encodedValue, Encoding.UTF8);
src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (1)
628return Encoding.UTF8.TryGetBytes(source, Unsafe.BitCast<Span<TChar>, Span<byte>>(destination), out charsWritten);
src\libraries\System.Private.CoreLib\src\System\Number.Parsing.cs (1)
1058SR.Format(SR.Format_InvalidStringWithValue, Encoding.UTF8.GetString(bytes)) :
src\libraries\System.Private.CoreLib\src\System\Numerics\INumberBase.cs (5)
310int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length); 444int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length); 490int destinationMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Destination.Length); 546int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length); 593int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length);
src\libraries\System.Private.CoreLib\src\System\Resources\ResourceReader.Core.cs (1)
34_store = new BinaryReader(stream, Encoding.UTF8);
src\libraries\System.Private.CoreLib\src\System\Resources\ResourceReader.cs (2)
101_store = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.RandomAccess), Encoding.UTF8); 133_store = new BinaryReader(stream, Encoding.UTF8);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshal.cs (6)
77return string.CreateStringFromEncoding((byte*)ptr, nbBytes, Encoding.UTF8); 85return string.CreateStringFromEncoding((byte*)ptr, byteLen, Encoding.UTF8); 970int nb = Encoding.UTF8.GetMaxByteCount(s.Length); 975int nbWritten = Encoding.UTF8.GetBytes(s, new Span<byte>(pbMem, nb)); 1011int nb = Encoding.UTF8.GetMaxByteCount(s.Length); 1016int nbWritten = Encoding.UTF8.GetBytes(s, new Span<byte>(pbMem, nb));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshal.Unix.cs (3)
39int convertedBytes = Encoding.UTF8.GetBytes(s, new Span<byte>(buffer, bufferLength)); 48int byteLength = Encoding.UTF8.GetByteCount(chars); 55int actualByteLength = Encoding.UTF8.GetBytes(chars, bytes);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\Utf8StringMarshaller.cs (4)
27int exactByteCount = checked(Encoding.UTF8.GetByteCount(managed) + 1); // + 1 for null terminator 31int byteCount = Encoding.UTF8.GetBytes(managed, buffer); 86int exactByteCount = checked(Encoding.UTF8.GetByteCount(managed) + 1); // + 1 for null terminator 97int byteCount = Encoding.UTF8.GetBytes(managed, buffer);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\TypeMapLazyDictionary.cs (4)
113? Encoding.UTF8.GetMaxCharCount(utf8TypeName.Length) 114: Encoding.UTF8.GetCharCount(utf8TypeName); 117int converted = Encoding.UTF8.GetChars(utf8TypeName, buffer); 131string externalTypeName = new((sbyte*)arg->Utf8String1, 0, arg->StringLen1, Encoding.UTF8);
src\libraries\System.Private.CoreLib\src\System\String.cs (1)
247return CreateStringFromEncoding(pb, numBytes, Encoding.UTF8);
src\libraries\System.Private.CoreLib\src\System\Text\Encoding.cs (1)
213case CodePageUTF8: return UTF8; // 65001
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8.cs (1)
574if (Encoding.UTF8.TryGetBytes(value, _destination.Slice(_pos), out int bytesWritten))
src\libraries\System.Private.CoreLib\src\System\Text\UTF8Encoding.Sealed.cs (1)
15/// of calls made directly off of <see cref="Encoding.UTF8"/>. See https://github.com/dotnet/coreclr/pull/9230.
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.cs (1)
1203Encoding enc = Encoding.UTF8;
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.NonAndroid.cs (1)
174using var reader = new StreamReader(fileName, Encoding.UTF8);
src\System\Reflection\Emit\CustomAttributeBuilder.cs (1)
354byte[] utf8Str = Encoding.UTF8.GetBytes(str);
src\System\Reflection\MdImport.cs (5)
264: Text.Encoding.UTF8.GetString(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(safeArrayUserDefinedSubTypeRaw)); 267: Text.Encoding.UTF8.GetString(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(marshalTypeRaw)); 270: Text.Encoding.UTF8.GetString(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(marshalCookieRaw)); 601importName = Text.Encoding.UTF8.GetString(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(importNameRaw)); 602importDll = Text.Encoding.UTF8.GetString(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(importDllRaw));
src\System\Reflection\RuntimeCustomAttributeData.cs (1)
1013return Encoding.UTF8.GetString(utf8ByteSpan);
src\System\RuntimeType.CoreCLR.cs (3)
342int cUtf8Name = Encoding.UTF8.GetByteCount(name); 358Encoding.UTF8.GetBytes(name, utf8Name); 4351=> Encoding.UTF8.GetString(new ReadOnlySpan<byte>(m_pStringHeap, m_StringHeapByteLength));
src\System\StubHelpers.cs (3)
167cbWritten = Encoding.UTF8.GetBytes(pwzChar, numChars, buffer, length); 209int nb = Encoding.UTF8.GetByteCount(strManaged); 213nb = strManaged.GetBytesFromEncoding(pbNativeBuffer, nb, Encoding.UTF8);
src\System\Text\StringBuilder.CoreCLR.cs (3)
46int numChars = Encoding.UTF8.GetCharCount(source); 52m_ChunkLength = Encoding.UTF8.GetChars(source, m_ChunkChars); 92convertedChars = Encoding.UTF8.GetChars((byte*)newBuffer, newLength, pChunkChars, newLength);
src\System\Threading\Mutex.CoreCLR.Unix.cs (1)
164SR.Format(SR.Unix_SystemCallErrors, Encoding.UTF8.GetString(systemCallErrors, systemCallErrorsLength));
System.Private.CoreLib.Generators (4)
EventSourceGenerator.Emitter.cs (3)
27context.AddSource($"{ec.ClassName}.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8)); 81int metadataSize = Encoding.UTF8.GetByteCount(name) + 3; 86Encoding.UTF8.GetBytes(name, 0, name.Length, metadata, 2);
NativeRuntimeEventSourceGenerator.cs (1)
56spc.AddSource($"{className}.g.cs", SourceText.From(source, System.Text.Encoding.UTF8));
System.Private.DataContractSerialization (37)
System\Runtime\Serialization\DataContract.cs (1)
1722byte[] namespaceBytes = Encoding.UTF8.GetBytes(namespaces);
System\Runtime\Serialization\Json\DataContractJsonSerializer.cs (1)
294XmlDictionaryWriter jsonWriter = JsonReaderWriterFactory.CreateJsonWriter(stream, Encoding.UTF8, false); // ownsStream
System\Runtime\Serialization\Json\JsonEncodingStreamWrapper.cs (1)
202_byteCount = Encoding.UTF8.GetBytes(_chars, 0, charCount, _bytes, 0);
System\Runtime\Serialization\Json\JsonReaderWriterFactory.cs (1)
50return CreateJsonWriter(stream, Encoding.UTF8, true);
System\Runtime\Serialization\Json\JsonXmlDataContract.cs (1)
33MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlContent));
System\Runtime\Serialization\Json\XmlJsonReader.cs (8)
603XmlExceptionHelper.ThrowTokenExpected(this, "false", Encoding.UTF8.GetString(buffer, offset, 5)); 611XmlExceptionHelper.ThrowTokenExpected(this, "false", Encoding.UTF8.GetString(buffer, offset, 4) + (char)ch); 624XmlExceptionHelper.ThrowTokenExpected(this, "true", Encoding.UTF8.GetString(buffer, offset, 4)); 632XmlExceptionHelper.ThrowTokenExpected(this, "true", Encoding.UTF8.GetString(buffer, offset, 4) + (char)ch); 645XmlExceptionHelper.ThrowTokenExpected(this, "null", Encoding.UTF8.GetString(buffer, offset, 4)); 658XmlExceptionHelper.ThrowTokenExpected(this, "null", Encoding.UTF8.GetString(buffer, offset, 4) + (char)ch); 1196string bufferAsString = Encoding.UTF8.GetString(buffer, offset, 4); 1207bufferAsString = Encoding.UTF8.GetString(buffer, offset, 4);
System\Runtime\Serialization\Json\XmlJsonWriter.cs (1)
241if (encoding.WebName != Encoding.UTF8.WebName)
System\Runtime\Serialization\XmlObjectSerializer.cs (1)
37XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8, false /*ownsStream*/);
System\Xml\EncodingStreamWrapper.cs (1)
612_byteCount = Encoding.UTF8.GetBytes(_chars, 0, charCount, _bytes, 0);
System\Xml\XmlBaseWriter.cs (1)
1644_textFragmentWriter.SetOutput(stream, false, Encoding.UTF8);
System\Xml\XmlCanonicalWriter.cs (7)
184_element.prefixLength = Encoding.UTF8.GetByteCount(prefix); 186_element.localNameLength = Encoding.UTF8.GetByteCount(localName); 254if (string.Equals(Encoding.UTF8.GetString(_xmlnsBuffer!, xmlnsAttribute.prefixOffset, xmlnsAttribute.prefixLength), _inclusivePrefixes[i], StringComparison.Ordinal)) 371xmlnsAttribute.prefixLength = Encoding.UTF8.GetBytes(prefix, 0, prefix.Length, _xmlnsBuffer, _xmlnsOffset); 374xmlnsAttribute.nsLength = Encoding.UTF8.GetBytes(ns, 0, ns.Length, _xmlnsBuffer, _xmlnsOffset); 424_attribute.prefixLength = Encoding.UTF8.GetByteCount(prefix); 426_attribute.localNameLength = Encoding.UTF8.GetByteCount(localName);
System\Xml\XmlDictionaryString.cs (1)
78return _buffer ??= System.Text.Encoding.UTF8.GetBytes(_value);
System\Xml\XmlNodeWriter.cs (8)
37WriteStartElement(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(localNameBuffer, localNameOffset, localNameLength)); 52WriteEndElement(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(localNameBuffer, localNameOffset, localNameLength)); 57WriteXmlnsAttribute(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(nsBuffer, nsOffset, nsLength)); 63WriteStartAttribute(Encoding.UTF8.GetString(prefixBuffer, prefixOffset, prefixLength), Encoding.UTF8.GetString(localNameBuffer, localNameOffset, localNameLength));
System\Xml\XmlUTF8TextReader.cs (2)
646XmlExceptionHelper.ThrowTokenExpected(this, "?>", Encoding.UTF8.GetString(buffer, offset, 2)); 1056XmlExceptionHelper.ThrowTokenExpected(this, "[CDATA[", Encoding.UTF8.GetString(buffer, offset, 7));
System\Xml\XmlUTF8TextWriter.cs (2)
25if (encoding.WebName != Encoding.UTF8.WebName) 93if (encoding != null && encoding.CodePage == Encoding.UTF8.CodePage)
System.Private.Windows.Core (4)
System\Private\Windows\BinaryFormat\Support\BinaryFormatWriterScope.cs (1)
15Writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true);
System\Private\Windows\Ole\Composition.ManagedToNativeAdapter.cs (2)
406int byteCount = Encoding.UTF8.GetByteCount(value); 415byteCount = Encoding.UTF8.GetBytes(value, span);
System\Private\Windows\Ole\Composition.NativeToManagedAdapter.cs (1)
193return Encoding.UTF8.GetString((byte*)buffer, size - 1);
System.Private.Xml (6)
System\Xml\Core\XmlTextReaderImpl.cs (1)
3177_ps.encoding = Encoding.UTF8;
System\Xml\Core\XmlWriterSettings.cs (2)
367Debug.Assert(Encoding.UTF8.WebName == "utf-8"); 503_encoding = Encoding.UTF8;
System\Xml\Serialization\Compiler.cs (1)
94byte[] valueBytes = Encoding.UTF8.GetBytes(value);
System\Xml\Xsl\XsltOld\SequentialOutput.cs (1)
609_utf8Encoding = Encoding.UTF8;
System\Xml\Xsl\XsltOld\XsltOutput.cs (1)
26private Encoding _encoding = System.Text.Encoding.UTF8;
System.Reflection.Emit (1)
System\Reflection\Emit\CustomAttributeWrapper.cs (1)
97return Text.Encoding.UTF8.GetString(data.Slice(pos, len));
System.Reflection.Metadata (5)
System\Reflection\Internal\Utilities\MemoryBlock.cs (1)
282return Encoding.UTF8.GetString(Pointer + offset, byteCount);
System\Reflection\Metadata\Internal\StringHeap.cs (1)
215StringKind.Virtual => Encoding.UTF8.GetBytes(GetVirtualString(handle.GetVirtualIndex())),
System\Reflection\Metadata\MetadataStringDecoder.cs (1)
35public static MetadataStringDecoder DefaultUTF8 { get; } = new MetadataStringDecoder(Encoding.UTF8);
System\Reflection\PortableExecutable\PEBinaryReader.cs (2)
32_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true); 107return Encoding.UTF8.GetString(bytes, 0, nonPaddedLength);
System.Reflection.MetadataLoadContext (2)
System\Reflection\TypeLoading\General\Helpers.cs (2)
367public static byte[] ToUtf8(this string s) => Encoding.UTF8.GetBytes(s); 370public static string ToUtf16(this ReadOnlySpan<byte> utf8) => Encoding.UTF8.GetString(utf8);
System.Resources.Extensions (4)
src\libraries\Common\src\System\Resources\ResourceWriter.cs (2)
248BinaryWriter bw = new BinaryWriter(_output, Encoding.UTF8); 303BinaryWriter data = new BinaryWriter(dataSection, Encoding.UTF8);
src\libraries\System.Private.CoreLib\src\System\Resources\ResourceReader.cs (2)
101_store = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.RandomAccess), Encoding.UTF8); 133_store = new BinaryReader(stream, Encoding.UTF8);
System.Resources.Writer (2)
src\libraries\Common\src\System\Resources\ResourceWriter.cs (2)
248BinaryWriter bw = new BinaryWriter(_output, Encoding.UTF8); 303BinaryWriter data = new BinaryWriter(dataSection, Encoding.UTF8);
System.Security.Cryptography (10)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (1)
57return Encoding.UTF8.GetString(spanBuffer.Slice(0, resultLength));
src\libraries\Common\src\System\Security\Cryptography\PasswordBasedEncryption.cs (3)
182encoding = System.Text.Encoding.UTF8; 329System.Text.Encoding encoding = System.Text.Encoding.UTF8; 467encoding = System.Text.Encoding.UTF8;
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
26int maxSize = checked(Encoding.UTF8.GetMaxByteCount(value.Length) + 1); 35int byteCount = Encoding.UTF8.GetBytes(value, _bytes);
System\Security\Cryptography\OpenSslAsnFormatter.cs (1)
81return Encoding.UTF8.GetString(buffer.Slice(0, total));
System\Security\Cryptography\Rfc2898DeriveBytes.cs (2)
59Encoding.UTF8.GetBytes(password ?? throw new ArgumentNullException(nameof(password))), 89byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
System\Security\Cryptography\X509Certificates\OpenSslX509CertificateReader.cs (1)
815return Encoding.UTF8.GetString(buffer.Slice(0, total));
System.Security.Cryptography.Pkcs (3)
src\libraries\Common\src\System\Security\Cryptography\PasswordBasedEncryption.cs (3)
182encoding = System.Text.Encoding.UTF8; 329System.Text.Encoding encoding = System.Text.Encoding.UTF8; 467encoding = System.Text.Encoding.UTF8;
System.Security.Cryptography.Xml (16)
System\Security\Cryptography\Xml\CanonicalXml.cs (1)
102return Encoding.UTF8.GetBytes(sb.ToString());
System\Security\Cryptography\Xml\CanonicalXmlAttribute.cs (2)
35byte[] rgbData = Encoding.UTF8.GetBytes(" " + Name + "=\""); 37rgbData = Encoding.UTF8.GetBytes(Utils.EscapeAttributeValue(Value));
System\Security\Cryptography\Xml\CanonicalXmlCDataSection.cs (1)
34byte[] rgbData = Encoding.UTF8.GetBytes(Utils.EscapeCData(Data));
System\Security\Cryptography\Xml\CanonicalXmlComment.cs (1)
61rgbData = Encoding.UTF8.GetBytes(Value!);
System\Security\Cryptography\Xml\CanonicalXmlElement.cs (2)
139rgbData = Encoding.UTF8.GetBytes("<" + Name); 167rgbData = Encoding.UTF8.GetBytes("</" + Name + ">");
System\Security\Cryptography\Xml\CanonicalXmlProcessingInstruction.cs (2)
57rgbData = Encoding.UTF8.GetBytes(Name); 62rgbData = Encoding.UTF8.GetBytes(" " + Value);
System\Security\Cryptography\Xml\CanonicalXmlSignificantWhitespace.cs (1)
36byte[] rgbData = Encoding.UTF8.GetBytes(Utils.EscapeWhitespaceData(Value));
System\Security\Cryptography\Xml\CanonicalXmlText.cs (1)
36byte[] rgbData = Encoding.UTF8.GetBytes(Utils.EscapeTextData(Value));
System\Security\Cryptography\Xml\CanonicalXmlWhitespace.cs (1)
36byte[] rgbData = Encoding.UTF8.GetBytes(Utils.EscapeWhitespaceData(Value));
System\Security\Cryptography\Xml\EncryptedXml.cs (1)
99_encoding = Encoding.UTF8;
System\Security\Cryptography\Xml\ExcCanonicalXml.cs (1)
55return Encoding.UTF8.GetBytes(sb.ToString());
System\Security\Cryptography\Xml\SignedXmlDebugLog.cs (1)
605Encoding.UTF8.GetString(ms.ToArray()));
System\Security\Cryptography\Xml\XmlDsigBase64Transform.cs (1)
101byte[] buffer = Encoding.UTF8.GetBytes(sb.ToString());
System.ServiceModel.Federation (2)
System\ServiceModel\Federation\WSTrustChannelSecurityTokenProvider.cs (2)
237var writer = XmlDictionaryWriter.CreateTextWriter(memeoryStream, Encoding.UTF8); 276var writer = XmlDictionaryWriter.CreateTextWriter(memeoryStream, Encoding.UTF8);
System.ServiceModel.NetFramingBase (3)
System\ServiceModel\Channels\FramingDecoders.cs (1)
165_value = Encoding.UTF8.GetString(_encodedBytes, 0, _encodedSize);
System\ServiceModel\Channels\FramingEncoders.cs (2)
56int valueByteCount = Encoding.UTF8.GetByteCount(value); 62Encoding.UTF8.GetBytes(value, EncodedBytes.Slice(offset).Span);
System.ServiceModel.NetNamedPipe (1)
System\ServiceModel\Channels\PipeConnectionInitiator.cs (1)
357byte[] canonicalBytes = Encoding.UTF8.GetBytes(canonicalName);
System.ServiceModel.Primitives.Tests (2)
Channels\TextMessageEncodingBindingElementTest.cs (1)
20Assert.Equal<Encoding>(Encoding.UTF8, element.WriteEncoding);
ServiceModel\ChannelFactoryTest.cs (1)
28new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8),
System.Text.Json (4)
System\Text\Json\JsonHelpers.cs (2)
201return Encoding.UTF8.GetString(bytes); 235int charsWritten = Encoding.UTF8.GetChars(utf8Key, charBuffer);
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (1)
490NameAsUtf8Bytes = Encoding.UTF8.GetBytes(Name);
System\Text\Json\Serialization\Metadata\PolymorphicTypeResolver.cs (1)
83byte[] utf8EncodedName = Encoding.UTF8.GetBytes(propertyName);
System.Text.Json.SourceGeneration (2)
JsonSourceGenerator.Parser.cs (1)
1648byte[] utf8Json = Encoding.UTF8.GetBytes(effectiveJsonPropertyName);
src\libraries\Common\src\SourceGenerators\SourceWriter.cs (1)
67return SourceText.From(_sb.ToString(), Encoding.UTF8);
System.Text.RegularExpressions.Generator (1)
RegexGenerator.Emitter.cs (1)
5453return $"{prefix}{ToHexStringNoDashes(sha.ComputeHash(Encoding.UTF8.GetBytes(toEncode)))}";
System.Web.HttpUtility (7)
System\Web\HttpUtility.cs (5)
81public static NameValueCollection ParseQueryString(string query) => ParseQueryString(query, Encoding.UTF8); 161public static string? UrlEncode(string? str) => UrlEncode(str, Encoding.UTF8); 177public static byte[]? UrlEncodeToBytes(string? str) => UrlEncodeToBytes(str, Encoding.UTF8); 187public static string? UrlDecode(string? str) => UrlDecode(str, Encoding.UTF8); 193public static byte[]? UrlDecodeToBytes(string? str) => UrlDecodeToBytes(str, Encoding.UTF8);
System\Web\Util\HttpEncoder.cs (2)
569byte[] bytes = ArrayPool<byte>.Shared.Rent(Encoding.UTF8.GetMaxByteCount(toEncode.Length)); 570int utf8Length = Encoding.UTF8.GetBytes(toEncode, bytes);
System.Windows.Forms (8)
System\Resources\ResXResourceWriter.cs (2)
161_xmlTextWriter = new XmlTextWriter(_stream, Encoding.UTF8); 166_xmlTextWriter = new XmlTextWriter(_fileName, Encoding.UTF8);
System\Windows\Forms\Controls\DataGridView\DataGridView.Methods.cs (2)
8156byte[] destinationBytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, sourceBytes); 8180destinationBytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, sourceBytes);
System\Windows\Forms\Controls\RichTextBox\RichTextBox.cs (3)
2831encodedBytes = (CodePagesEncodingProvider.Instance.GetEncoding(0) ?? Encoding.UTF8).GetBytes(str); 2875string str = (CodePagesEncodingProvider.Instance.GetEncoding(0) ?? Encoding.UTF8).GetString(bytes); 2968result = (CodePagesEncodingProvider.Instance.GetEncoding(0) ?? Encoding.UTF8).GetString(bytes, 0, bytes.Length);
System\Windows\Forms\Controls\WebBrowser\WebBrowser.cs (1)
325StreamWriter sw = new(ms, Encoding.UTF8);
System.Windows.Forms.Analyzers.CSharp.Tests (1)
Generators\ApplicationConfigurationGenerator\ApplicationConfigurationGeneratorTests.cs (1)
224return SourceText.From(input, Encoding.UTF8);
System.Windows.Forms.Analyzers.Tests (1)
TestFileLoader.cs (1)
47using var reader = new StreamReader(testFilePath, Encoding.UTF8);
System.Windows.Forms.Design.Tests (1)
System\Resources\Tools\StronglyTypedResourceBuilderTests.cs (1)
707Assert.Equal("HELLO", Encoding.UTF8.GetString(contents));
System.Windows.Forms.Tests (10)
SerializableTypesTests.cs (2)
29byte[] bytes = Encoding.UTF8.GetBytes(payload); 67Assert.Equal(payload, Encoding.UTF8.GetString(buffer));
System\Resources\ResXResourceReaderTests.cs (1)
77byte[] resxBytes = Encoding.UTF8.GetBytes(ResxHelper.CreateResx());
System\Windows\Forms\HtmlDocumentTests.cs (1)
2388byte[] data = Encoding.UTF8.GetBytes(html);
System\Windows\Forms\HtmlElementTests.cs (1)
3334byte[] data = Encoding.UTF8.GetBytes(html);
System\Windows\Forms\HtmlWindowTests.cs (1)
108byte[] data = Encoding.UTF8.GetBytes(html);
System\Windows\Forms\RichTextBoxTests.cs (1)
9758int currentCodePage = (CodePagesEncodingProvider.Instance.GetEncoding(0) ?? Encoding.UTF8).CodePage;
System\Windows\Forms\WebBrowserTests.cs (3)
539Assert.Equal(Html, Encoding.UTF8.GetString(documentStream.ToArray())); 579using MemoryStream value = new(Encoding.UTF8.GetBytes(Html)); 4651byte[] data = Encoding.UTF8.GetBytes(html);
Templates.Tests (1)
ByteOrderMarkTest.cs (1)
93var expectedBytes = Encoding.UTF8.GetPreamble();
Test.Utilities (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
Text.Analyzers (8)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
607text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (1)
38using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
src\RoslynAnalyzers\Utilities\Compiler\Extensions\StringExtensions.cs (1)
15return Encoding.UTF8.GetByteCount(value) == value.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.cs (1)
47_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
94_writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\TextEncodingKind.cs (3)
45TextEncodingKind.EncodingUtf8_BOM => Encoding.UTF8, 82Debug.Assert(HasPreamble(Encoding.UTF8)); 83kind = (encoding.Equals(Encoding.UTF8) || HasPreamble(encoding)) ? TextEncodingKind.EncodingUtf8_BOM : TextEncodingKind.EncodingUtf8;
UnitTests.Common (1)
TestData.cs (1)
50{ Encoding.UTF8 },
vbc (2)
src\Compilers\Shared\BuildServerConnection.cs (1)
575var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(pipeNameInput));
src\Compilers\Shared\CompilerServerLogger.cs (1)
157byte[] bytes = Encoding.UTF8.GetBytes(output);
VBCSCompiler (2)
src\Compilers\Shared\BuildServerConnection.cs (1)
575var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(pipeNameInput));
src\Compilers\Shared\CompilerServerLogger.cs (1)
157byte[] bytes = Encoding.UTF8.GetBytes(output);
VisualBasicErrorFactsGenerator (1)
Program.vb (1)
53File.WriteAllText(outputPath, outputText.ToString(), Encoding.UTF8)
VisualBasicSyntaxGenerator (6)
Program.vb (6)
78Using output As New StreamWriter(New FileStream(mainFile, FileMode.Create, FileAccess.Write), Encoding.UTF8) 126Using output As New StreamWriter(New FileStream(outputFile, FileMode.Create, FileAccess.Write), Encoding.UTF8) 142Using output As New StreamWriter(New FileStream(outputFile, FileMode.Create, FileAccess.Write), Encoding.UTF8) 161Using output As New StreamWriter(New FileStream(mainFile, FileMode.Create, FileAccess.Write), Encoding.UTF8) 172Using output As New StreamWriter(New FileStream(syntaxFile, FileMode.Create, FileAccess.Write), Encoding.UTF8) 178Using output As New StreamWriter(New FileStream(internalFile, FileMode.Create, FileAccess.Write), Encoding.UTF8)
WebSocketSample (2)
Program.cs (2)
37var bytes = Encoding.UTF8.GetBytes(line); 59Console.WriteLine(Encoding.UTF8.GetString(buffer, 0, result.Count));