Skip to content

Commit

Permalink
Fix diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
kzrnm committed Oct 21, 2023
1 parent 3fbe0a8 commit 6e81c6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static IEnumerable<string> TypeNameToNamespaces(string typeName)

static void Target(StringBuilder sb, ICompilationUnitSyntax newRoot)
{
using var sr = new StringReader(newRoot.ToString());
using var sr = new StringReader(newRoot.ToString()!);
var line = sr.ReadLine();
while (line != null)
{
Expand All @@ -115,7 +115,7 @@ static void Target(StringBuilder sb, ICompilationUnitSyntax newRoot)
}
}

public string ExpandAll(CancellationToken cancellationToken)
public string ExpandAllForTesting(CancellationToken cancellationToken)
{
var sb = new StringBuilder();
sb.AppendLine("namespace SourceExpander.Testing{");
Expand All @@ -126,7 +126,7 @@ public string ExpandAll(CancellationToken cancellationToken)
var files = sourceFileContainer.ToArray();
Array.Sort(files.Select(f => f.FileName).ToArray(), files);
Embedded(sb, files, Array.Empty<string>(), cancellationToken);
sb.Append("}");
sb.Append('}');
return sb.ToString();
}

Expand Down
5 changes: 4 additions & 1 deletion Source/SourceExpander.Generating.Common/EmbeddedLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ SyntaxTree Rewrited(SyntaxTree tree)
/// </summary>
public bool IsEmbeddedEmpty => container.Count == 0;

public string ExpandAll(CancellationToken token) => new CompilationExpander(compilation, container, config).ExpandAll(token);
/// <summary>
/// Expand all source for testing.
/// </summary>
public string ExpandAllForTesting(CancellationToken token) => new CompilationExpander(compilation, container, config).ExpandAllForTesting(token);
}
}
2 changes: 1 addition & 1 deletion Source/SourceExpander.Generator/ExpandGeneratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal void Execute(IContextWrappter ctx, CSharpCompilation compilation, Parse
if (config.ExpandingAll)
{
ctx.CancellationToken.ThrowIfCancellationRequested();
ctx.AddSource("SourceExpander.ExpandingAll.cs", loader.ExpandAll(ctx.CancellationToken));
ctx.AddSource("SourceExpander.ExpandingAll.cs", loader.ExpandAllForTesting(ctx.CancellationToken));
}

var expandedCode = CreateExpanded(loader.ExpandedCodes());
Expand Down

0 comments on commit 6e81c6c

Please sign in to comment.