Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moq library throwing TypeIniatilizationException. #1459

Open
protyaig opened this issue Jan 22, 2024 · 0 comments
Open

Moq library throwing TypeIniatilizationException. #1459

protyaig opened this issue Jan 22, 2024 · 0 comments
Labels

Comments

@protyaig
Copy link

Describe the Bug

TypeInitializationException with SyncrhonizationLockException being thrown when instantiating Mocks . This was thrown for all the tests in the class. This issue happened once in our pipelines but it didn't occur locally. Or in any of the later builds.

Steps to Reproduce

Expected Behavior

The initialization should go through

Exception with Stack Trace

System.TypeInitializationException : The type initializer for 'Moq.ProxyFactory' threw an exception.
build 18-Jan-2024 08:40:56 ---- System.Threading.SynchronizationLockException : Object synchronization method was called from an unsynchronized block of code.
build 18-Jan-2024 08:40:56 Stack Trace:
build 18-Jan-2024 08:40:56 //src/Moq/Guard.cs(113,0): at Moq.Guard.IsVisibleToProxyFactory(MethodInfo method)
build 18-Jan-2024 08:40:56 /
/src/Moq/MethodExpectation.cs(240,0): at Moq.MethodExpectation..ctor(LambdaExpression expression, MethodInfo method, IReadOnlyList1 arguments, Boolean exactGenericTypeArguments, Boolean skipMatcherInitialization, Boolean allowNonOverridable) build 18-Jan-2024 08:40:56 /_/src/Moq/ExpressionExtensions.cs(240,0): at Moq.ExpressionExtensions.<Split>g__Split|5_0(Expression e, Expression& r, MethodExpectation& p, Boolean assignment, Boolean allowNonOverridableLastProperty) build 18-Jan-2024 08:40:56 /_/src/Moq/ExpressionExtensions.cs(171,0): at Moq.ExpressionExtensions.Split(LambdaExpression expression, Boolean allowNonOverridableLastProperty) build 18-Jan-2024 08:40:56 /_/src/Moq/Mock.cs(562,0): at Moq.Mock.Setup(Mock mock, LambdaExpression expression, Condition condition) build 18-Jan-2024 08:40:56 /_/src/Moq/Mock1.cs(645,0): at Moq.Mock1.Setup[TResult](Expression1 expression)

Put the exception with stack trace here.

Version Info

Moq version 4.20.70
Moq.AutoMock Version 3.5.0

Additional Info

@protyaig protyaig added the bug label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant