提交 6d110f7f 编写于 作者: T Tomas Matousek

Cleanup shims, nuspec of DSR.PortablePdb

上级 359eba13
......@@ -41,13 +41,13 @@ public void GetReaderForFile_NextToPE()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string peFilePath = Path.Combine(tempDir, "Documents.dll");
string pdbFilePath = Path.Combine(tempDir, "Documents.pdb");
Directory.CreateDirectory(tempDir);
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
string searchPath = null;
......@@ -68,15 +68,15 @@ public void GetReaderForFile_SearchPaths()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string searchDir = Path.Combine(tempDir, "Dir");
string peFilePath = Path.Combine(tempDir, "Documents.dll");
string pdbFilePath = Path.Combine(searchDir, "Documents.pdb");
Directory.CreateDirectory(tempDir);
Directory.CreateDirectory(searchDir);
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
string searchPath = searchDir;
......@@ -97,15 +97,15 @@ public void GetReaderForFile_SearchPaths_SubDir1()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string searchDir = Path.Combine(tempDir, "Dir");
string peFilePath = Path.Combine(tempDir, "Documents.dll");
string pdbFilePath = Path.Combine(searchDir, "dll", "Documents.pdb");
Directory.CreateDirectory(tempDir);
Directory.CreateDirectory(Path.GetDirectoryName(pdbFilePath));
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
string searchPath = searchDir;
......@@ -126,15 +126,15 @@ public void GetReaderForFile_SearchPaths_SubDir2()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string searchDir = Path.Combine(tempDir, "Dir");
string peFilePath = Path.Combine(tempDir, "Documents.dll");
string pdbFilePath = Path.Combine(searchDir, "symbols", "dll", "Documents.pdb");
Directory.CreateDirectory(tempDir);
Directory.CreateDirectory(Path.GetDirectoryName(pdbFilePath));
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
string searchPath = searchDir;
......@@ -157,7 +157,7 @@ public void GetReaderForFile_SkipNative1()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string searchDir = Path.Combine(tempDir, "Dir");
string peFilePath = Path.Combine(tempDir, "Documents.dll");
string pdbFilePath = Path.Combine(searchDir, "Documents.pdb");
......@@ -166,9 +166,9 @@ public void GetReaderForFile_SkipNative1()
Directory.CreateDirectory(tempDir);
Directory.CreateDirectory(Path.GetDirectoryName(pdbFilePath));
Directory.CreateDirectory(Path.GetDirectoryName(nativePdbFilePath));
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
PortableShim.File.WriteAllBytes(nativePdbFilePath, TestResources.Documents.Pdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
File.WriteAllBytes(nativePdbFilePath, TestResources.Documents.Pdb);
string searchPath = searchDir;
......@@ -189,7 +189,7 @@ public void GetReaderForFile_SkipNative2()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string searchDir1 = Path.Combine(tempDir, "Dir1");
string searchDir2 = Path.Combine(tempDir, "Dir2");
string peFilePath = Path.Combine(tempDir, "Documents.dll");
......@@ -199,9 +199,9 @@ public void GetReaderForFile_SkipNative2()
Directory.CreateDirectory(tempDir);
Directory.CreateDirectory(Path.GetDirectoryName(pdbFilePath));
Directory.CreateDirectory(Path.GetDirectoryName(nativePdbFilePath));
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
PortableShim.File.WriteAllBytes(nativePdbFilePath, TestResources.Documents.Pdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
File.WriteAllBytes(nativePdbFilePath, TestResources.Documents.Pdb);
string searchPath = searchDir1 + ";" + searchDir2;
......@@ -222,7 +222,7 @@ public void GetReaderForFile_SkipNonMatching()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string searchDir = Path.Combine(tempDir, "Dir");
string peFilePath = Path.Combine(tempDir, "Documents.dll");
string pdbFilePath = Path.Combine(searchDir, "Documents.pdb");
......@@ -231,9 +231,9 @@ public void GetReaderForFile_SkipNonMatching()
Directory.CreateDirectory(tempDir);
Directory.CreateDirectory(Path.GetDirectoryName(pdbFilePath));
Directory.CreateDirectory(Path.GetDirectoryName(anotherPdbFilePath));
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
PortableShim.File.WriteAllBytes(anotherPdbFilePath, TestResources.Async.PortablePdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb);
File.WriteAllBytes(anotherPdbFilePath, TestResources.Async.PortablePdb);
string searchPath = searchDir;
......@@ -254,15 +254,15 @@ public void GetReaderForFile_MatchingNotFound()
{
var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll));
string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString());
string tempDir = Path.Combine(Path.GetDirectoryName(Path.GetTempFileName()), Guid.NewGuid().ToString());
string searchDir = Path.Combine(tempDir, "Dir");
string peFilePath = Path.Combine(tempDir, "Documents.dll");
string anotherPdbFilePath = Path.Combine(searchDir, "symbols", "dll", "Documents.pdb");
Directory.CreateDirectory(tempDir);
Directory.CreateDirectory(Path.GetDirectoryName(anotherPdbFilePath));
PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
PortableShim.File.WriteAllBytes(anotherPdbFilePath, TestResources.Async.PortablePdb);
File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll);
File.WriteAllBytes(anotherPdbFilePath, TestResources.Async.PortablePdb);
string searchPath = searchDir;
......@@ -276,8 +276,8 @@ public void GetReaderForFile_MatchingNotFound()
[Fact]
public void GetReaderFromPdbFile()
{
string filePath = PortableShim.Path.GetTempFileName();
PortableShim.File.WriteAllBytes(filePath, TestResources.Documents.PortablePdb);
string filePath = Path.GetTempFileName();
File.WriteAllBytes(filePath, TestResources.Documents.PortablePdb);
ISymUnmanagedReader symReader;
Assert.Equal(HResult.S_OK, SymBinder.GetReaderFromPdbFile(NotImplementedMetadataProvider.Instance, filePath, out symReader));
......@@ -291,7 +291,7 @@ public void GetReaderFromPdbFile()
Assert.Throws<ObjectDisposedException>(() => symReader.GetDocuments(0, out actualCount, null));
PortableShim.File.Delete(filePath);
File.Delete(filePath);
}
[Fact]
......
{
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc3-24011-00",
"System.Collections": "4.0.11-rc3-24011-00",
"System.Diagnostics.Debug": "4.0.11-rc3-24011-00",
"System.Runtime": "4.1.0-rc3-24011-00",
"System.Runtime.Extensions": "4.1.0-rc3-24011-00",
"System.Runtime.InteropServices": "4.1.0-rc3-24011-00",
"System.IO.FileSystem": "4.0.1-rc3-24011-00",
"NETStandard.Library": "1.5.0-rc3-24011-00"
},
"frameworks": {
"netstandard1.3": {
......
......@@ -15,7 +15,8 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<TargetFrameworkProfile></TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
......@@ -27,9 +28,6 @@
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\ReflectionUtilities.cs">
<Link>Utilities\ReflectionUtilities.cs</Link>
</Compile>
<Compile Include="..\..\Compilers\Core\Portable\PortableShim.cs">
<Link>Utilities\PortableShim.cs</Link>
</Compile>
<Compile Include="..\Roslyn.Reflection.Metadata.Decoding\ArrayShape.cs">
<Link>System.Reflection.Metadata.Decoding\ArrayShape.cs</Link>
</Compile>
......@@ -86,6 +84,7 @@
<Compile Include="SymMethod.cs" />
<Compile Include="SymReader.cs" />
<Compile Include="SymVariable.cs" />
<Compile Include="Utilities\PortableShim.cs" />
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
......
......@@ -17,7 +17,6 @@
<dependency id="System.Collections" version="4.0.11-rc3-24011-00" />
<dependency id="System.Collections.Immutable" version="1.2.0-rc3-24011-00" />
<dependency id="System.Diagnostics.Debug" version="4.0.11-rc3-24011-00" />
<dependency id="System.Globalization" version="4.0.0-rc3-24011-00" />
<dependency id="System.IO" version="4.1.0-rc3-24011-00" />
<dependency id="System.Linq" version="4.1.0-rc3-24011-00" />
<dependency id="System.Reflection" version="4.1.0-rc3-24011-00" />
......@@ -26,9 +25,7 @@
<dependency id="System.Runtime" version="4.1.0-rc3-24011-00" />
<dependency id="System.Runtime.Extensions" version="4.1.0-rc3-24011-00" />
<dependency id="System.Runtime.InteropServices" version="4.1.0-rc3-24011-00" />
<dependency id="System.Text.Encoding" version="4.0.11-rc3-24011-00" />
<dependency id="System.Threading" version="4.0.11-rc3-24011-00" />
<dependency id="System.Xml.XDocument" version="4.0.11-rc3-24011-00" />
</group>
</dependencies>
<language>en-US</language>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using Roslyn.Utilities;
namespace Microsoft.DiaSymReader.PortablePdb
{
internal static class PortableShim
{
private static class CoreNames
{
internal const string System_IO_FileSystem = "System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
internal const string System_Runtime_Extensions = "System.Runtime.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
}
internal static class Environment
{
internal const string TypeName = "System.Environment";
internal static readonly Type Type = ReflectionUtilities.GetTypeFromEither(
contractName: $"{TypeName}, {CoreNames.System_Runtime_Extensions}",
desktopName: TypeName);
internal static Func<string, string> GetEnvironmentVariable = (Func<string, string>)Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(GetEnvironmentVariable), paramTypes: new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, string>));
}
internal static class File
{
internal const string TypeName = "System.IO.File";
internal static readonly Type Type = ReflectionUtilities.GetTypeFromEither(
contractName: $"{TypeName}, {CoreNames.System_IO_FileSystem}",
desktopName: TypeName);
internal static readonly Func<string, Stream> OpenRead = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(OpenRead), paramTypes: new[] { typeof(string) })
.CreateDelegate<Func<string, Stream>>();
internal static readonly Func<string, bool> Exists = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(Exists), new[] { typeof(string) })
.CreateDelegate<Func<string, bool>>();
internal static readonly Func<string, byte[]> ReadAllBytes = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(ReadAllBytes), paramTypes: new[] { typeof(string) })
.CreateDelegate<Func<string, byte[]>>();
}
}
}
{
"dependencies": {
"System.Xml.XDocument": "4.0.11-rc3-24011-00",
"System.AppContext": "4.1.0-rc3-24011-00"
},
"frameworks": {
"netstandard1.3": {}
"netstandard1.1": {}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册