Skip to content

Commit 3f086c5

Browse files
Register provider now required
1 parent 1839975 commit 3f086c5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Tests/Compilation/CompilerExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Linq;
44
using System.Reflection;
5+
using System.Text;
56
using ICSharpCode.CodeConverter.Common;
67
using Microsoft.CodeAnalysis;
78

@@ -15,6 +16,10 @@ public static class CompilerExtensions
1516
/// <remarks>The transitive closure of the references for <paramref name="requiredAssemblies"/> are added.</remarks>
1617
public static Assembly AssemblyFromCode(this ICompiler compiler, SyntaxTree syntaxTree, params Assembly[] requiredAssemblies)
1718
{
19+
// Register CodePages encoding provider for Windows-1252 and other code pages
20+
// This is needed for VB.NET Chr() function which relies on code page specific encodings
21+
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
22+
1823
var allReferences = DefaultReferences.With(requiredAssemblies);
1924
var compilation = compiler.CreateCompilationFromTree(syntaxTree, allReferences);
2025

0 commit comments

Comments
 (0)