Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1cd08cc2
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1cd08cc2
编写于
8月 02, 2018
作者:
S
Sam Harwell
提交者:
GitHub
8月 02, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29029 from siegfriedpammer/decompiler-v4
Update ICSharpCode.Decompiler to 4.0-beta1
上级
f251e7a1
3347e95c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
28 addition
and
26 deletion
+28
-26
build/Targets/Packages.props
build/Targets/Packages.props
+1
-1
build/config/SignToolData.json
build/config/SignToolData.json
+0
-4
src/EditorFeatures/Core/Implementation/MetadataAsSource/MetadataAsSourceFileService.cs
...mentation/MetadataAsSource/MetadataAsSourceFileService.cs
+27
-15
src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb
src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb
+0
-4
src/VisualStudio/Setup/AssemblyRedirects.cs
src/VisualStudio/Setup/AssemblyRedirects.cs
+0
-1
src/VisualStudio/Setup/Roslyn.VisualStudio.Setup.csproj
src/VisualStudio/Setup/Roslyn.VisualStudio.Setup.csproj
+0
-1
未找到文件。
build/Targets/Packages.props
浏览文件 @
1cd08cc2
...
...
@@ -14,7 +14,7 @@
<dotnetxunitVersion>
2.3.1
</dotnetxunitVersion>
<FakeSignVersion>
0.9.2
</FakeSignVersion>
<HumanizerCoreVersion>
2.2.0
</HumanizerCoreVersion>
<ICSharpCodeDecompilerVersion>
3.1.0.3652
</ICSharpCodeDecompilerVersion>
<ICSharpCodeDecompilerVersion>
4.0.0.4285-beta1
</ICSharpCodeDecompilerVersion>
<LibGit2SharpVersion>
0.22.0
</LibGit2SharpVersion>
<MicroBuildCoreVersion>
0.2.0
</MicroBuildCoreVersion>
<MicroBuildCoreSentinelVersion>
1.0.0
</MicroBuildCoreSentinelVersion>
...
...
build/config/SignToolData.json
浏览文件 @
1cd08cc2
...
...
@@ -185,10 +185,6 @@
"Microsoft.VisualStudio.Threading.resources.dll"
,
"Microsoft.VisualStudio.Validation.dll"
,
"Microsoft.Win32.Primitives.dll"
,
"Mono.Cecil.dll"
,
"Mono.Cecil.Mdb.dll"
,
"Mono.Cecil.Pdb.dll"
,
"Mono.Cecil.Rocks.dll"
,
"Nerdbank.FullDuplexStream.dll"
,
"Newtonsoft.Json.dll"
,
"NuGet.CommandLine.2.8.5.nupkg"
,
...
...
src/EditorFeatures/Core/Implementation/MetadataAsSource/MetadataAsSourceFileService.cs
浏览文件 @
1cd08cc2
...
...
@@ -7,12 +7,14 @@
using
System.Globalization
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection.PortableExecutable
;
using
System.Runtime.CompilerServices
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
ICSharpCode.Decompiler
;
using
ICSharpCode.Decompiler.CSharp
;
using
ICSharpCode.Decompiler.CSharp.Transforms
;
using
ICSharpCode.Decompiler.Metadata
;
using
ICSharpCode.Decompiler.TypeSystem
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.CodeAnalysis.MetadataAsSource
;
...
...
@@ -20,7 +22,6 @@
using
Microsoft.CodeAnalysis.SymbolMapping
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.Text
;
using
Mono.Cecil
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.MetadataAsSource
...
...
@@ -224,10 +225,11 @@ private async Task<Document> DecompileSymbolAsync(Document temporaryDocument, IS
}
// Load the assembly.
var
assemblyDefinition
=
AssemblyDefinition
.
ReadAssembly
(
assemblyLocation
,
new
ReaderParameters
()
{
AssemblyResolver
=
new
RoslynAssemblyResolver
(
compilation
)
}
);
var
pefile
=
new
PEFile
(
assemblyLocation
,
PEStreamOptions
.
PrefetchEntireImage
);
// Initialize a decompiler with default settings.
var
decompiler
=
new
CSharpDecompiler
(
assemblyDefinition
.
MainModule
,
new
DecompilerSettings
());
var
settings
=
new
DecompilerSettings
(
LanguageVersion
.
Latest
);
var
decompiler
=
new
CSharpDecompiler
(
pefile
,
new
RoslynAssemblyResolver
(
compilation
),
settings
);
// Escape invalid identifiers to prevent Roslyn from failing to parse the generated code.
// (This happens for example, when there is compiler-generated code that is not yet recognized/transformed by the decompiler.)
decompiler
.
AstTransforms
.
Add
(
new
EscapeInvalidIdentifiers
());
...
...
@@ -238,8 +240,8 @@ private async Task<Document> DecompileSymbolAsync(Document temporaryDocument, IS
// Add header to match output of metadata-only view.
// (This also makes debugging easier, because you can see which assembly was decompiled inside VS.)
var
header
=
$"#region
{
FeaturesResources
.
Assembly
}
{
assemblyDefinition
.
FullName
}
"
+
Environment
.
NewLine
+
$"//
{
assembly
Definition
.
MainModule
.
FileName
}
"
+
Environment
.
NewLine
var
header
=
$"#region
{
FeaturesResources
.
Assembly
}
{
pefile
.
FullName
}
"
+
Environment
.
NewLine
+
$"//
{
assembly
Location
}
"
+
Environment
.
NewLine
+
$"// Decompiled with ICSharpCode.Decompiler
{
decompilerVersion
.
FileVersion
}
"
+
Environment
.
NewLine
+
"#endregion"
+
Environment
.
NewLine
;
...
...
@@ -251,28 +253,31 @@ private async Task<Document> DecompileSymbolAsync(Document temporaryDocument, IS
private
class
RoslynAssemblyResolver
:
IAssemblyResolver
{
private
readonly
Compilation
parentCompilation
;
private
static
readonly
Version
zeroVersion
=
new
Version
(
0
,
0
,
0
,
0
);
public
RoslynAssemblyResolver
(
Compilation
parentCompilation
)
{
this
.
parentCompilation
=
parentCompilation
;
}
public
AssemblyDefinition
Resolve
(
AssemblyNameReference
name
)
{
return
Resolve
(
name
,
new
ReaderParameters
());
}
public
AssemblyDefinition
Resolve
(
AssemblyNameReference
name
,
ReaderParameters
parameters
)
public
PEFile
Resolve
(
IAssemblyReference
name
)
{
foreach
(
var
assembly
in
parentCompilation
.
GetReferencedAssemblySymbols
())
{
// First, find the correct IAssemblySymbol by name and PublicKeyToken.
if
(
assembly
.
Identity
.
Name
!=
name
.
Name
||
!
assembly
.
Identity
.
PublicKeyToken
.
SequenceEqual
(
name
.
PublicKeyToken
??
Array
.
Empty
<
byte
>()))
{
continue
;
}
if
(
assembly
.
Identity
.
Version
!=
name
.
Version
// Normally we skip versions that do not match, except if the reference is "mscorlib" (see comments below)
// or if the name.Version is '0.0.0.0'. This is because we require the metadata of all transitive references
// and modules, to achieve best decompilation results.
// In the case of .NET Standard projects for example, the 'netstandard' reference contains no references
// with actual versions. All versions are '0.0.0.0', therefore we have to ignore those version numbers,
// and can just use the references provided by Roslyn instead.
if
(
assembly
.
Identity
.
Version
!=
name
.
Version
&&
name
.
Version
!=
zeroVersion
&&
!
string
.
Equals
(
"mscorlib"
,
assembly
.
Identity
.
Name
,
StringComparison
.
OrdinalIgnoreCase
))
{
// MSBuild treats mscorlib special for the purpose of assembly resolution/unification, where all
...
...
@@ -280,17 +285,24 @@ public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters p
continue
;
}
// reference assemblies should be fine here
..
.
// reference assemblies should be fine here
, we only need the metadata of references
.
var
reference
=
parentCompilation
.
GetMetadataReference
(
assembly
);
return
AssemblyDefinition
.
ReadAssembly
(
reference
.
Display
);
return
new
PEFile
(
reference
.
Display
,
PEStreamOptions
.
PrefetchMetadata
);
}
// not found
return
null
;
}
public
void
Dispose
(
)
public
PEFile
ResolveModule
(
PEFile
mainModule
,
string
moduleName
)
{
// Primitive implementation to support multi-module assemblies
// where all modules are located next to the main module.
string
baseDirectory
=
Path
.
GetDirectoryName
(
mainModule
.
FileName
);
string
moduleFileName
=
Path
.
Combine
(
baseDirectory
,
moduleName
);
if
(!
File
.
Exists
(
moduleFileName
))
return
null
;
return
new
PEFile
(
moduleFileName
,
PEStreamOptions
.
PrefetchMetadata
);
}
}
...
...
src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb
浏览文件 @
1cd08cc2
...
...
@@ -538,10 +538,6 @@ Public Class BuildDevDivInsertionFiles
add
(
"Vsix\Roslyn.VisualStudio.Setup\System.Composition.Hosting.dll"
)
add
(
"Vsix\Roslyn.VisualStudio.Setup\System.Composition.TypedParts.dll"
)
add
(
"Vsix\Roslyn.VisualStudio.Setup\System.Threading.Tasks.Extensions.dll"
)
add
(
"Vsix\Roslyn.VisualStudio.Setup\Mono.Cecil.dll"
)
add
(
"Vsix\Roslyn.VisualStudio.Setup\Mono.Cecil.Mdb.dll"
)
add
(
"Vsix\Roslyn.VisualStudio.Setup\Mono.Cecil.Pdb.dll"
)
add
(
"Vsix\Roslyn.VisualStudio.Setup\Mono.Cecil.Rocks.dll"
)
add
(
"Vsix\Roslyn.VisualStudio.Setup\ICSharpCode.Decompiler.dll"
)
add
(
"Dlls\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler.vsdconfig"
)
add
(
"Dlls\Microsoft.CodeAnalysis.VisualBasic.ResultProvider\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.vsdconfig"
)
...
...
src/VisualStudio/Setup/AssemblyRedirects.cs
浏览文件 @
1cd08cc2
...
...
@@ -44,7 +44,6 @@
[
assembly
:
ProvideCodeBase
(
CodeBase
=
@"$PackageFolder$\System.Threading.Tasks.Extensions.dll"
)]
[
assembly
:
ProvideCodeBase
(
CodeBase
=
@"$PackageFolder$\Humanizer.dll"
)]
[
assembly
:
ProvideCodeBase
(
CodeBase
=
@"$PackageFolder$\Mono.Cecil.dll"
)]
[
assembly
:
ProvideCodeBase
(
CodeBase
=
@"$PackageFolder$\ICSharpCode.Decompiler.dll"
)]
[
assembly
:
ProvideBindingRedirection
(
...
...
src/VisualStudio/Setup/Roslyn.VisualStudio.Setup.csproj
浏览文件 @
1cd08cc2
...
...
@@ -237,7 +237,6 @@
<NuGetPackageToIncludeInVsix
Include=
"System.Composition.Hosting"
/>
<NuGetPackageToIncludeInVsix
Include=
"System.Threading.Tasks.Extensions"
/>
<NuGetPackageToIncludeInVsix
Include=
"ICSharpCode.Decompiler"
/>
<NuGetPackageToIncludeInVsix
Include=
"Mono.Cecil"
/>
</ItemGroup>
<ItemGroup>
<VSIXSourceItem
Include=
"$(NuGetPackageRoot)\SQLitePCLRaw.bundle_green\1.1.2\lib\net45\SQLitePCLRaw.batteries_green.dll"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录