Skip to content

Commit

Permalink
Fix parsing quoted empty arg in response file (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Nov 20, 2023
1 parent 1ceb048 commit 61ce5b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ jobs:
name: test-logs-${{ matrix.os }}-node${{ matrix.node-version }}-${{ matrix.configuration }}
path: |
out/obj/${{ matrix.configuration }}/**/*.log
out/obj/${{ matrix.configuration }}/**/*.rsp
out/test/**/*.trx
- name: Check formatting
Expand Down
2 changes: 2 additions & 0 deletions src/NodeApi.Generator/ModuleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class ModuleGenerator : SourceGenerator, ISourceGenerator

public GeneratorExecutionContext Context { get; protected set; }

#pragma warning disable IDE0060 // Unused parameter
public void Initialize(GeneratorInitializationContext context)
#pragma warning restore IDE0060
{
// Note source generators cannot be directly launched in a debugger,
// because the generator runs at build time, not at application run-time.
Expand Down
9 changes: 6 additions & 3 deletions src/NodeApi.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,20 @@ private static IEnumerable<string> SplitWithQuotes(string line)
{
StringBuilder s = new();
bool inQuotes = false;
bool foundQuotes = false;
foreach (char c in line)
{
if (c == '"')
{
inQuotes = !inQuotes;
foundQuotes = true;
}
else if (c == ' ' && !inQuotes)
{
if (s.Length > 0)
if (s.Length > 0 || foundQuotes)
{
yield return s.ToString();
foundQuotes = false;
s.Clear();
}
}
Expand All @@ -301,7 +304,7 @@ private static IEnumerable<string> SplitWithQuotes(string line)
}
}

if (s.Length > 0)
if (s.Length > 0 || foundQuotes)
{
yield return s.ToString();
}
Expand Down Expand Up @@ -344,7 +347,7 @@ private static void ResolveSystemAssemblies(
{
if (targetingPacks.Count == 0)
{
// If no targeting packs were specified, use the deafult targeting pack for .NET.
// If no targeting packs were specified, use the default targeting pack for .NET.
targetingPacks.Add("Microsoft.NETCore.App");
}

Expand Down

0 comments on commit 61ce5b3

Please sign in to comment.