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
Describe the bug
Generic attributes were introduced with C# 11 and .NET 7 and are therefore not supported in .NET Framework 4.8 and prior. If another component now tries to read all attributes for the RestResponse<T> class a NotSupportedException is thrown. In our case an additional component not under our control calls Type.GetCustomAttributes for all loaded types.
To Reproduce
Create a .NET Framework 4.8 project
Call typeof(RestResponse<>).GetCustomAttributes()
Expected behavior
No exception should be thrown.
Stack trace
System.NotSupportedException
HResult=0x80131515
Message=Generic types are not valid.
Source=mscorlib
StackTrace:
at System.RuntimeTypeHandle.CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttributes(MemberInfo element)
at RestSharpTest.Program.Main(String[] args) in C:\Test\RestSharpTest\Program.cs:line 15
Desktop (please complete the following information):
OS: Windows 10 22H2
.NET version: .NET Framework 4.8
Version: 111.3.0+
The text was updated successfully, but these errors were encountered:
It's not framework related as RestSharp builds for .NET Framework.
I am not sure if RestSharp has to account for some tools that make calls like that. In addition, the attribute is not even public. It's hard to accommodate for cases where people use reflections to get the library internals and crash because of that.
Describe the bug
Generic attributes were introduced with C# 11 and .NET 7 and are therefore not supported in .NET Framework 4.8 and prior. If another component now tries to read all attributes for the
RestResponse<T>
class aNotSupportedException
is thrown. In our case an additional component not under our control callsType.GetCustomAttributes
for all loaded types.To Reproduce
typeof(RestResponse<>).GetCustomAttributes()
Expected behavior
No exception should be thrown.
Stack trace
System.NotSupportedException
HResult=0x80131515
Message=Generic types are not valid.
Source=mscorlib
StackTrace:
at System.RuntimeTypeHandle.CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttributes(MemberInfo element)
at RestSharpTest.Program.Main(String[] args) in C:\Test\RestSharpTest\Program.cs:line 15
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: