Skip to content

Commit a94b2f0

Browse files
committed
Fix matching on csproj
1 parent 0e4d056 commit a94b2f0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/utilities/generateCode.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ async function checkResxGeneratorType(resxPath: string): Promise<'public' | 'int
2222
const content = await vscode.workspace.fs.readFile(csprojFile);
2323
const csprojContent = content.toString();
2424

25-
// Use regex to find EmbeddedResource items with our RESX file
26-
const regex = new RegExp(`<EmbeddedResource\\s+Include=["'](?:[^"']*[\\\\/])?${escapeRegExp(resxFileName)}["'][^>]*>([\\s\\S]*?)</EmbeddedResource>`, 'i');
25+
// Use regex to find EmbeddedResource items with our RESX file using either Include or Update attributes
26+
const regex = new RegExp(`<EmbeddedResource\\s+(?:Include|Update)=["'](?:[^"']*[\\\\/])?${escapeRegExp(resxFileName)}["'][^>]*>([\\s\\S]*?)</EmbeddedResource>`, 'i');
2727
const match = regex.exec(csprojContent);
2828

2929
if (match) {
3030
const itemContent = match[1];
3131
// Look for Generator metadata within the EmbeddedResource element
32-
const generatorRegex = /<Generator>([^<]+)<\/Generator>/i;
32+
const generatorRegex = /<Generator>\s*([^<]+?)\s*<\/Generator>/i;
3333
const generatorMatch = generatorRegex.exec(itemContent);
3434

3535
if (generatorMatch) {

0 commit comments

Comments
 (0)