Skip to content

Allow benchmark methods to use names that are used by code generation templates (fixes #2821) - #2897

Merged
timcassell merged 7 commits into
dotnet:masterfrom
User0332:fix-issue-2821-retry
Dec 9, 2025
Merged

timcassell merged 7 commits into
dotnet:masterfrom
User0332:fix-issue-2821-retry

Conversation

@User0332

@User0332 User0332 commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #2821.

Solution

Uses the suggested solution from #2821, using base.MethodName for instance methods, FQTypeName.MethodName for static methods, and prefixing all type/namespace names with the global:: namespace prefix to avoid accidentally referencing methods with names like System or BenchmarkDotNet.

Adds a new test that ensures the method names System and BenchmarkDotNet can be used as benchmark method names.

@timcassell

Copy link
Copy Markdown
Collaborator

It may not be strictly necessary, but we should probably also use this. to reference members of the generated class within itself. e.g. this.__Overhead, etc.

@timcassell

Copy link
Copy Markdown
Collaborator

Need to fix merge conflicts

@User0332

User0332 commented Dec 8, 2025 •

Copy link
Copy Markdown
Contributor Author

I might not be able to get to this for a bit so if anyone who is seeing this wants to build off this PR & finish it up I'd be open to that

@timcassell
timcassell force-pushed the fix-issue-2821-retry branch 3 times, most recently from 6c883d0 to c0f76ca Compare December 8, 2025 11:29
Fix missing prefixes.
Update Params and Arguments.
Remove ValidateNamingConflicts and test more name conflicts.
@timcassell
timcassell force-pushed the fix-issue-2821-retry branch from c0f76ca to da6cac4 Compare December 8, 2025 11:34
@timcassell
timcassell merged commit de52812 into dotnet:master Dec 9, 2025
11 of 16 checks passed
@timcassell timcassell added this to the v0.16.0 milestone Dec 9, 2025
@timcassell timcassell linked an issue Mar 16, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Params interaction with required property PR Build error when using certain method names

2 participants