Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Common/test-runtime/project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-beta-23328",
"Microsoft.NETCore.TestHost": "1.0.0-beta-23328",
"Microsoft.NETCore.Console": "1.0.0-beta-23328",
"Microsoft.NETCore.Platforms": "1.0.1-beta-23419",
"Microsoft.NETCore.TestHost": "1.0.0-beta-23419",
"Microsoft.NETCore.Console": "1.0.0-beta-23419",

"coveralls.io": "1.4",
"OpenCover": "4.6.166",
Expand Down
7,568 changes: 3,789 additions & 3,779 deletions src/Common/test-runtime/project.lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DriveInfoWindowsTests
{
[Fact]
[PlatformSpecific(PlatformID.Windows)]
[ActiveIssue(4040)]
public void TestConstructor()
{
string[] invalidInput = { ":", "://", @":\", ":/", @":\\", "Az", "1", "a1", @"\\share", @"\\", "c ", string.Empty, " c" };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22609.0
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.TypeExtensions.CoreCLR", "src\System.Reflection.TypeExtensions.CoreCLR.csproj", "{1E689C1B-690C-4799-BDE9-6E7990585894}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.TypeExtensions.Tests", "tests\System.Reflection.TypeExtensions.Tests.csproj", "{089444FE-8FF5-4D8F-A51B-32D026425F6B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.TypeExtensions", "ref\System.Reflection.TypeExtensions.csproj", "{DA96367E-04D1-4057-997E-AED4A2773F0D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.TypeExtensions.CoreCLR.Tests", "tests\CoreCLR\System.Reflection.TypeExtensions.CoreCLR.Tests.csproj", "{BED9F8D5-7420-404E-9EAD-D9148C16EAC1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +25,14 @@ Global
{089444FE-8FF5-4D8F-A51B-32D026425F6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{089444FE-8FF5-4D8F-A51B-32D026425F6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{089444FE-8FF5-4D8F-A51B-32D026425F6B}.Release|Any CPU.Build.0 = Release|Any CPU
{DA96367E-04D1-4057-997E-AED4A2773F0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA96367E-04D1-4057-997E-AED4A2773F0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA96367E-04D1-4057-997E-AED4A2773F0D}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{DA96367E-04D1-4057-997E-AED4A2773F0D}.Release|Any CPU.Build.0 = Debug|Any CPU
{BED9F8D5-7420-404E-9EAD-D9148C16EAC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BED9F8D5-7420-404E-9EAD-D9148C16EAC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BED9F8D5-7420-404E-9EAD-D9148C16EAC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BED9F8D5-7420-404E-9EAD-D9148C16EAC1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,20 @@ public static partial class EventInfoExtensions
public static System.Reflection.MethodInfo GetRemoveMethod(this System.Reflection.EventInfo eventInfo) { return default(System.Reflection.MethodInfo); }
public static System.Reflection.MethodInfo GetRemoveMethod(this System.Reflection.EventInfo eventInfo, bool nonPublic) { return default(System.Reflection.MethodInfo); }
}
public static partial class MemberInfoExtensions
{
public static bool HasMetadataToken(this MemberInfo member) { return default(bool); }
public static int GetMetadataToken(this MemberInfo member) { return default(int); }
}
public static partial class MethodInfoExtensions
{
public static System.Reflection.MethodInfo GetBaseDefinition(this System.Reflection.MethodInfo method) { return default(System.Reflection.MethodInfo); }
}
public static partial class ModuleExtensions
{
public static bool HasModuleVersionId(this Module module) { return default(bool); }
public static Guid GetModuleVersionId(this Module module) { return default(Guid); }
}
public static partial class PropertyInfoExtensions
{
public static System.Reflection.MethodInfo[] GetAccessors(this System.Reflection.PropertyInfo property) { return default(System.Reflection.MethodInfo[]); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<OutputType>Library</OutputType>
<PackageTargetFramework>dotnet5.1</PackageTargetFramework>
</PropertyGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions src/System.Reflection.TypeExtensions/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="NoMetadataTokenAvailable" xml:space="preserve">
<value>There is no metadata token available for the given member.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>System.Reflection.TypeExtensions</AssemblyName>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<OutputType>Library</OutputType>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<NuGetTargetFrameworkMoniker>DNXCore,Version=v5.0</NuGetTargetFrameworkMoniker>
<ProjectGuid>{1e689c1b-690c-4799-bde9-6e7990585894}</ProjectGuid>
<ProjectGuid>{1E689C1B-690C-4799-BDE9-6E7990585894}</ProjectGuid>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
// look like infinite recursion in the implementation. Callers compiled against
// the contract will still be able to invoke them as extension methods and get
// source compatibility with classic reflection code.
//
// However, this does not apply if there is no 1:1 correspondence with an instance
// in mscorlib. New extension methods should be merked with 'this'.

namespace System.Reflection
{
Expand Down Expand Up @@ -270,6 +273,67 @@ public static MethodInfo GetRemoveMethod(EventInfo eventInfo, bool nonPublic)
}
}

public static class MemberInfoExtensions
{

/// <summary>
/// Determines if there is a metadata token available for the given member.
/// <see cref="GetMetadataToken(MemberInfo)"/> throws <see cref="InvalidOperationException"/> otherwise.
/// </summary>
/// <remarks>This maybe</remarks>
public static bool HasMetadataToken(this MemberInfo member)
{
Requires.NotNull(member, "member");

try
{
return GetMetadataTokenOrZeroOrThrow(member) != 0;
}
catch (InvalidOperationException)
{
// Thrown for unbaked ref-emit members/types.
// Other cases such as typeof(byte[]).MetadataToken will be handled by comparison to zero above.
return false;
}
}

/// <summary>
/// Gets a metadata token for the given member if available. The returned token is never nil.
/// </summary>
/// <exception cref="InvalidOperationException">
/// There is no metadata token available. <see cref="HasMetadataToken(MemberInfo)"/> returns false in this case.
/// </exception>
public static int GetMetadataToken(this MemberInfo member)
{
Requires.NotNull(member, "member");

int token = GetMetadataTokenOrZeroOrThrow(member);

if (token == 0)
{
throw new InvalidOperationException(SR.NoMetadataTokenAvailable);
}

return token;
}

private static int GetMetadataTokenOrZeroOrThrow(MemberInfo member)
{
int token = member.MetadataToken;

// Tokens have MSB = table index, 3 LSBs = row index
// row index of 0 is a nil token
const int rowMask = 0x00FFFFFF;
if ((token & rowMask) == 0)
{
// Nil token is returned for edge cases like typeof(byte[]).MetadataToken.
return 0;
}

return token;
}
}

public static class MethodInfoExtensions
{
public static MethodInfo GetBaseDefinition(MethodInfo method)
Expand All @@ -279,6 +343,21 @@ public static MethodInfo GetBaseDefinition(MethodInfo method)
}
}

public static class ModuleExtensions
{
public static bool HasModuleVersionId(this Module module)
{
Requires.NotNull(module, "module");
return true; // not expected to fail on platforms with Module.ModuleVersionId built-in.
}

public static Guid GetModuleVersionId(this Module module)
{
Requires.NotNull(module, "module");
return module.ModuleVersionId;
}
}

public static class PropertyInfoExtensions
{
public static MethodInfo[] GetAccessors(PropertyInfo property)
Expand Down
Loading