sentry-dotnet icon indicating copy to clipboard operation
sentry-dotnet copied to clipboard

chore: update DeviceTests to net8

Open vaind opened this issue 2 years ago • 4 comments

This original exception seems resolved now...

Many tests currently fail with the following exception:

System.InvalidCastException : Specified cast is not valid.
   at Castle.DynamicProxy.Internal.AttributeUtil.ReadAttributeValue(CustomAttributeTypedArgument argument)
   at Castle.DynamicProxy.Internal.AttributeUtil.GetArguments(IList`1 constructorArguments, Type[]& constructorArgTypes, Object[]& constructorArgs)
   at Castle.DynamicProxy.Internal.AttributeUtil.CreateInfo(CustomAttributeData attribute)
   at Castle.DynamicProxy.Internal.AttributeUtil.GetNonInheritableAttributes(ParameterInfo parameter)+MoveNext()
   at Castle.DynamicProxy.Generators.Emitters.MethodEmitter.DefineParameters(ParameterInfo[] parameters)
   at Castle.DynamicProxy.Generators.Emitters.MethodEmitter..ctor(AbstractTypeEmitter owner, String name, MethodAttributes attributes, MethodInfo methodToUseAsATemplate)
   at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.CreateMethod(String name, MethodAttributes attributes, MethodInfo methodToUseAsATemplate)
   at Castle.DynamicProxy.Generators.MethodGenerator.Generate(ClassEmitter class, INamingScope namingScope)
   at Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementMethod(MetaMethod method, ClassEmitter class, OverrideMethodDelegate overrideMethod)
   at Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(ClassEmitter class)
   at Castle.DynamicProxy.Generators.BaseClassProxyGenerator.GenerateType(String name, INamingScope namingScope)
   at Castle.DynamicProxy.Generators.BaseProxyGenerator.<>c__DisplayClass13_0.<GetProxyType>b__0(CacheKey cacheKey)
   at Castle.Core.Internal.SynchronizedDictionary`2[[Castle.DynamicProxy.Generators.CacheKey, Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc],[System.Type, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(CacheKey key, Func`2 valueFactory)
   at Castle.DynamicProxy.Generators.BaseProxyGenerator.GetProxyType()
   at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.CreateProxyUsingCastleProxyGenerator(Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments, IInterceptor[] interceptors, ProxyGenerationOptions proxyGenerationOptions)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateTypeProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments, Boolean callBaseByDefault)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For[IHub](Object[] constructorArguments)
   at Sentry.Tests.SentryHttpFailedRequestHandlerTests..ctor()
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Which looks very similar to https://github.com/dotnet/runtime/issues/93770 and that should be fixed by https://github.com/dotnet/runtime/pull/94469 so I think we need to wait till that makes it to a release.

but there's a new one, which is weird because we have exactly that setting: https://github.com/getsentry/sentry-dotnet/blob/7108689f09addc2f678cb44ea0ead6bb7fa1c1af/Directory.Build.props#L100

        <failure exception-type="System.ArgumentException">
          <message><![CDATA[System.ArgumentException : Can not create proxy for type Sentry.Internal.IAppDomain because it is not accessible. Make it public, or internal and mark your assembly with [assembly: InternalsVisibleTo(\"DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7\")] attribute, because assembly Sentry is strong-named. Arg_ParamName_Name, additionalInterfacesToProxy]]></message>
          <stack-trace><![CDATA[   at Castle.DynamicProxy.DefaultProxyBuilder.AssertValidTypeForTarget(Type type, Type target, String paramName)
   at Castle.DynamicProxy.DefaultProxyBuilder.AssertValidType(Type target, String paramName)
   at Castle.DynamicProxy.DefaultProxyBuilder.AssertValidTypes(IEnumerable`1 targetTypes, String paramName)
   at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.CreateProxyUsingCastleProxyGenerator(Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments, IInterceptor[] interceptors, ProxyGenerationOptions proxyGenerationOptions)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateTypeProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments, Boolean callBaseByDefault)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For[IAppDomain](Object[] constructorArguments)
   at Sentry.Tests.UnobservedTaskExceptionIntegrationTests.Fixture..ctor()
   at Sentry.Tests.UnobservedTaskExceptionIntegrationTests..ctor()
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags )]]></stack-trace>
        </failure>

#skip-changelog

vaind avatar Nov 16 '23 19:11 vaind

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 76.40%. Comparing base (495e742) to head (b81c6f0). Report is 86 commits behind head on main.

:exclamation: Current head b81c6f0 differs from pull request most recent head 572ba22. Consider uploading reports for the commit 572ba22 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2854      +/-   ##
==========================================
+ Coverage   75.73%   76.40%   +0.67%     
==========================================
  Files         357      351       -6     
  Lines       13466    13257     -209     
  Branches     2671     2645      -26     
==========================================
- Hits        10198    10129      -69     
+ Misses       2593     2451     -142     
- Partials      675      677       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 11 '24 15:01 codecov[bot]

Superseded by https://github.com/getsentry/sentry-dotnet/pull/3286

bitsandfoxes avatar Apr 11 '24 14:04 bitsandfoxes

Derp.. jumped the gun

bitsandfoxes avatar Apr 11 '24 14:04 bitsandfoxes

I wonder if there's a chance we get this to work at this point? I'm concerned it might get super stale eventually

bruno-garcia avatar May 01 '24 00:05 bruno-garcia

@vaind I managed to get this going in the net9.0 branch.

There were multiple things going on:

I'll close this PR then.

jamescrosswell avatar Oct 30 '24 07:10 jamescrosswell

@vaind I managed to get this going in the net9.0 branch.

thanks, much appreciated!

vaind avatar Oct 30 '24 14:10 vaind