Skip to content

Commit b6f9089

Browse files
Merge pull request #610 from yaqian256/users/yaqian/namespace-for-unsafe-not-import
Fix missing import of namespace for Unsafe
2 parents fbdf27a + 6f2553b commit b6f9089

File tree

5 files changed

+5
-0
lines changed

5 files changed

+5
-0
lines changed

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,6 +3121,7 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co
31213121

31223122
if (arraySize == 1)
31233123
{
3124+
code.AddUsingDirective("System.Runtime.CompilerServices");
31243125
code.Write("Unsafe.Add(ref e0, index)");
31253126
}
31263127
else

tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex
2121

2222
var expectedOutputContents = $@"using System;
2323
using System.Diagnostics.CodeAnalysis;
24+
using System.Runtime.CompilerServices;
2425
using System.Runtime.InteropServices;
2526
2627
namespace ClangSharp.Test

tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex
2121

2222
var expectedOutputContents = $@"using System;
2323
using System.Diagnostics.CodeAnalysis;
24+
using System.Runtime.CompilerServices;
2425
using System.Runtime.InteropServices;
2526
2627
namespace ClangSharp.Test

tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex
2121

2222
var expectedOutputContents = $@"using System;
2323
using System.Diagnostics.CodeAnalysis;
24+
using System.Runtime.CompilerServices;
2425
using System.Runtime.InteropServices;
2526
2627
namespace ClangSharp.Test

tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex
2121

2222
var expectedOutputContents = $@"using System;
2323
using System.Diagnostics.CodeAnalysis;
24+
using System.Runtime.CompilerServices;
2425
using System.Runtime.InteropServices;
2526
2627
namespace ClangSharp.Test

0 commit comments

Comments
 (0)