diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs index bea24aa1b62cdf..55ab40020a54c0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs @@ -91,7 +91,7 @@ public enum Stage /// public StubCodeContext? ParentContext { get; protected init; } - public const string GeneratedNativeIdentifierSuffix = "_gen_native"; + public const string GeneratedNativeIdentifierSuffix = "_native"; /// /// Get managed and native instance identifiers for the diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/SyntaxExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/SyntaxExtensions.cs index 331b5882d252ae..02a0d80743d59e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/SyntaxExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/SyntaxExtensions.cs @@ -19,16 +19,31 @@ private static FixedStatementSyntax AddStatementWithoutEmptyStatements(this Fixe { return fixedStatement.WithStatement(childStatement); } + + BlockSyntax block; if (fixedStatement.Statement.IsKind(SyntaxKind.Block)) { - var block = (BlockSyntax)fixedStatement.Statement; + block = (BlockSyntax)fixedStatement.Statement; if (block.Statements.Count == 0) { return fixedStatement.WithStatement(childStatement); } - return fixedStatement.WithStatement(block.AddStatements(childStatement)); } - return fixedStatement.WithStatement(SyntaxFactory.Block(fixedStatement.Statement, childStatement)); + else + { + block = SyntaxFactory.Block(fixedStatement.Statement); + } + + if (childStatement.IsKind(SyntaxKind.Block)) + { + block = block.WithStatements(block.Statements.AddRange(((BlockSyntax)childStatement).Statements)); + } + else + { + block = block.AddStatements(childStatement); + } + + return fixedStatement.WithStatement(block); } public static StatementSyntax NestFixedStatements(this ImmutableArray fixedStatements, StatementSyntax innerStatement)