diff --git a/Samples/RefTypeAnalyzer/Program.cs b/Samples/RefTypeAnalyzer/Program.cs index ed18fbb2d..cdc11c154 100644 --- a/Samples/RefTypeAnalyzer/Program.cs +++ b/Samples/RefTypeAnalyzer/Program.cs @@ -17,6 +17,11 @@ public MyUnmanagedType() Hello = 42; } } + + static int AnotherFunction() + { + return new MyRefType().Hello; + } static void Kernel(Index1D index, ArrayView input, ArrayView output) { @@ -30,16 +35,19 @@ static void Kernel(Index1D index, ArrayView input, ArrayView output) // But arrays of reference types are still disallowed MyRefType[] refs = [new MyRefType()]; + + // Any functions that may be called are also analyzed + int result = AnotherFunction(); } static void Main(string[] args) { - var context = Context.CreateDefault(); + using var context = Context.CreateDefault(); var device = context.GetPreferredDevice(false); - var accelerator = device.CreateAccelerator(context); + using var accelerator = device.CreateAccelerator(context); - var input = accelerator.Allocate1D(1024); - var output = accelerator.Allocate1D(1024); + using var input = accelerator.Allocate1D(1024); + using var output = accelerator.Allocate1D(1024); var kernel = accelerator.LoadAutoGroupedStreamKernel, ArrayView>(Kernel);