Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying encoding of source file content #1195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ Microsoft.CodeAnalysis.Testing.SolutionState.WithProcessedMarkup(Microsoft.CodeA
Microsoft.CodeAnalysis.Testing.SourceFileCollection
Microsoft.CodeAnalysis.Testing.SourceFileCollection.Add((System.Type sourceGeneratorType, string filename, Microsoft.CodeAnalysis.Text.SourceText content) file) -> void
Microsoft.CodeAnalysis.Testing.SourceFileCollection.Add((System.Type sourceGeneratorType, string filename, string content) file) -> void
Microsoft.CodeAnalysis.Testing.SourceFileCollection.Add((System.Type sourceGeneratorType, string filename, string content, System.Text.Encoding encoding) file) -> void
Microsoft.CodeAnalysis.Testing.SourceFileCollection.Add((string filename, string content) file) -> void
Microsoft.CodeAnalysis.Testing.SourceFileCollection.Add((string filename, string content, System.Text.Encoding encoding) file) -> void
Microsoft.CodeAnalysis.Testing.SourceFileCollection.SourceFileCollection() -> void
Microsoft.CodeAnalysis.Testing.SourceFileList
Microsoft.CodeAnalysis.Testing.SourceFileList.Add(Microsoft.CodeAnalysis.Text.SourceText content) -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ public void Add((string filename, string content) file)
Add((file.filename, SourceText.From(file.content)));
}

public void Add((string filename, string content, Encoding encoding) file)
{
Add((file.filename, SourceText.From(file.content, file.encoding)));
}

public void Add((Type sourceGeneratorType, string filename, string content) file)
{
var contentWithEncoding = SourceText.From(file.content, Encoding.UTF8);
Add((file.sourceGeneratorType, file.filename, file.content, Encoding.UTF8));
}

public void Add((Type sourceGeneratorType, string filename, string content, Encoding encoding) file)
{
var contentWithEncoding = SourceText.From(file.content, file.encoding);
Add((file.sourceGeneratorType, file.filename, contentWithEncoding));
}

Expand Down
Loading