Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
13033a4e
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,发现更多精彩内容 >>
提交
13033a4e
编写于
10月 12, 2018
作者:
T
Tomas Matousek
提交者:
Tomáš Matoušek
10月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test loading of analyzer built against netstandard1.3
上级
27bb312f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
224 addition
and
2 deletion
+224
-2
build/Targets/Packages.props
build/Targets/Packages.props
+1
-1
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
+208
-0
src/Compilers/Test/Resources/Core/TestKeys.cs
src/Compilers/Test/Resources/Core/TestKeys.cs
+14
-0
src/Test/Utilities/Portable/Mocks/TestReferences.cs
src/Test/Utilities/Portable/Mocks/TestReferences.cs
+1
-1
未找到文件。
build/Targets/Packages.props
浏览文件 @
13033a4e
...
...
@@ -48,7 +48,7 @@
<MicrosoftCodeAnalysisAnalyzersVersion>
$(RoslynDiagnosticsNugetPackageVersion)
</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisBuildTasksVersion>
2.0.0-rc2-61102-09
</MicrosoftCodeAnalysisBuildTasksVersion>
<MicrosoftCodeAnalysisElfieVersion>
0.10.6
</MicrosoftCodeAnalysisElfieVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
2.0.1
2
</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
2.0.1
4
</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeQualityAnalyzersVersion>
$(RoslynDiagnosticsNugetPackageVersion)
</MicrosoftCodeQualityAnalyzersVersion>
<SystemCompositionVersion>
1.0.31
</SystemCompositionVersion>
<MicrosoftCSharpVersion>
4.3.0
</MicrosoftCSharpVersion>
...
...
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
浏览文件 @
13033a4e
...
...
@@ -9770,6 +9770,214 @@ public void MissingCompilerAssembly()
result
.
Output
.
Trim
());
}
[
ConditionalFact
(
typeof
(
WindowsDesktopOnly
),
typeof
(
IsEnglishLocal
),
Reason
=
"https://github.com/dotnet/roslyn/issues/30321"
)]
public
void
LoadingAnalyzerNetStandard13
()
{
var
analyzerFileName
=
"AnalyzerNS13.dll"
;
var
srcFileName
=
"src.cs"
;
var
analyzerDir
=
Temp
.
CreateDirectory
();
var
analyzerFile
=
analyzerDir
.
CreateFile
(
analyzerFileName
).
WriteAllBytes
(
CreateCSharpAnalyzerNetStandard13
(
Path
.
GetFileNameWithoutExtension
(
analyzerFileName
)));
var
srcFile
=
analyzerDir
.
CreateFile
(
srcFileName
).
WriteAllText
(
"public class C { }"
);
var
result
=
ProcessUtilities
.
Run
(
s_CSharpCompilerExecutable
,
arguments
:
$"/nologo /t:library /analyzer:
{
analyzerFileName
}
{
srcFileName
}
"
,
workingDirectory
:
analyzerDir
.
Path
);
AssertEx
.
AssertEqualToleratingWhitespaceDifferences
(
$"warning AD0001: Analyzer 'TestAnalyzer' threw an exception of type 'System.NotImplementedException' with message '28'."
,
result
.
Output
);
Assert
.
Equal
(
0
,
result
.
ExitCode
);
}
private
static
ImmutableArray
<
byte
>
CreateCSharpAnalyzerNetStandard13
(
string
analyzerAssemblyName
)
{
var
minSystemCollectionsImmutableSource
=
@"
[assembly: System.Reflection.AssemblyVersion(""1.2.3.0"")]
namespace System.Collections.Immutable
{
public struct ImmutableArray<T>
{
}
}
"
;
var
minCodeAnalysisSource
=
@"
using System;
[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")]
namespace Microsoft.CodeAnalysis.Diagnostics
{
[AttributeUsage(AttributeTargets.Class)]
public sealed class DiagnosticAnalyzerAttribute : Attribute
{
public DiagnosticAnalyzerAttribute(string firstLanguage, params string[] additionalLanguages) {}
}
public abstract class DiagnosticAnalyzer
{
public abstract System.Collections.Immutable.ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }
public abstract void Initialize(AnalysisContext context);
}
public abstract class AnalysisContext
{
}
}
namespace Microsoft.CodeAnalysis
{
public sealed class DiagnosticDescriptor
{
}
}
"
;
var
minSystemCollectionsImmutableImage
=
CSharpCompilation
.
Create
(
"System.Collections.Immutable"
,
new
[]
{
SyntaxFactory
.
ParseSyntaxTree
(
minSystemCollectionsImmutableSource
)
},
new
[]
{
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Runtime
)
},
new
CSharpCompilationOptions
(
OutputKind
.
DynamicallyLinkedLibrary
,
cryptoPublicKey
:
TestResources
.
TestKeys
.
PublicKey_b03f5f7f11d50a3a
)).
EmitToArray
();
var
minSystemCollectionsImmutableRef
=
MetadataReference
.
CreateFromImage
(
minSystemCollectionsImmutableImage
);
var
minCodeAnalysisImage
=
CSharpCompilation
.
Create
(
"Microsoft.CodeAnalysis"
,
new
[]
{
SyntaxFactory
.
ParseSyntaxTree
(
minCodeAnalysisSource
)
},
new
[]
{
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Runtime
),
minSystemCollectionsImmutableRef
},
new
CSharpCompilationOptions
(
OutputKind
.
DynamicallyLinkedLibrary
,
cryptoPublicKey
:
TestResources
.
TestKeys
.
PublicKey_31bf3856ad364e35
)).
EmitToArray
();
var
minCodeAnalysisRef
=
MetadataReference
.
CreateFromImage
(
minCodeAnalysisImage
);
var
analyzerSource
=
@"
using System;
using System.Collections.ObjectModel;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Net.Http;
using System.Net.Security;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.Win32.SafeHandles;
[DiagnosticAnalyzer(""C#"")]
public class TestAnalyzer : DiagnosticAnalyzer
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => throw new NotImplementedException(new[]
{
typeof(Win32Exception), // Microsoft.Win32.Primitives
typeof(AppContext), // System.AppContext
typeof(Console), // System.Console
typeof(ValueTuple), // System.ValueTuple
typeof(FileVersionInfo), // System.Diagnostics.FileVersionInfo
typeof(Process), // System.Diagnostics.Process
typeof(ChineseLunisolarCalendar), // System.Globalization.Calendars
typeof(ZipArchive), // System.IO.Compression
typeof(ZipFile), // System.IO.Compression.ZipFile
typeof(FileOptions), // System.IO.FileSystem
typeof(FileAttributes), // System.IO.FileSystem.Primitives
typeof(HttpClient), // System.Net.Http
typeof(AuthenticatedStream), // System.Net.Security
typeof(IOControlCode), // System.Net.Sockets
typeof(RuntimeInformation), // System.Runtime.InteropServices.RuntimeInformation
typeof(SerializationException), // System.Runtime.Serialization.Primitives
typeof(GenericIdentity), // System.Security.Claims
typeof(Aes), // System.Security.Cryptography.Algorithms
typeof(CspParameters), // System.Security.Cryptography.Csp
typeof(AsnEncodedData), // System.Security.Cryptography.Encoding
typeof(AsymmetricAlgorithm), // System.Security.Cryptography.Primitives
typeof(SafeX509ChainHandle), // System.Security.Cryptography.X509Certificates
typeof(IXmlLineInfo), // System.Xml.ReaderWriter
typeof(XmlNode), // System.Xml.XmlDocument
typeof(XPathDocument), // System.Xml.XPath
typeof(XDocumentExtensions), // System.Xml.XPath.XDocument
typeof(CodePagesEncodingProvider),// System.Text.Encoding.CodePages
typeof(ValueTask<>), // System.Threading.Tasks.Extensions
// csc doesn't ship with facades for the following assemblies.
// Analyzers can't use them unless they carry the facade with them.
// typeof(SafePipeHandle), // System.IO.Pipes
// typeof(StackFrame), // System.Diagnostics.StackTrace
// typeof(BindingFlags), // System.Reflection.TypeExtensions
// typeof(AccessControlActions), // System.Security.AccessControl
// typeof(SafeAccessTokenHandle), // System.Security.Principal.Windows
// typeof(Thread), // System.Threading.Thread
}.Length.ToString());
public override void Initialize(AnalysisContext context)
{
}
}"
;
var
analyzerImage
=
CSharpCompilation
.
Create
(
analyzerAssemblyName
,
new
SyntaxTree
[]
{
SyntaxFactory
.
ParseSyntaxTree
(
analyzerSource
)
},
new
MetadataReference
[]
{
minCodeAnalysisRef
,
minSystemCollectionsImmutableRef
,
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
Microsoft_Win32_Primitives
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_AppContext
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Console
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard10
.
System_ValueTuple
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Diagnostics_FileVersionInfo
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Diagnostics_Process
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Diagnostics_StackTrace
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Globalization_Calendars
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_IO_Compression
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_IO_Compression_ZipFile
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_IO_FileSystem
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_IO_FileSystem_Primitives
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_IO_Pipes
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Net_Http
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Net_Security
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Net_Sockets
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Reflection_TypeExtensions
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Runtime
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard11
.
System_Runtime_InteropServices_RuntimeInformation
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Runtime_Serialization_Primitives
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_AccessControl
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_Claims
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_Cryptography_Algorithms
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_Cryptography_Csp
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_Cryptography_Encoding
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_Cryptography_Primitives
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_Cryptography_X509Certificates
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Security_Principal_Windows
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Threading_Thread
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard10
.
System_Threading_Tasks_Extensions
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Xml_ReaderWriter
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Xml_XmlDocument
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Xml_XPath
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Xml_XPath_XDocument
),
MetadataReference
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard13
.
System_Text_Encoding_CodePages
)
},
new
CSharpCompilationOptions
(
OutputKind
.
DynamicallyLinkedLibrary
)).
EmitToArray
();
return
analyzerImage
;
}
[
WorkItem
(
406649
,
"https://devdiv.visualstudio.com/DevDiv/_workitems?id=484417"
)]
[
ConditionalFact
(
typeof
(
WindowsDesktopOnly
),
typeof
(
IsEnglishLocal
),
Reason
=
"https://github.com/dotnet/roslyn/issues/30321"
)]
public
void
MicrosoftDiaSymReaderNativeAltLoadPath
()
...
...
src/Compilers/Test/Resources/Core/TestKeys.cs
浏览文件 @
13033a4e
...
...
@@ -33,5 +33,19 @@ public static class TestKeys
0xfa
,
0xd6
,
0x3d
,
0x74
,
0x5d
,
0x6f
,
0x2d
,
0xe5
,
0xf1
,
0x7e
,
0x5e
,
0xaf
,
0x0f
,
0xc4
,
0x96
,
0x3d
,
0x26
,
0x1c
,
0x8a
,
0x12
,
0x43
,
0x65
,
0x18
,
0x20
,
0x6d
,
0xc0
,
0x93
,
0x34
,
0x4d
,
0x5a
,
0xd2
,
0x93
,
});
public
static
readonly
ImmutableArray
<
byte
>
PublicKey_31bf3856ad364e35
=
ImmutableArray
.
Create
(
new
byte
[]
{
0x00
,
0x24
,
0x00
,
0x00
,
0x04
,
0x80
,
0x00
,
0x00
,
0x94
,
0x00
,
0x00
,
0x00
,
0x06
,
0x02
,
0x00
,
0x00
,
0x00
,
0x24
,
0x00
,
0x00
,
0x52
,
0x53
,
0x41
,
0x31
,
0x00
,
0x04
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0xB5
,
0xFC
,
0x90
,
0xE7
,
0x02
,
0x7F
,
0x67
,
0x87
,
0x1E
,
0x77
,
0x3A
,
0x8F
,
0xDE
,
0x89
,
0x38
,
0xC8
,
0x1D
,
0xD4
,
0x02
,
0xBA
,
0x65
,
0xB9
,
0x20
,
0x1D
,
0x60
,
0x59
,
0x3E
,
0x96
,
0xC4
,
0x92
,
0x65
,
0x1E
,
0x88
,
0x9C
,
0xC1
,
0x3F
,
0x14
,
0x15
,
0xEB
,
0xB5
,
0x3F
,
0xAC
,
0x11
,
0x31
,
0xAE
,
0x0B
,
0xD3
,
0x33
,
0xC5
,
0xEE
,
0x60
,
0x21
,
0x67
,
0x2D
,
0x97
,
0x18
,
0xEA
,
0x31
,
0xA8
,
0xAE
,
0xBD
,
0x0D
,
0xA0
,
0x07
,
0x2F
,
0x25
,
0xD8
,
0x7D
,
0xBA
,
0x6F
,
0xC9
,
0x0F
,
0xFD
,
0x59
,
0x8E
,
0xD4
,
0xDA
,
0x35
,
0xE4
,
0x4C
,
0x39
,
0x8C
,
0x45
,
0x43
,
0x07
,
0xE8
,
0xE3
,
0x3B
,
0x84
,
0x26
,
0x14
,
0x3D
,
0xAE
,
0xC9
,
0xF5
,
0x96
,
0x83
,
0x6F
,
0x97
,
0xC8
,
0xF7
,
0x47
,
0x50
,
0xE5
,
0x97
,
0x5C
,
0x64
,
0xE2
,
0x18
,
0x9F
,
0x45
,
0xDE
,
0xF4
,
0x6B
,
0x2A
,
0x2B
,
0x12
,
0x47
,
0xAD
,
0xC3
,
0x65
,
0x2B
,
0xF5
,
0xC3
,
0x08
,
0x05
,
0x5D
,
0xA9
,
});
}
}
src/Test/Utilities/Portable/Mocks/TestReferences.cs
浏览文件 @
13033a4e
...
...
@@ -230,7 +230,7 @@ public static class v4_0_30319_17626
public
static
class
NetStandard13
{
private
static
readonly
Lazy
<
PortableExecutableReference
>
s_systemRuntime
=
new
Lazy
<
PortableExecutableReference
>(
()
=>
AssemblyMetadata
.
CreateFromImage
(
TestResources
.
NetFX
.
ReferenceAssemblies_netstandard1_
3
.
System_Runtime
).
GetReference
(
display
:
@"System.Runtime.dll (netstandard13 ref)"
),
()
=>
AssemblyMetadata
.
CreateFromImage
(
TestResources
.
NetFX
.
netstandard1
3
.
System_Runtime
).
GetReference
(
display
:
@"System.Runtime.dll (netstandard13 ref)"
),
LazyThreadSafetyMode
.
PublicationOnly
);
public
static
PortableExecutableReference
SystemRuntime
=>
s_systemRuntime
.
Value
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录