From 14796cd776e31436bfce4d09519ffacf47363871 Mon Sep 17 00:00:00 2001 From: Claudio Benghi Date: Mon, 25 Jan 2021 00:05:33 +0100 Subject: [PATCH] Added comment parsing check for NativeMethods.txt Lines starting with "//" will be ignored when parsing NativeMethods.txt to allow more expressive configuration files. --- README.md | 3 ++- src/Microsoft.Windows.CsWin32/SourceGenerator.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b001ad7..bceaa706 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,9 @@ Create a `NativeMethods.txt` file in your project directory that lists the APIs Each line may consist of *one* of the following: * Exported method name (e.g. `CreateFile`). This *may* include the `A` or `W` suffix, where applicable. -* Module name followed by `.*` to generate all methods exported from that module (e.g. `Kernel32.*`) +* Module name followed by `.*` to generate all methods exported from that module (e.g. `Kernel32.*`). * The name of a struct, enum, constant or interface to generate. +* A comment (i.e. any line starting with `//`) or white space line, which will be ignored. When generating any type or member, all supporting types will also be generated. diff --git a/src/Microsoft.Windows.CsWin32/SourceGenerator.cs b/src/Microsoft.Windows.CsWin32/SourceGenerator.cs index de6bbd12..13af22b2 100644 --- a/src/Microsoft.Windows.CsWin32/SourceGenerator.cs +++ b/src/Microsoft.Windows.CsWin32/SourceGenerator.cs @@ -117,7 +117,7 @@ public void Execute(GeneratorExecutionContext context) { context.CancellationToken.ThrowIfCancellationRequested(); string name = line.ToString(); - if (string.IsNullOrWhiteSpace(name)) + if (string.IsNullOrWhiteSpace(name) || name.StartsWith("//", StringComparison.InvariantCulture)) { continue; }