Skip to content

Generator hintName collision#1545

Open
czirok wants to merge 1 commit into
gircore:mainfrom
czirok:fix/generator-hintname-collision
Open

Generator hintName collision#1545
czirok wants to merge 1 commit into
gircore:mainfrom
czirok:fix/generator-hintname-collision

Conversation

@czirok

@czirok czirok commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • I agree that my contribution may be licensed either under MIT or any version of LGPL license.

Include the namespace in generated source filenames to avoid hintName collisions when different namespaces contain types with the same short name.

The filename generation in TypeDataHelper is now namespace-aware while keeping nested type names and generic parameter counts as part of the generated name.

This prevents AddSource collisions in source generators that use TypeData.Filename, including the GObject subclass generator and the GTK template generator.

Tests were added for both GObject and GTK integration paths with identical Widget type names declared in different namespaces, verifying that source generation no longer fails with CS8785.

@badcel badcel linked an issue Jun 30, 2026 that may be closed by this pull request

@badcel badcel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code itself looks perfectly fine for me.

Unfortunately the tests seem not to work like intended. I'm fine with having a "stupid" test like mentioned in the comments to detect if "something" is broken. I this happens to often we can still think about moving tests for namespace verification in actual unit tests.

Comment thread src/Tests/Libs/GObject-2.0.Integration.Tests/DiagnosticAnalyzerTest.cs Outdated
Comment thread src/Tests/Libs/Gtk-4.0.Integration.Tests/DiagnosticAnalyzerTest.cs Outdated
@czirok czirok force-pushed the fix/generator-hintname-collision branch from 4be0851 to fe4e292 Compare July 7, 2026 13:18
@czirok

czirok commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

I reworked the test so it verifies the actual generator output.

It now creates two subclasses with the same class name in different namespaces, runs the generator, checks that no CS8785 diagnostic is produced, verifies that both namespace-qualified hint names are generated, and ensures that all generated hint names are unique.

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

Successfully merging this pull request may close these issues.

Generator hintName collision

2 participants