提交 31a83f08 编写于 作者: A AlekseyTs

Merge remote-tracking branch 'upstream/master' into merge-master-into-future20160418-171208

......@@ -2,94 +2,10 @@
// Jenkins DSL: https://github.com/jenkinsci/job-dsl-plugin/wiki
import jobs.generation.Utilities;
import static Constants.*;
def project = GithubProject
class Constants {
// Number of minutes a build job is given to complete.
static final BuildTimeLimit = 120;
}
static void addLogRotator(def myJob) {
myJob.with {
logRotator {
daysToKeep(90)
numToKeep(-1)
artifactDaysToKeep(21)
artifactNumToKeep(-1)
}
}
}
static void addConcurrentBuild(def myJob, String category) {
myJob.with {
concurrentBuild(true)
if (category != null) {
throttleConcurrentBuilds {
throttleDisabled(false)
maxTotal(0)
maxPerNode(1)
categories([category])
}
}
}
}
static void addScm(def myJob, String branchName, String refspecName = '') {
myJob.with {
scm {
git {
remote {
github('dotnet/roslyn', 'https', 'github.com')
name('')
refspec(refspecName)
}
branch(branchName)
wipeOutWorkspace(true)
shallowClone(true)
}
}
}
}
static void addWrappers(def myJob) {
myJob.with {
wrappers {
timeout {
absolute(BuildTimeLimit)
abortBuild()
}
timestamps()
}
}
}
static void addArtifactArchiving(def myJob, String patternString, String excludeString) {
myJob.with {
publishers {
flexiblePublish {
conditionalAction {
condition {
status('ABORTED', 'FAILURE')
}
publishers {
archiveArtifacts {
allowEmpty(true)
defaultExcludes(false)
exclude(excludeString)
fingerprint(false)
onlyIfSuccessful(false)
pattern(patternString)
}
}
}
}
}
}
}
// Email the results of aborted / failed jobs to our infrastructure alias
static void addEmailPublisher(def myJob) {
myJob.with {
publishers {
......@@ -101,94 +17,29 @@ static void addEmailPublisher(def myJob) {
}
}
static void addUnitPublisher(def myJob) {
myJob.with {
configure { node ->
node / 'publishers' << {
'xunit'('plugin': 'xunit@1.97') {
'types' {
'XUnitDotNetTestType' {
'pattern'('**/xUnitResults/*.xml')
'skipNoTestFiles'(false)
'failIfNotNew'(true)
'deleteOutputFiles'(true)
'stopProcessingIfError'(true)
}
}
'thresholds' {
'org.jenkinsci.plugins.xunit.threshold.FailedThreshold' {
'unstableThreshold'('')
'unstableNewThreshold'('')
'failureThreshold'('0')
'failureNewThreshold'('')
}
'org.jenkinsci.plugins.xunit.threshold.SkippedThreshold' {
'unstableThreshold'('')
'unstableNewThreshold'('')
'failureThreshold'('')
'failureNewThreshold'('')
}
}
'thresholdMode'('1')
'extraConfiguration' {
testTimeMargin('3000')
}
}
}
}
}
}
static void addPushTrigger(def myJob) {
myJob.with {
triggers {
githubPush()
}
}
}
// Generates the standard trigger phrases. This is the regex which ends up matching lines like:
// test win32 please
static String generateTriggerPhrase(String jobName, String opsysName, String triggerKeyword = 'this') {
return "(?i).*test\\W+(${jobName.replace('_', '/').substring(7)}|${opsysName}|${triggerKeyword}|${opsysName}\\W+${triggerKeyword}|${triggerKeyword}\\W+${opsysName})\\W+please.*";
}
static void addPullRequestTrigger(def myJob, String jobName, String triggerPhraseText, Boolean triggerPhraseOnly = false) {
myJob.with {
triggers {
pullRequest {
admin('Microsoft')
useGitHubHooks(true)
triggerPhrase(triggerPhraseText)
onlyTriggerPhrase(triggerPhraseOnly)
autoCloseFailedPullRequests(false)
orgWhitelist('Microsoft')
allowMembersOfWhitelistedOrgsAsAdmin(true)
permitAll(true)
extensions {
commitStatus {
context(jobName.replace('_', '/').substring(7))
}
}
}
}
}
}
static void addStandardJob(def myJob, String jobName, String branchName, String triggerPhrase, Boolean triggerPhraseOnly = false) {
addLogRotator(myJob)
addWrappers(myJob)
static void addRoslynJob(def myJob, String jobName, String branchName, String triggerPhrase, Boolean triggerPhraseOnly = false) {
def includePattern = "Binaries/**/*.pdb,Binaries/**/*.xml,Binaries/**/*.log,Binaries/**/*.dmp,Binaries/**/*.zip,Binaries/**/*.png,Binaries/**/*.xml"
def excludePattern = "Binaries/Obj/**,Binaries/Bootstrap/**,Binaries/**/nuget*.zip"
addArtifactArchiving(myJob, includePattern, excludePattern)
if (branchName == 'prtest') {
addPullRequestTrigger(myJob, jobName, triggerPhrase, triggerPhraseOnly);
addScm(myJob, '${sha1}', '+refs/pull/*:refs/remotes/origin/pr/*')
Utilities.addArchival(myJob, includePattern, excludePattern)
// Create the standard job. This will setup parameter, SCM, timeout, etc ...
def projectName = 'dotnet/roslyn'
def isPr = branchName == 'prtest'
def defaultBranch = "*/${branchName}"
Utilities.standardJobSetup(myJob, projectName, isPr, defaultBranch)
// Need to setup the triggers for the job
if (isPr) {
def contextName = jobName.replace('_', '/').substring(7)
Utilities.addGithubPRTrigger(myJob, contextName, triggerPhrase, triggerPhraseOnly)
} else {
addPushTrigger(myJob)
addScm(myJob, "*/${branchName}")
Utilities.addGithubPushTrigger(myJob)
addEmailPublisher(myJob)
}
}
......@@ -237,7 +88,6 @@ set TMP=%TEMP%
}
Utilities.setMachineAffinity(myJob, 'Windows_NT', 'latest-or-auto')
// Generic throttling for Windows, no category
addConcurrentBuild(myJob, null)
break;
case 'linux':
myJob.with {
......@@ -246,7 +96,6 @@ set TMP=%TEMP%
shell("./cibuild.sh --nocache --debug")
}
}
addConcurrentBuild(myJob, 'roslyn/lin/unit')
break;
case 'mac':
myJob.with {
......@@ -255,13 +104,12 @@ set TMP=%TEMP%
shell("./cibuild.sh --nocache --debug")
}
}
addConcurrentBuild(myJob, 'roslyn/mac/unit')
triggerPhraseOnly = true;
break;
}
addUnitPublisher(myJob)
addStandardJob(myJob, jobName, branchName, triggerPhrase, triggerPhraseOnly);
Utilities.addXUnitDotNETResults(myJob, '**/xUnitResults/*.xml')
addRoslynJob(myJob, jobName, branchName, triggerPhrase, triggerPhraseOnly)
}
}
}
......@@ -284,7 +132,6 @@ set TMP=%TEMP%
}
Utilities.setMachineAffinity(determinismJob, 'Windows_NT', 'latest-or-auto')
addConcurrentBuild(determinismJob, null)
addStandardJob(determinismJob, determinismJobName, branchName, "(?i).*test\\W+determinism.*", true);
addRoslynJob(determinismJob, determinismJobName, branchName, "(?i).*test\\W+determinism.*", true);
}
// 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.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using System.Linq;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.Metadata.PE
......@@ -105,5 +104,36 @@ public void Test1()
Assert.Equal(SymbolKind.Field, csFields.GetMembers("Fff").Single().Kind);
Assert.Equal(SymbolKind.Method, csFields.GetMembers("FfF").Single().Kind);
}
[Fact]
[WorkItem(193333, "https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?_a=edit&id=193333")]
public void EnumWithPrivateValueField()
{
var il = @"
.class public auto ansi sealed TestEnum
extends [mscorlib]System.Enum
{
.field private specialname rtspecialname int32 value__
.field public static literal valuetype TestEnum Value1 = int32(0x00000000)
.field public static literal valuetype TestEnum Value2 = int32(0x00000001)
} // end of class TestEnum
";
var text = @"
class Program
{
static void Main()
{
TestEnum val = TestEnum.Value1;
System.Console.WriteLine(val.ToString());
val = TestEnum.Value2;
System.Console.WriteLine(val.ToString());
}
}
";
var compilation = CreateCompilationWithCustomILSource(text, il, options:TestOptions.DebugExe);
CompileAndVerify(compilation, expectedOutput: @"Value1
Value2");
}
}
}
......@@ -1115,17 +1115,30 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Dim moduleSymbol = Me.ContainingPEModule
Dim [module] = moduleSymbol.Module
Dim isOrdinaryStruct As Boolean = Me.TypeKind = TypeKind.Structure AndAlso
(Me.SpecialType = SpecialType.None OrElse Me.SpecialType = SpecialType.System_Nullable_T)
Try
For Each fieldDef In [module].GetFieldsOfTypeOrThrow(_handle)
Dim import As Boolean = True
Dim import As Boolean
Try
If Not ([module].ShouldImportField(fieldDef, moduleSymbol.ImportOptions) OrElse
isOrdinaryStruct AndAlso ([module].GetFieldDefFlagsOrThrow(fieldDef) And FieldAttributes.Static) = 0) Then
import = False
import = [module].ShouldImportField(fieldDef, moduleSymbol.ImportOptions)
If Not import Then
Select Case Me.TypeKind
Case TypeKind.Structure
Dim specialType = Me.SpecialType
If specialType = SpecialType.None OrElse specialType = SpecialType.System_Nullable_T Then
' This is an ordinary struct
If ([module].GetFieldDefFlagsOrThrow(fieldDef) And FieldAttributes.Static) = 0 Then
import = True
End If
End If
Case TypeKind.Enum
If ([module].GetFieldDefFlagsOrThrow(fieldDef) And FieldAttributes.Static) = 0 Then
import = True
End If
End Select
End If
Catch mrEx As BadImageFormatException
End Try
......
......@@ -240,6 +240,39 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Symbols.Metadata.PE
Assert.Equal(-8L, Int64Value.GetConstantValue(SymbolsInProgress(Of FieldSymbol).Empty).Int64Value)
End Sub
<Fact>
<WorkItem(193333, "https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?_a=edit&id=193333")>
Public Sub EnumWithPrivateValueField()
Dim ilSource = "
.class public auto ansi sealed TestEnum
extends [mscorlib]System.Enum
{
.field private specialname rtspecialname int32 value__
.field public static literal valuetype TestEnum Value1 = int32(0x00000000)
.field public static literal valuetype TestEnum Value2 = int32(0x00000001)
} // end of class TestEnum
"
Dim vbSource =
<compilation>
<file>
Module Module1
Sub Main()
Dim val as TestEnum = TestEnum.Value1
System.Console.WriteLine(val.ToString())
val = TestEnum.Value2
System.Console.WriteLine(val.ToString())
End Sub
End Module
</file>
</compilation>
Dim compilation = CreateCompilationWithCustomILSource(vbSource, ilSource, includeVbRuntime:=True, options:=TestOptions.DebugExe)
CompileAndVerify(compilation, expectedOutput:="Value1
Value2")
End Sub
End Class
......
......@@ -840,8 +840,9 @@ public async Task DottedPattern7()
}
[WorkItem(1174255, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1174255")]
[WorkItem(8009, "https://github.com/dotnet/roslyn/issues/8009")]
[Fact, Trait(Traits.Feature, Traits.Features.NavigateTo)]
public async Task NoNavigationToGeneratedFiles()
public async Task NavigateToGeneratedFiles()
{
using (var workspace = await TestWorkspace.CreateAsync(@"
<Workspace>
......@@ -860,7 +861,7 @@ namespace N
{
public partial class C
{
public void VisibleMethod_Not() { }
public void VisibleMethod_Generated() { }
}
}
</Document>
......@@ -876,7 +877,8 @@ public partial class C
var items = _aggregator.GetItems("VisibleMethod");
var expectedItems = new List<NavigateToItem>()
{
new NavigateToItem("VisibleMethod", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Exact, true, null)
new NavigateToItem("VisibleMethod", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Exact, true, null),
new NavigateToItem("VisibleMethod_Generated", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Prefix, true, null)
};
// The pattern matcher should match 'VisibleMethod' to both 'VisibleMethod' and 'VisibleMethod_Not', except that
......
......@@ -29,7 +29,8 @@ public static IEnumerable<INavigableItem> GetItemsFromPreferredSourceLocations(S
return locations.Select(loc => GetItemFromSymbolLocation(solution, symbol, loc, displayString));
}
public static IEnumerable<Location> GetPreferredSourceLocations(Solution solution, ISymbol symbol)
public static IEnumerable<Location> GetPreferredSourceLocations(
Solution solution, ISymbol symbol)
{
// Prefer non-generated source locations over generated ones.
......
......@@ -16,11 +16,10 @@ internal static class NavigateToSymbolFinder
{
internal static async Task<IEnumerable<ValueTuple<DeclaredSymbolInfo, Document, IEnumerable<PatternMatch>>>> FindNavigableDeclaredSymbolInfos(Project project, string pattern, CancellationToken cancellationToken)
{
var generatedCodeRecognitionService = project.LanguageServices.WorkspaceServices.GetService<IGeneratedCodeRecognitionService>();
var patternMatcher = new PatternMatcher(pattern);
var result = new List<ValueTuple<DeclaredSymbolInfo, Document, IEnumerable<PatternMatch>>>();
foreach (var document in project.Documents.Where(d => !generatedCodeRecognitionService?.IsGeneratedCode(d) ?? true))
foreach (var document in project.Documents)
{
cancellationToken.ThrowIfCancellationRequested();
var declaredSymbolInfos = await document.GetDeclaredSymbolInfosAsync(cancellationToken).ConfigureAwait(false);
......
......@@ -27,6 +27,8 @@ Supported Platforms:
<file src="Microsoft.CodeAnalysis.CSharp.Workspaces.xml" target="lib\portable-net45+win8" />
<file src="Microsoft.CodeAnalysis.CSharp.Workspaces.dll" target="lib\net45" />
<file src="Microsoft.CodeAnalysis.CSharp.Workspaces.xml" target="lib\net45" />
<file src="Microsoft.CodeAnalysis.CSharp.Workspaces.dll" target="lib\netstandard1.3" />
<file src="Microsoft.CodeAnalysis.CSharp.Workspaces.xml" target="lib\netstandard1.3" />
<file src="$thirdPartyNoticesPath$" target="" />
</files>
</package>
......@@ -27,6 +27,8 @@ Supported Platforms:
<file src="Microsoft.CodeAnalysis.VisualBasic.Workspaces.xml" target="lib\portable-net45+win8" />
<file src="Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll" target="lib\net45" />
<file src="Microsoft.CodeAnalysis.VisualBasic.Workspaces.xml" target="lib\net45" />
<file src="Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll" target="lib\netstandard1.3" />
<file src="Microsoft.CodeAnalysis.VisualBasic.Workspaces.xml" target="lib\netstandard1.3" />
<file src="$thirdPartyNoticesPath$" target="" />
</files>
</package>
......@@ -32,6 +32,8 @@ Supported Platforms:
<file src="Microsoft.CodeAnalysis.Workspaces.xml" target="lib\net45" />
<file src="Microsoft.CodeAnalysis.Workspaces.Desktop.dll" target="lib\net45" />
<file src="Microsoft.CodeAnalysis.Workspaces.Desktop.xml" target="lib\net45" />
<file src="Microsoft.CodeAnalysis.Workspaces.dll" target="lib\netstandard1.3" />
<file src="Microsoft.CodeAnalysis.Workspaces.xml" target="lib\netstandard1.3" />
<file src="$thirdPartyNoticesPath$" target="" />
</files>
</package>
......@@ -5,6 +5,7 @@
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
......@@ -170,10 +171,20 @@ public static Task<SyntaxTreeDeclarationInfo> GetDeclarationInfoAsync(Document d
// TryGetDeclaredSymbolInfo, then this will at least prevent us from returning bad spans
// and will prevent the crash from occurring.
DeclaredSymbolInfo declaredSymbolInfo;
if (syntaxFacts.TryGetDeclaredSymbolInfo(node, out declaredSymbolInfo) &&
root.FullSpan.Contains(declaredSymbolInfo.Span))
if (syntaxFacts.TryGetDeclaredSymbolInfo(node, out declaredSymbolInfo))
{
declaredSymbolInfos.Add(declaredSymbolInfo);
if (root.FullSpan.Contains(declaredSymbolInfo.Span))
{
declaredSymbolInfos.Add(declaredSymbolInfo);
}
else
{
var message =
$@"Invalid span in {nameof(declaredSymbolInfo)}.
{nameof(declaredSymbolInfo.Span)} = {declaredSymbolInfo.Span}
{nameof(root.FullSpan)} = {root.FullSpan}";
FatalError.ReportWithoutCrash(new InvalidOperationException(message));
}
}
}
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册