Is it possible to use Burst in generated code?
This is what I've tried:
namespace ExampleSourceGenerator
{
[Generator]
public class BurstedMethodGenerator : ISourceGenerator
{
public void Execute(GeneratorExecutionContext context)
{
var sourceBuilder = new StringBuilder(
@"
using Unity.Burst;
using System;
namespace BurstedMethodNamespace
{
public static class BurstedMethodClass
{
[BurstCompile]
public static int MyFunction(int x)
{
return x * 2;
}
}
}"
);
context.AddSource("burstedMethodSourceGenerator", SourceText.From(sourceBuilder.ToString(), Encoding.UTF8));
}
public void Initialize(GeneratorInitializationContext context)
{
}
}
}
When I import my custom library I get these error messages:
NetStandard\ExampleSourceGenerator.BurstedMethodGenerator\burstedMethodSourceGenerator.cs(8,21): error CS0246: The type or namespace name 'BurstCompileAttribute' could not be found (are you missing a using directive or an assembly reference?)
NetStandardBlinq\ExampleSourceGenerator.BurstedMethodGenerator\burstedMethodSourceGenerator.cs(8,21): error CS0246: The type or namespace name 'BurstCompile' could not be found (are you missing a using directive or an assembly reference?)```
