Skip to content

c#: Fix same name issue in resources#1238

Closed
jsturtevant wants to merge 3 commits intobytecodealliance:mainfrom
jsturtevant:same-name
Closed

c#: Fix same name issue in resources#1238
jsturtevant wants to merge 3 commits intobytecodealliance:mainfrom
jsturtevant:same-name

Conversation

@jsturtevant
Copy link
Collaborator

possible fix for #1232

I am not a huge fan of this but not sure if there is another way

@yowl @silesmo @pavelsavara thoughts?

Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
@jsturtevant jsturtevant marked this pull request as ready for review March 22, 2025 04:42
@pavelsavara
Copy link
Collaborator

Perhaps there could be opt-in mapping per type. --map-resource-name=XYZ:XYZResource or something like that.
Or even for that specific method. --map-function-name=foo.foo:foo.fooFactory

@pavelsavara
Copy link
Collaborator

Making C# look differently than wit is not great. Let's keep the problem as localized as possible.

@jsturtevant
Copy link
Collaborator Author

Perhaps there could be opt-in mapping per type. --map-resource-name=XYZ:XYZResource or something like that.
Or even for that specific method. --map-function-name=foo.foo:foo.fooFactory
Making C# look differently than wit is not great. Let's keep the problem as localized as possible.

💯. thanks for the suggestion, I'll see if I can get it working

@pavelsavara
Copy link
Collaborator

If we want something that magically always works, we could have foo._foo or foo.foo1 when we detect class and method name match.

@silesmo
Copy link
Member

silesmo commented Mar 24, 2025

I understand the reasoning for allowing to re-map the name of a type. But that will also add edge cases where you would need to manually remap something if they clash? I would expect the tooling to handle this automatically to not introduce additional hurdles for new users to adopt C# with wasi. @pavelsavara @jsturtevant

@pavelsavara
Copy link
Collaborator

I guess other languages also have naming clashes, for example with keywords or with method names that start with numbers. having same rules would help.

That said naming something foo.foo is bad idea and that's why C# has the rule in place. Maybe we could also propagate that rule to wit spec ?

@silesmo
Copy link
Member

silesmo commented Mar 24, 2025

Keywords are generally handled by escaping the keyword. So it wouldn't directly map to this problem.

Yea I wouldn't mind trying to push it to the wit spec if we can get others to agree.

@jsturtevant
Copy link
Collaborator Author

dropping a few more notes here:

@jsturtevant
Copy link
Collaborator Author

something like foo._foo might be relatively unobtrusive.

I've also raised the issue in the component model WebAssembly/component-model#478

@jsturtevant
Copy link
Collaborator Author

proposed change to the spec: WebAssembly/component-model#494

@jsturtevant
Copy link
Collaborator Author

this is now part of the spec: WebAssembly/component-model#494 with a change going into the tooling: bytecodealliance/wasm-tools#2138

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.

3 participants