https://github.com/StefH/ReflectionBridge
ReflectionBridge : Provides some extensions which define a bridge for the differences between Type and TypeInfo.
https://github.com/StefH/ReflectionBridge
netstandard reflection type typeinfo
Last synced: 11 months ago
JSON representation
ReflectionBridge : Provides some extensions which define a bridge for the differences between Type and TypeInfo.
- Host: GitHub
- URL: https://github.com/StefH/ReflectionBridge
- Owner: StefH
- License: mit
- Created: 2015-03-09T19:00:30.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-01-13T09:16:18.000Z (about 8 years ago)
- Last Synced: 2024-04-14T13:08:22.207Z (almost 2 years ago)
- Topics: netstandard, reflection, type, typeinfo
- Language: C#
- Homepage:
- Size: 82 KB
- Stars: 25
- Watchers: 9
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ReflectionBridge
[](https://ci.appveyor.com/project/StefH/ReflectionBridge)
[](https://www.nuget.org/packages/ReflectionBridge)
Provides some extensions which define a bridge for the differences between Type and TypeInfo.
This library can be used for the following Frameworks:
- net2.0
- net3.5
- net4.0
- net4.5
- net4.5.x
- net4.6
- net4.6.1
- netcore4.5 Windows Store apps [only up until version 0.0.12]
- netcore4.5.1 Windows Store apps (Windows 8.1) [only up until version 0.0.12]
- netcore5.0 Windows Universal [only up until version 0.0.12]
- dnx451 [only up until version 0.0.12]
- dnxcore5 [only up until version 0.0.12]
- uap10.0
- sl5 (SilverLight 5.0) [only up until version 0.0.12]
- netstandard1.3 and up
So instead of doing this in your code:
```c#
string s = "example";
#if (!(NET40 || NET35 || NET20))
Type t = s.BaseType;
#else
Type t = s.GetTypeInfo().BaseType;
#endif
```
You can just do:
```c#
string s = "example";
Type t = s.BaseType();
```
An extension method in this project like this does the if-def:
```c#
public static Type BaseType(this Type type)
{
#if REFLECTIONBRIDGE && (!(NET40 || NET35 || NET20))
return type.GetTypeInfo().BaseType;
#else
return type.BaseType;
#endif
}
```
Please provide feedback on this project.