CRASH: CppSharp.Generators.CSharp.CSharpSources.GenerateFieldGetter #"Sequence contains no matching element"
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start at CppSharp.Generators.CSharp.CSharpSources.GenerateFieldGetter, using the SidUsage.h declaration and the Setup method's module configuration as the reproduction case. Trace the field and property generation path shown in the stack trace, then verify that generating bindings for this header completes without the “Sequence contains no matching element” crash.
Written by the indexing model from the issue text.
Description
Brief Description
Hello I am trying to generate bindings for the Sidplay2 library (https://sourceforge.net/projects/sidplay2/files/sidplay2/sidplay-libs-2.1.1/).
I have a crash when trying to generate an header.

OS: Windows / OS X / Linux (include version and/or distro)
Windows 10 (I downloaded CppSharp 2 days ago so standing to the changelog file im here -> ## [0.11.1] - 2021-2-3)
Used headers
(inside "sidplay-libs-2.1.1\libsidutils\src\SidUsage.h"):
struct sid2_usage_t: public sid_usage_t
{
uint_least16_t start; // Load image start address
uint_least16_t end; // Load image end address
char md5[SIDTUNE_MD5_LENGTH + 1]; // Tunes MD5 key
uint_least16_t length; // usage scan length
// Copy common parts of basic usage to extended usage.
sid2_usage_t &sid2_usage_t::operator= (const sid_usage_t &usage)
{
*((sid_usage_t *) this) = usage;
return *this;
}
};
Used settings
I only have this in my Setup method:
public void Setup(Driver driver)
{
var options = driver.Options;
options.GeneratorKind = GeneratorKind.CSharp;
var module = options.AddModule(nameof(SIDUsage));
module.IncludeDirs.Add(@"C:\sidplay-libs-2.1.1\libsidutils\include\sidplay\utils");
module.Headers.Add("SidUsage.h");
module.IncludeDirs.Add(@"C:\sidplay-libs-2.1.1\libsidplay\include\sidplay");
module.Headers.Add("sidusage.h");
module.IncludeDirs.Add(@"C:\sidplay-libs-2.1.1\libsidplay\include");
module.Headers.Add("config.h");
}
Target: MSVC/GCC/Clang
Other settings
Stack trace or incompilable generated code
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.GenerateFieldGetter(CppSharp.AST.Field field, CppSharp.AST.Class class, CppSharp.AST.QualifiedType returnType) Line 1375 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSourcesExtensions.GenerateField(CppSharp.Generators.CSharp.CSharpSources gen, CppSharp.AST.Class class, CppSharp.AST.Field field, System.Action<CppSharp.AST.Field, CppSharp.AST.Class, CppSharp.AST.QualifiedType> generate, bool isVoid) Line 92 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.GeneratePropertyGetter<CppSharp.AST.Field>(CppSharp.AST.Field decl, CppSharp.AST.Class class, bool isAbstract, CppSharp.AST.Property property) Line 1271 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.GenerateProperties(CppSharp.AST.Class class) Line 1584 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.GenerateClassProperties(CppSharp.AST.Class class) Line 1525 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.VisitClassDecl(CppSharp.AST.Class class) Line 472 C#
CppSharp.AST.dll!CppSharp.AST.Class.Visit(CppSharp.AST.IDeclVisitor visitor) Line 289 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.VisitDeclContext(CppSharp.AST.DeclarationContext context) Line 223 C#
CppSharp.Generator.dll!CppSharp.Generators.CodeGenerator.VisitNamespace(CppSharp.AST.Namespace namespace) Line 396 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.VisitNamespace(CppSharp.AST.Namespace namespace) Line 203 C#
CppSharp.Generator.dll!CppSharp.Generators.CodeGenerator.VisitTranslationUnit(CppSharp.AST.TranslationUnit unit) Line 258 C#
CppSharp.AST.dll!CppSharp.AST.TranslationUnit.Visit(CppSharp.AST.IDeclVisitor visitor) Line 83 C#
CppSharp.Generator.dll!CppSharp.Generators.CSharp.CSharpSources.Process() Line 95 C#
CppSharp.Generator.dll!CppSharp.Generators.Generator.GenerateModule(CppSharp.AST.Module module) Line 170 C#
CppSharp.Generator.dll!CppSharp.Generators.Generator.Generate() Line 95 C#
CppSharp.Generator.dll!CppSharp.Driver.GenerateCode() Line 313 C#
CppSharp.Generator.dll!CppSharp.ConsoleDriver.Run(CppSharp.ILibrary library) Line 457 C#
SidPlayBindingGenerator.dll!SidPlayBindingGenerator.Program.Main(string[] args) Line 16 C#
Any clue of what can cause this?
Thank you!
- Dominant language
- C#
- Stars
- 3.4k
- Forks
- 541
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mono/CppSharp
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
How to get started Open
Difficulty 3/5 1-2 days Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100