Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception generating C# for openrazer-win32 #1858

Open
element109 opened this issue Aug 7, 2024 · 0 comments
Open

Exception generating C# for openrazer-win32 #1858

element109 opened this issue Aug 7, 2024 · 0 comments

Comments

@element109
Copy link

https://github.com/CalcProgrammer1/openrazer-win32

OS: Windows 10
VS 2022
nuget CppSharp 1.1.5.3168

`namespace OpenRazerWin32
{
using CppSharp;
using CppSharp.AST;
using CppSharp.Generators;

static class Program
{
    static void Main(string[] args)
    {
        try
        {
            var name = args[0];
            var projectPath = args[1];
            Console.WriteLine(name);
            var outputPath = Path.Combine(Environment.CurrentDirectory, name);
            var generator = new Generate(name, outputPath, projectPath);
            ConsoleDriver.Run(generator);
        }
        catch (Exception ex)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(ex.ToString());
        }

        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("\r\nPress any key to quit...");
        Console.ReadKey();
    }

    class Generate : ILibrary
    {
        public string Name { get; private set; }
        public string OutputDirectory { get; private set; }
        public string ProjectBasePath { get; private set; }

        public Generate(string name, string outputDir, string projectPath)
        {
            Name = name;
            OutputDirectory = outputDir;
            ProjectBasePath = projectPath;
        }

        public void Postprocess(Driver driver, ASTContext ctx) { }
        public void Preprocess(Driver driver, ASTContext ctx) { }
        public void SetupPasses(Driver driver) { }

        public void Setup(Driver driver)
        {
            var options = driver.Options;
            options.GeneratorKind = GeneratorKind.CSharp;
            options.OutputDir = OutputDirectory;

            var module = options.AddModule(Name);
            var pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
            module.IncludeDirs.Add(Path.Combine(pf, "Windows Kits\\10\\Include\\10.0.22621.0\\um"));
            module.IncludeDirs.Add(Path.Combine(pf, "Windows Kits\\10\\Include\\10.0.22621.0\\shared"));              
            module.IncludeDirs.Add(Path.Combine(ProjectBasePath, "linux"));
            module.IncludeDirs.Add(Path.Combine(ProjectBasePath, "dependencies\\hidapi\\hidapi"));

            var hfs = Directory.EnumerateFiles(Path.Combine(ProjectBasePath, "openrazer\\driver"), "*.h");
            foreach (var hf in hfs)
                module.Headers.Add(hf);
        }
    }
}

}`

Stack trace

at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at CppSharp.Generators.CSharp.CSharpSources.GenerateFieldGetter(Field field, Class class, QualifiedType returnType)
at CppSharp.Generators.CSharp.CSharpSourcesExtensions.GenerateField(CSharpSources gen, Class class, Field field, Action3 generate, Boolean isVoid) at CppSharp.Generators.CSharp.CSharpSources.GeneratePropertyGetter[T](T decl, Class class, Boolean isAbstract, Property property) at CppSharp.Generators.CSharp.CSharpSources.GenerateProperties(Class class) at CppSharp.Generators.CSharp.CSharpSources.GenerateClassProperties(Class class) at CppSharp.Generators.CSharp.CSharpSources.VisitClassDecl(Class class) at CppSharp.AST.Class.Visit[T](IDeclVisitor1 visitor)
at CppSharp.Generators.CSharp.CSharpSources.VisitDeclContext(DeclarationContext context)
at CppSharp.Generators.CodeGenerator.VisitNamespace(Namespace namespace)
at CppSharp.Generators.CSharp.CSharpSources.VisitNamespace(Namespace namespace)
at CppSharp.Generators.CodeGenerator.VisitTranslationUnit(TranslationUnit unit)
at CppSharp.AST.TranslationUnit.Visit[T](IDeclVisitor`1 visitor)
at CppSharp.Generators.CSharp.CSharpSources.Process()
at CppSharp.Generators.Generator.GenerateModule(Module module)
at CppSharp.Generators.Generator.Generate()
at CppSharp.Driver.GenerateCode()
at CppSharp.ConsoleDriver.Run(ILibrary library)
at OpenRazerWin32.Program.Main(String[] args) in OpenRazerWin32.Program.cs:line 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant