Skip to content

Assembly identifier does not strip -, unlike Immediate.Handlers/Apis, producing invalid method names #140

Description

@dukesteen

GetAssemblyIdentifier in this package strips . and spaces from the assembly name, but not -:

return (compilation.AssemblyName ?? string.Empty)
	.Replace(".", string.Empty, StringComparison.Ordinal)
	.Replace(" ", string.Empty, StringComparison.Ordinal)
	.Trim();

Immediate.Handlers and Immediate.Apis both have the extra - replacement that this copy is missing:

	.Replace("-", string.Empty, StringComparison.Ordinal)

Impact

For an assembly named Todo-Web, the four packages disagree:

Package Generated method Valid C#?
Immediate.Handlers AddTodoWebHandlers() yes
Immediate.Apis MapTodoWebEndpoints() yes
Immediate.Cache AddTodo-WebCaches() no
Immediate.Injections AddTodo-WebServices() no

A hyphen is not valid in a C# identifier, so the generated extension method does not compile. Hyphenated assembly names are common (my-app.Web, acme-todo), and the failure is a syntax error inside generated code with no obvious link to the assembly name.

Setting [assembly: ImmediateAssemblyIdentifier("...")] works around it, but only if the user has Immediate.Handlers referenced and works out why they need it.

Fix

Add the - replacement so this matches Immediate.Handlers and Immediate.Apis.

Same issue filed against the other affected package. Found while auditing the packages for the docs site rewrite.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions