You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Foo {
public virtual object Bar { get; internal set; }
}
Mock.Of<Foo>();
previously worked. Now it throws:
Cannot set up Foo.set_Bar because it is not accessible to the proxy generator used by Moq:
Can not create proxy for method Void set_Bar(Foo) because it or its declaring type is not accessible. Make it public, or internal and mark your assembly with [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] attribute, because assembly Opc.Ua.Client is not strong-named.
at Moq.Guard.IsVisibleToProxyFactory(MethodInfo method)
at Moq.InvocationShape..ctor(LambdaExpression expression, MethodInfo method, IReadOnlyList1 arguments) at Moq.AutoImplementedPropertySetterSetup..ctor(LambdaExpression originalExpression, MethodInfo method, Action1 setter)
at Moq.Mock.SetupAllProperties(Mock mock, DefaultValueProvider defaultValueProvider)
at Moq.Mock.OfT
I assume that previously this was mocked as "readonly property" where get could be setuped.
Now Moq tries to mock the same property as a get + set property.
Is this an intended change "here to stay" or will this be reverted?
Also note that when the property is notvirtual, SetupAllProperties() will succeed. The property is just not mocked.
public class Foo {
public object Bar { get; internal set; }
}
Mock.Of<Foo>();
This creates a precedent for "just mock everything mockable". Seems for consistency reasons it might make sense to revert back to the old behavior and "ignore" internal setters?
Thanks!
The text was updated successfully, but these errors were encountered:
Sorry for the previous comment, I was being stupid - didn't notice the fix hasn't been released yet and re-tested it against 4.11, again, and of course found it didn't work...
Case:
previously worked. Now it throws:
I assume that previously this was mocked as "readonly property" where
get
could be setuped.Now Moq tries to mock the same property as a get + set property.
Is this an intended change "here to stay" or will this be reverted?
Also note that when the property is not
virtual
,SetupAllProperties()
will succeed. The property is just not mocked.This creates a precedent for "just mock everything mockable". Seems for consistency reasons it might make sense to revert back to the old behavior and "ignore" internal setters?
Thanks!
The text was updated successfully, but these errors were encountered: