ISourceGenerator.cs 1.2 KB

123456789101112131415161718192021222324252627
  1. using Microsoft.CodeAnalysis;
  2. namespace QuestPDF.InteropGenerators;
  3. /// <summary>
  4. /// Interface for generating interop bindings for QuestPDF public API.
  5. /// Generates both C# native AOT code for C ABI/FFI and Python bindings.
  6. /// </summary>
  7. public interface ISourceGenerator
  8. {
  9. /// <summary>
  10. /// Generates C# code for native AOT compilation with C ABI compatibility.
  11. /// This should produce UnmanagedCallersOnly methods for FFI interop.
  12. /// Return empty string if the type doesn't require C interop code (e.g., enums).
  13. /// </summary>
  14. /// <param name="namespaceSymbol">Root namespace symbol to analyze</param>
  15. /// <returns>Generated C# interop code or empty string if not applicable</returns>
  16. string GenerateCSharpCode(INamespaceSymbol namespaceSymbol);
  17. /// <summary>
  18. /// Generates Python bindings code using ctypes or similar FFI mechanisms.
  19. /// This creates Python classes and functions that wrap the C ABI interface.
  20. /// </summary>
  21. /// <param name="namespaceSymbol">Root namespace symbol to analyze</param>
  22. /// <returns>Generated Python binding code</returns>
  23. string GeneratePythonCode(INamespaceSymbol namespaceSymbol);
  24. }