I have a Portable Classlibrary.
".NETPortable,Version=v4.5,Profile=Profile75"
The code
typeof(T).GetMethods()
with the error
cannot resolve symbol 'GetMethods'
my project.json
{
"supports": {},
"dependencies": {
},
"frameworks": {
".NETPortable,Version=v4.5,Profile=Profile75": { },
"net541": { },
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516",
"System.Reflection": "4.1.0-beta-23516",
"System.Collections.Concurrent": "4.0.11-beta-23516"
}
}
}
}
and the key property in the csproj file
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile75</TargetFrameworkProfile>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
I don't know much about that specific profile (and testing anything with that profile is giving me massive errors around predefined types not being available), but I do know that reflection is now split between Type
and TypeInfo
.
Chances are you want a using
directive of
using System.Reflection;
then use:
typeof(T).GetTypeInfo().DeclaredMethods
(Using the DeclaredMethods
property.) Note that that only returns the methods declared in the given class, not inherited ones, which may not be what you need.
or
typeof(T).GetTypeInfo().GetMethods()
The latter claims to be supported by the PCL, but may not be - in my experience, the version information in MSDN is becoming increasingly hard to trust, with the DNX varieties adding more complexity.
See more on this question at Stackoverflow