FakeItEasy: Faked delegates with in parameters don't honor the read-only semantics

Reported by @zvirja https://github.com/FakeItEasy/FakeItEasy/issues/1338#issuecomment-402251902

Faked delegates with in parameters don’t honor the read-only semantics of in, i.e. it’s possible to configure the faked delegate to mutate the parameter:

delegate void Foo(in int x);
...
var foo = A.Fake<Foo>();
A.CallTo(() => foo(A<int>.Ignored)).AssignsOutAndRefParameters(123);
int z = 0;
foo(z);
Console.WriteLine(z); // Should print 0, but prints 123

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (14 by maintainers)

Most upvoted comments

@blairconrad Thanks for mentioning, was happy to help ☺️