Skip to content

Members That Define a Parameter With the Name handler Cause Issues #296

@JasonBock

Description

@JasonBock

To Reproduce

var code =
	"""
	using Rocks;

	[assembly: RockCreate<IHandle>]

	public interface IHandle
	{
		void Handle(string handler);
	}
	""";

Expected behavior
The mock is made.

Actual behavior
Errors occur:

error CS0841: Cannot use local variable '@handler' before it is declared

Additional context
This happens because a method or indexer defines a parameter with the name handler, and in the expectation handlers, Rocks doesn't check to ensure that name isn't used and create another one.

This was found on AngleSharp.Dom.IWindowTimers. It's recent with the code generation changes in 8.0.0.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions