未验证 提交 c9c3d05c 编写于 作者: D dotnet-automerge-bot 提交者: GitHub

Merge pull request #34077 from dotnet/merges/master-to-master-vs-deps

Merge master to master-vs-deps
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<Dependencies> <Dependencies>
<ProductDependencies></ProductDependencies> <ProductDependencies></ProductDependencies>
<ToolsetDependencies> <ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19157.23"> <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19161.14">
<Uri>https://github.com/dotnet/arcade</Uri> <Uri>https://github.com/dotnet/arcade</Uri>
<Sha>a0d951e12a53401c3da812b581e39feb4a5bb4ab</Sha> <Sha>2ca74c76adc84f0459b4a0352034db463d0b910f</Sha>
</Dependency> </Dependency>
</ToolsetDependencies> </ToolsetDependencies>
</Dependencies> </Dependencies>
...@@ -208,7 +208,11 @@ function BuildSolution() { ...@@ -208,7 +208,11 @@ function BuildSolution() {
$projects = Join-Path $RepoRoot $solution $projects = Join-Path $RepoRoot $solution
$enableAnalyzers = !$skipAnalyzers $enableAnalyzers = !$skipAnalyzers
$toolsetBuildProj = InitializeToolset $toolsetBuildProj = InitializeToolset
$quietRestore = !$ci
# Have to disable quiet restore during bootstrap builds to work around
# an arcade bug
# https://github.com/dotnet/arcade/issues/2220
$quietRestore = !($ci -or ($bootstrapDir -ne ""))
$testTargetFrameworks = if ($testCoreClr) { "netcoreapp2.1" } else { "" } $testTargetFrameworks = if ($testCoreClr) { "netcoreapp2.1" } else { "" }
$ibcSourceBranchName = GetIbcSourceBranchName $ibcSourceBranchName = GetIbcSourceBranchName
$ibcDropId = if ($officialIbcDropId -ne "default") { $officialIbcDropId } else { "" } $ibcDropId = if ($officialIbcDropId -ne "default") { $officialIbcDropId } else { "" }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)DefaultVersions.props" Condition="Exists('$(MSBuildThisFileDirectory)DefaultVersions.props')" /> <Import Project="$(MSBuildThisFileDirectory)DefaultVersions.props" Condition="Exists('$(MSBuildThisFileDirectory)DefaultVersions.props')" />
<Import Project="$(MSBuildThisFileDirectory)Versions.props" Condition="Exists('$(MSBuildThisFileDirectory)Versions.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.dotnet.build.tasks.feed\$(MicrosoftDotNetBuildTasksFeedVersion)\build\Microsoft.DotNet.Build.Tasks.Feed.targets" /> <Import Project="$(NuGetPackageRoot)microsoft.dotnet.build.tasks.feed\$(MicrosoftDotNetBuildTasksFeedVersion)\build\Microsoft.DotNet.Build.Tasks.Feed.targets" />
......
...@@ -42,7 +42,7 @@ try { ...@@ -42,7 +42,7 @@ try {
} }
Write-Host "Generating dependency graph..." Write-Host "Generating dependency graph..."
$darc = Invoke-Expression "& `"$darcExe`" $options" Invoke-Expression "& `"$darcExe`" $options"
CheckExitCode "Generating dependency graph" CheckExitCode "Generating dependency graph"
$graph = Get-Content $graphVizFilePath $graph = Get-Content $graphVizFilePath
......
parameters:
# Optional: dependencies of the job
dependsOn: ''
# Optional: A defined YAML pool - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#pool
pool: {}
# Optional: Include toolset dependencies in the generated graph files
includeToolset: false
jobs:
- job: Generate_Graph_Files
dependsOn: ${{ parameters.dependsOn }}
displayName: Generate Graph Files
pool: ${{ parameters.pool }}
variables:
# Publish-Build-Assets provides: MaestroAccessToken, BotAccount-dotnet-maestro-bot-PAT
# DotNet-AllOrgs-Darc-Pats provides: dn-bot-devdiv-dnceng-rw-code-pat
- group: Publish-Build-Assets
- group: DotNet-AllOrgs-Darc-Pats
- name: _GraphArguments
value: -gitHubPat $(BotAccount-dotnet-maestro-bot-PAT)
-azdoPat $(dn-bot-devdiv-dnceng-rw-code-pat)
-barToken $(MaestroAccessToken)
-outputFolder '$(Build.StagingDirectory)/GraphFiles/'
- ${{ if ne(parameters.includeToolset, 'false') }}:
- name: _GraphArguments
value: ${{ variables._GraphArguments }} -includeToolset
steps:
- task: PowerShell@2
displayName: Generate Graph Files
inputs:
filePath: eng\common\generate-graph-files.ps1
arguments: $(_GraphArguments)
continueOnError: true
- task: PublishBuildArtifacts@1
displayName: Publish Graph to Artifacts
inputs:
PathtoPublish: '$(Build.StagingDirectory)/GraphFiles'
PublishLocation: Container
ArtifactName: GraphFiles
continueOnError: true
condition: always()
...@@ -13,7 +13,13 @@ parameters: ...@@ -13,7 +13,13 @@ parameters:
# Optional: Enable publishing to the build asset registry # Optional: Enable publishing to the build asset registry
enablePublishBuildAssets: false enablePublishBuildAssets: false
graphFileGeneration:
# Optional: Enable generating the graph files at the end of the build
enabled: false
# Optional: Include toolset dependencies in the generated graph files
includeToolset: false
# Optional: Include PublishTestResults task # Optional: Include PublishTestResults task
enablePublishTestResults: false enablePublishTestResults: false
...@@ -68,4 +74,13 @@ jobs: ...@@ -68,4 +74,13 @@ jobs:
vmImage: vs2017-win2016 vmImage: vs2017-win2016
runAsPublic: ${{ parameters.runAsPublic }} runAsPublic: ${{ parameters.runAsPublic }}
enablePublishBuildArtifacts: ${{ parameters.enablePublishBuildArtifacts }} enablePublishBuildArtifacts: ${{ parameters.enablePublishBuildArtifacts }}
- ${{ if and(eq(parameters.graphFileGeneration.enabled, true), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- template: ../job/generate-graph-files.yml
parameters:
continueOnError: ${{ parameters.continueOnError }}
includeToolset: ${{ parameters.graphFileGeneration.includeToolset }}
dependsOn:
- Asset_Registry_Publish
pool:
vmImage: vs2017-win2016
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
"xcopy-msbuild": "15.9.0-alpha" "xcopy-msbuild": "15.9.0-alpha"
}, },
"msbuild-sdks": { "msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19157.23" "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19161.14"
} }
} }
...@@ -30,7 +30,8 @@ private void VisitSwitchBlock(BoundSwitchStatement node) ...@@ -30,7 +30,8 @@ private void VisitSwitchBlock(BoundSwitchStatement node)
{ {
foreach (var label in section.SwitchLabels) foreach (var label in section.SwitchLabels)
{ {
if (reachableLabels.Contains(label.Label) || label.HasErrors) if (reachableLabels.Contains(label.Label) || label.HasErrors ||
label == node.DefaultLabel && node.Expression.ConstantValue == null && IsTraditionalSwitch(node))
{ {
SetState(initialState.Clone()); SetState(initialState.Clone());
} }
......
...@@ -10,8 +10,8 @@ namespace Microsoft.CodeAnalysis.CSharp.Symbols ...@@ -10,8 +10,8 @@ namespace Microsoft.CodeAnalysis.CSharp.Symbols
[DebuggerDisplay("{GetDebuggerDisplay(), nq}")] [DebuggerDisplay("{GetDebuggerDisplay(), nq}")]
internal readonly struct TypeWithState internal readonly struct TypeWithState
{ {
public TypeSymbol Type { get; } public readonly TypeSymbol Type;
public NullableFlowState State { get; } public readonly NullableFlowState State;
public bool HasNullType => Type is null; public bool HasNullType => Type is null;
public bool MayBeNull => State == NullableFlowState.MaybeNull; public bool MayBeNull => State == NullableFlowState.MaybeNull;
public bool IsNotNull => State == NullableFlowState.NotNull; public bool IsNotNull => State == NullableFlowState.NotNull;
......
...@@ -2918,6 +2918,35 @@ public static void Main() ...@@ -2918,6 +2918,35 @@ public static void Main()
); );
} }
[Fact]
[WorkItem(33783, "https://github.com/dotnet/roslyn/issues/33783")]
public void UnreachableDefaultInBoolSwitch()
{
var text = @"
public class TestClass
{
public static void Main()
{
bool b = false;
switch (b)
{
case true:
break;
case false:
break;
default:
break; //1
}
}
}";
CreateCompilation(text, parseOptions: TestOptions.Regular6).VerifyDiagnostics();
CreateCompilation(text, parseOptions: TestOptions.Regular7_3).VerifyDiagnostics();
CreateCompilation(text).VerifyDiagnostics(
// (14,17): warning CS0162: Unreachable code detected
// break; //1
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(14, 17));
}
#endregion #endregion
} }
} }
...@@ -3112,6 +3112,64 @@ End Class ...@@ -3112,6 +3112,64 @@ End Class
End Using End Using
End Sub End Sub
<Fact>
<Trait(Traits.Feature, Traits.Features.Rename)>
<WorkItem(16576, "https://github.com/dotnet/roslyn/issues/16576")>
Public Sub RenameParameterizedPropertyResolvedConflict()
Using result = RenameEngineResult.Create(_outputHelper,
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document><![CDATA[
Public Class C
Public ReadOnly Property P(a As Object) As Int32
Get
Return 2
End Get
End Property
Public ReadOnly Property [|$$P2|](a As String) As Int32
Get
Return {|Conflict0:P|}("")
End Get
End Property
End Class
]]>
</Document>
</Project>
</Workspace>, renameTo:="P")
result.AssertLabeledSpansAre("Conflict0", replacement:="Return P(CObj(""""))", type:=RelatedLocationType.ResolvedNonReferenceConflict)
End Using
End Sub
<Fact>
<Trait(Traits.Feature, Traits.Features.Rename)>
<WorkItem(16576, "https://github.com/dotnet/roslyn/issues/16576")>
Public Sub RenameParameterizedPropertyUnresolvedConflict()
Using result = RenameEngineResult.Create(_outputHelper,
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document><![CDATA[
Public Class C
Public ReadOnly Property {|Conflict:P|}(a As String) As Int32
Get
Return 2
End Get
End Property
Public ReadOnly Property [|$$P2|](a As String) As Int32
Get
Return 3
End Get
End Property
End Class
]]>
</Document>
</Project>
</Workspace>, renameTo:="P")
result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict)
End Using
End Sub
<Fact> <Fact>
<Trait(Traits.Feature, Traits.Features.Rename)> <Trait(Traits.Feature, Traits.Features.Rename)>
<WorkItem(10469, "https://github.com/dotnet/roslyn/issues/10469")> <WorkItem(10469, "https://github.com/dotnet/roslyn/issues/10469")>
......
...@@ -57,10 +57,16 @@ public bool IsExperimentEnabled(string experimentName) ...@@ -57,10 +57,16 @@ public bool IsExperimentEnabled(string experimentName)
{ {
try try
{ {
var enabled = _featureFlags.IsFeatureEnabled(experimentName, defaultValue: false); // check whether "." exist in the experimentName since it is requirement for featureflag service.
if (enabled) // we do this since RPS complains about resource file being loaded for invalid name exception
// we are not testing all rules but just simple "." check
if (experimentName.IndexOf(".") > 0)
{ {
return enabled; var enabled = _featureFlags.IsFeatureEnabled(experimentName, defaultValue: false);
if (enabled)
{
return enabled;
}
} }
} }
catch catch
......
...@@ -259,7 +259,7 @@ private class TestService : ServiceHubServiceBase ...@@ -259,7 +259,7 @@ private class TestService : ServiceHubServiceBase
{ {
Event = new ManualResetEvent(false); Event = new ManualResetEvent(false);
Rpc.StartListening(); StartService();
} }
public readonly ManualResetEvent Event; public readonly ManualResetEvent Event;
......
...@@ -40,7 +40,7 @@ internal static partial class ConflictResolver ...@@ -40,7 +40,7 @@ internal static partial class ConflictResolver
/// <param name="originalText">The original name of the identifier.</param> /// <param name="originalText">The original name of the identifier.</param>
/// <param name="replacementText">The new name of the identifier</param> /// <param name="replacementText">The new name of the identifier</param>
/// <param name="optionSet">The option for rename</param> /// <param name="optionSet">The option for rename</param>
/// <param name="hasConflict">Called after renaming references. Can be used by callers to /// <param name="hasConflict">Called after renaming references. Can be used by callers to
/// indicate if the new symbols that the reference binds to should be considered to be ok or /// indicate if the new symbols that the reference binds to should be considered to be ok or
/// are in conflict. 'true' means they are conflicts. 'false' means they are not conflicts. /// are in conflict. 'true' means they are conflicts. 'false' means they are not conflicts.
/// 'null' means that the default conflict check should be used.</param> /// 'null' means that the default conflict check should be used.</param>
...@@ -181,14 +181,31 @@ private static bool IsRenameValid(ConflictResolution conflictResolution, ISymbol ...@@ -181,14 +181,31 @@ private static bool IsRenameValid(ConflictResolution conflictResolution, ISymbol
{ {
try try
{ {
var project = conflictResolution.NewSolution.GetProject(renamedSymbol.ContainingAssembly, cancellationToken);
if (renamedSymbol.ContainingSymbol.IsKind(SymbolKind.NamedType)) if (renamedSymbol.ContainingSymbol.IsKind(SymbolKind.NamedType))
{ {
var otherThingsNamedTheSame = renamedSymbol.ContainingType.GetMembers(renamedSymbol.Name) var otherThingsNamedTheSame = renamedSymbol.ContainingType.GetMembers(renamedSymbol.Name)
.Where(s => !s.Equals(renamedSymbol) && .Where(s => !s.Equals(renamedSymbol) &&
string.Equals(s.MetadataName, renamedSymbol.MetadataName, StringComparison.Ordinal) && string.Equals(s.MetadataName, renamedSymbol.MetadataName, StringComparison.Ordinal));
(s.Kind != SymbolKind.Method || renamedSymbol.Kind != SymbolKind.Method));
AddConflictingSymbolLocations(otherThingsNamedTheSame, conflictResolution, reverseMappedLocations); IEnumerable<ISymbol> otherThingsNamedTheSameExcludeMethodAndParameterizedProperty;
// Possibly overloaded symbols are excluded here and handled elsewhere
var semanticFactsService = project.LanguageServices.GetService<ISemanticFactsService>();
if (semanticFactsService.SupportsParameterizedProperties)
{
otherThingsNamedTheSameExcludeMethodAndParameterizedProperty = otherThingsNamedTheSame
.Where(s=> !s.MatchesKind(SymbolKind.Method, SymbolKind.Property) ||
!renamedSymbol.MatchesKind(SymbolKind.Method, SymbolKind.Property));
}
else
{
otherThingsNamedTheSameExcludeMethodAndParameterizedProperty = otherThingsNamedTheSame
.Where(s => s.Kind != SymbolKind.Method || renamedSymbol.Kind != SymbolKind.Method);
}
AddConflictingSymbolLocations(otherThingsNamedTheSameExcludeMethodAndParameterizedProperty, conflictResolution, reverseMappedLocations);
} }
...@@ -220,8 +237,6 @@ private static bool IsRenameValid(ConflictResolution conflictResolution, ISymbol ...@@ -220,8 +237,6 @@ private static bool IsRenameValid(ConflictResolution conflictResolution, ISymbol
// Some types of symbols (namespaces, cref stuff, etc) might not have ContainingAssemblies // Some types of symbols (namespaces, cref stuff, etc) might not have ContainingAssemblies
if (renamedSymbol.ContainingAssembly != null) if (renamedSymbol.ContainingAssembly != null)
{ {
var project = conflictResolution.NewSolution.GetProject(renamedSymbol.ContainingAssembly, cancellationToken);
// There also might be language specific rules we need to include // There also might be language specific rules we need to include
var languageRenameService = project.LanguageServices.GetService<IRenameRewriterLanguageService>(); var languageRenameService = project.LanguageServices.GetService<IRenameRewriterLanguageService>();
var languageConflicts = await languageRenameService.ComputeDeclarationConflictsAsync( var languageConflicts = await languageRenameService.ComputeDeclarationConflictsAsync(
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
...@@ -17,24 +18,53 @@ public static ImmutableArray<Location> GetMembersWithConflictingSignatures(IMeth ...@@ -17,24 +18,53 @@ public static ImmutableArray<Location> GetMembersWithConflictingSignatures(IMeth
.OfType<IMethodSymbol>() .OfType<IMethodSymbol>()
.Where(m => !m.Equals(renamedMethod) && m.Arity == renamedMethod.Arity); .Where(m => !m.Equals(renamedMethod) && m.Arity == renamedMethod.Arity);
var signatureToConflictingMember = new Dictionary<ImmutableArray<ITypeSymbol>, IMethodSymbol>(ConflictingSignatureComparer.Instance); return GetConflictLocations(renamedMethod, potentiallyConfictingMethods, isMethod:true,
(method) => GetAllSignatures((method as IMethodSymbol).Parameters, trimOptionalParameters));
}
public static ImmutableArray<Location> GetMembersWithConflictingSignatures(IPropertySymbol renamedProperty, bool trimOptionalParameters)
{
var potentiallyConfictingProperties =
renamedProperty.ContainingType.GetMembers(renamedProperty.Name)
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(renamedProperty) && m.Parameters.Count() == renamedProperty.Parameters.Count());
return GetConflictLocations(renamedProperty, potentiallyConfictingProperties, isMethod: false,
(property)=>GetAllSignatures((property as IPropertySymbol).Parameters, trimOptionalParameters));
}
private static ImmutableArray<Location> GetConflictLocations(ISymbol renamedMember,
IEnumerable<ISymbol> potentiallyConfictingMembers,
bool isMethod,
Func<ISymbol, ImmutableArray<ImmutableArray<ITypeSymbol>>> getAllSignatures)
{
var signatureToConflictingMember = new Dictionary<ImmutableArray<ITypeSymbol>, ISymbol>(ConflictingSignatureComparer.Instance);
foreach (var method in potentiallyConfictingMethods) foreach (var member in potentiallyConfictingMembers)
{ {
foreach (var signature in GetAllSignatures(method, trimOptionalParameters)) foreach (var signature in getAllSignatures(member))
{ {
signatureToConflictingMember[signature] = method; signatureToConflictingMember[signature] = member;
} }
} }
var builder = ArrayBuilder<Location>.GetInstance(); var builder = ArrayBuilder<Location>.GetInstance();
foreach (var signature in GetAllSignatures(renamedMethod, trimOptionalParameters)) foreach (var signature in getAllSignatures(renamedMember))
{ {
if (signatureToConflictingMember.TryGetValue(signature, out var conflictingSymbol)) if (signatureToConflictingMember.TryGetValue(signature, out var conflictingSymbol))
{ {
if (!(conflictingSymbol.PartialDefinitionPart != null && conflictingSymbol.PartialDefinitionPart == renamedMethod) && if (isMethod)
!(conflictingSymbol.PartialImplementationPart != null && conflictingSymbol.PartialImplementationPart == renamedMethod)) {
var conflictingMethod = conflictingSymbol as IMethodSymbol;
var renamedMethod = renamedMember as IMethodSymbol;
if (!(conflictingMethod.PartialDefinitionPart != null && conflictingMethod.PartialDefinitionPart == renamedMethod) &&
!(conflictingMethod.PartialImplementationPart != null && conflictingMethod.PartialImplementationPart == renamedMethod))
{
builder.AddRange(conflictingSymbol.Locations);
}
}
else
{ {
builder.AddRange(conflictingSymbol.Locations); builder.AddRange(conflictingSymbol.Locations);
} }
...@@ -57,25 +87,20 @@ public bool Equals(ImmutableArray<ITypeSymbol> x, ImmutableArray<ITypeSymbol> y) ...@@ -57,25 +87,20 @@ public bool Equals(ImmutableArray<ITypeSymbol> x, ImmutableArray<ITypeSymbol> y)
public int GetHashCode(ImmutableArray<ITypeSymbol> obj) public int GetHashCode(ImmutableArray<ITypeSymbol> obj)
{ {
// This is a very simple GetHashCode implementation. Doing something "fancier" here // This is a very simple GetHashCode implementation. Doing something "fancier" here
// isn't really worth it, since to compute a proper hash we'd end up walking all the // isn't really worth it, since to compute a proper hash we'd end up walking all the
// ITypeSymbols anyways. // ITypeSymbols anyways.
return obj.Length; return obj.Length;
} }
} }
private static ImmutableArray<ImmutableArray<ITypeSymbol>> GetAllSignatures(IMethodSymbol method, bool trimOptionalParameters) private static ImmutableArray<ImmutableArray<ITypeSymbol>> GetAllSignatures(ImmutableArray<IParameterSymbol> parameters, bool trimOptionalParameters)
{ {
var resultBuilder = ArrayBuilder<ImmutableArray<ITypeSymbol>>.GetInstance(); var resultBuilder = ArrayBuilder<ImmutableArray<ITypeSymbol>>.GetInstance();
var signatureBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(); var signatureBuilder = ArrayBuilder<ITypeSymbol>.GetInstance();
if (method.MethodKind == MethodKind.Conversion) foreach (var parameter in parameters)
{
signatureBuilder.Add(method.ReturnType);
}
foreach (var parameter in method.Parameters)
{ {
// In VB, a method effectively creates multiple signatures which are produced by // In VB, a method effectively creates multiple signatures which are produced by
// chopping off each of the optional parameters on the end, last to first, per 4.1.1 of // chopping off each of the optional parameters on the end, last to first, per 4.1.1 of
......
...@@ -42,5 +42,14 @@ ...@@ -42,5 +42,14 @@
<Compile Include="..\ServiceHub\Shared\ServiceHubServiceBase.cs"> <Compile Include="..\ServiceHub\Shared\ServiceHubServiceBase.cs">
<Link>Shared\ServiceHubServiceBase.cs</Link> <Link>Shared\ServiceHubServiceBase.cs</Link>
</Compile> </Compile>
<Compile Include="..\ServiceHub\Shared\Extensions.cs">
<Link>Shared\Extensions.cs</Link>
</Compile>
<Compile Include="..\ServiceHub\Shared\ClientDirectStream.cs">
<Link>Shared\ClientDirectStream.cs</Link>
</Compile>
<Compile Include="..\ServiceHub\Shared\ServerDirectStream.cs">
<Link>Shared\ServerDirectStream.cs</Link>
</Compile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
// 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 Microsoft.VisualStudio.Telemetry;
namespace Microsoft.VisualStudio.Telemetry
{
internal interface IFaultUtility
{
void AddProcessDump(int pid);
void AddFile(string fullpathname);
}
}
namespace Microsoft.CodeAnalysis.ErrorReporting
{
/// <summary>
/// dummy types just to make linked file work
/// </summary>
internal class WatsonReporter
{
public static void Report(string description, Exception exception)
{
// do nothing
}
public static void Report(string description, Exception exception, Func<IFaultUtility, int> callback)
{
// do nothing
}
}
}
...@@ -11,7 +11,7 @@ internal partial class CodeAnalysisService : ServiceHubServiceBase ...@@ -11,7 +11,7 @@ internal partial class CodeAnalysisService : ServiceHubServiceBase
public CodeAnalysisService(Stream stream, IServiceProvider serviceProvider) : public CodeAnalysisService(Stream stream, IServiceProvider serviceProvider) :
base(serviceProvider, stream) base(serviceProvider, stream)
{ {
Rpc.StartListening(); StartService();
} }
} }
} }
...@@ -61,8 +61,8 @@ public SymbolSearchService(CodeAnalysisService codeAnalysisService) ...@@ -61,8 +61,8 @@ public SymbolSearchService(CodeAnalysisService codeAnalysisService)
public async Task<IList<PackageWithTypeResult>> FindPackagesWithTypeAsync( public async Task<IList<PackageWithTypeResult>> FindPackagesWithTypeAsync(
string source, string name, int arity, CancellationToken cancellationToken) string source, string name, int arity, CancellationToken cancellationToken)
{ {
var result = await codeAnalysisService.Rpc.InvokeAsync<IList<PackageWithTypeResult>>( var result = await codeAnalysisService.InvokeAsync<IList<PackageWithTypeResult>>(
nameof(FindPackagesWithTypeAsync), source, name, arity).ConfigureAwait(false); nameof(FindPackagesWithTypeAsync), new object[] { source, name, arity }, cancellationToken).ConfigureAwait(false);
return result; return result;
} }
...@@ -70,8 +70,8 @@ public SymbolSearchService(CodeAnalysisService codeAnalysisService) ...@@ -70,8 +70,8 @@ public SymbolSearchService(CodeAnalysisService codeAnalysisService)
public async Task<IList<PackageWithAssemblyResult>> FindPackagesWithAssemblyAsync( public async Task<IList<PackageWithAssemblyResult>> FindPackagesWithAssemblyAsync(
string source, string assemblyName, CancellationToken cancellationToken) string source, string assemblyName, CancellationToken cancellationToken)
{ {
var result = await codeAnalysisService.Rpc.InvokeAsync<IList<PackageWithAssemblyResult>>( var result = await codeAnalysisService.InvokeAsync<IList<PackageWithAssemblyResult>>(
nameof(FindPackagesWithAssemblyAsync), source, assemblyName).ConfigureAwait(false); nameof(FindPackagesWithAssemblyAsync), new object[] { source, assemblyName }, cancellationToken).ConfigureAwait(false);
return result; return result;
} }
...@@ -79,8 +79,8 @@ public SymbolSearchService(CodeAnalysisService codeAnalysisService) ...@@ -79,8 +79,8 @@ public SymbolSearchService(CodeAnalysisService codeAnalysisService)
public async Task<IList<ReferenceAssemblyWithTypeResult>> FindReferenceAssembliesWithTypeAsync( public async Task<IList<ReferenceAssemblyWithTypeResult>> FindReferenceAssembliesWithTypeAsync(
string name, int arity, CancellationToken cancellationToken) string name, int arity, CancellationToken cancellationToken)
{ {
var result = await codeAnalysisService.Rpc.InvokeAsync<IList<ReferenceAssemblyWithTypeResult>>( var result = await codeAnalysisService.InvokeAsync<IList<ReferenceAssemblyWithTypeResult>>(
nameof(FindReferenceAssembliesWithTypeAsync), name, arity).ConfigureAwait(false); nameof(FindReferenceAssembliesWithTypeAsync), new object[] { name, arity }, cancellationToken).ConfigureAwait(false);
return result; return result;
} }
......
...@@ -168,10 +168,10 @@ public FindLiteralReferencesProgressCallback(CodeAnalysisService service) ...@@ -168,10 +168,10 @@ public FindLiteralReferencesProgressCallback(CodeAnalysisService service)
} }
public Task ReportProgressAsync(int current, int maximum) public Task ReportProgressAsync(int current, int maximum)
=> _service.Rpc.InvokeAsync(nameof(ReportProgressAsync), current, maximum); => _service.InvokeAsync(nameof(ReportProgressAsync), new object[] { current, maximum }, CancellationToken.None);
public Task OnReferenceFoundAsync(Document document, TextSpan span) public Task OnReferenceFoundAsync(Document document, TextSpan span)
=> _service.Rpc.InvokeAsync(nameof(OnReferenceFoundAsync), document.Id, span); => _service.InvokeAsync(nameof(OnReferenceFoundAsync), new object[] { document.Id, span }, CancellationToken.None);
} }
private class FindReferencesProgressCallback : IStreamingFindReferencesProgress private class FindReferencesProgressCallback : IStreamingFindReferencesProgress
...@@ -184,30 +184,29 @@ public FindReferencesProgressCallback(CodeAnalysisService service) ...@@ -184,30 +184,29 @@ public FindReferencesProgressCallback(CodeAnalysisService service)
} }
public Task OnStartedAsync() public Task OnStartedAsync()
=> _service.Rpc.InvokeAsync(nameof(OnStartedAsync)); => _service.InvokeAsync(nameof(OnStartedAsync), CancellationToken.None);
public Task OnCompletedAsync() public Task OnCompletedAsync()
=> _service.Rpc.InvokeAsync(nameof(OnCompletedAsync)); => _service.InvokeAsync(nameof(OnCompletedAsync), CancellationToken.None);
public Task ReportProgressAsync(int current, int maximum) public Task ReportProgressAsync(int current, int maximum)
=> _service.Rpc.InvokeAsync(nameof(ReportProgressAsync), current, maximum); => _service.InvokeAsync(nameof(ReportProgressAsync), new object[] { current, maximum }, CancellationToken.None);
public Task OnFindInDocumentStartedAsync(Document document) public Task OnFindInDocumentStartedAsync(Document document)
=> _service.Rpc.InvokeAsync(nameof(OnFindInDocumentStartedAsync), document.Id); => _service.InvokeAsync(nameof(OnFindInDocumentStartedAsync), new object[] { document.Id }, CancellationToken.None);
public Task OnFindInDocumentCompletedAsync(Document document) public Task OnFindInDocumentCompletedAsync(Document document)
=> _service.Rpc.InvokeAsync(nameof(OnFindInDocumentCompletedAsync), document.Id); => _service.InvokeAsync(nameof(OnFindInDocumentCompletedAsync), new object[] { document.Id }, CancellationToken.None);
public Task OnDefinitionFoundAsync(SymbolAndProjectId definition) public Task OnDefinitionFoundAsync(SymbolAndProjectId definition)
=> _service.Rpc.InvokeAsync(nameof(OnDefinitionFoundAsync), => _service.InvokeAsync(nameof(OnDefinitionFoundAsync), new object[] { SerializableSymbolAndProjectId.Dehydrate(definition) }, CancellationToken.None);
SerializableSymbolAndProjectId.Dehydrate(definition));
public Task OnReferenceFoundAsync( public Task OnReferenceFoundAsync(
SymbolAndProjectId definition, ReferenceLocation reference) SymbolAndProjectId definition, ReferenceLocation reference)
{ {
return _service.Rpc.InvokeAsync(nameof(OnReferenceFoundAsync), return _service.InvokeAsync(nameof(OnReferenceFoundAsync),
SerializableSymbolAndProjectId.Dehydrate(definition), new object[] { SerializableSymbolAndProjectId.Dehydrate(definition), SerializableReferenceLocation.Dehydrate(reference) },
SerializableReferenceLocation.Dehydrate(reference)); CancellationToken.None);
} }
} }
} }
......
...@@ -57,7 +57,7 @@ static RemoteHostService() ...@@ -57,7 +57,7 @@ static RemoteHostService()
base(serviceProvider, stream) base(serviceProvider, stream)
{ {
// this service provide a way for client to make sure remote host is alive // this service provide a way for client to make sure remote host is alive
Rpc.StartListening(); StartService();
} }
public string Connect(string host, int uiCultureLCID, int cultureLCID, string serializedSession, CancellationToken cancellationToken) public string Connect(string host, int uiCultureLCID, int cultureLCID, string serializedSession, CancellationToken cancellationToken)
......
...@@ -21,7 +21,7 @@ public RemoteSymbolSearchUpdateEngine(Stream stream, IServiceProvider servicePro ...@@ -21,7 +21,7 @@ public RemoteSymbolSearchUpdateEngine(Stream stream, IServiceProvider servicePro
_updateEngine = new SymbolSearchUpdateEngine( _updateEngine = new SymbolSearchUpdateEngine(
logService: this, progressService: this); logService: this, progressService: this);
Rpc.StartListening(); StartService();
} }
public Task UpdateContinuouslyAsync(string sourceName, string localSettingsDirectory) public Task UpdateContinuouslyAsync(string sourceName, string localSettingsDirectory)
...@@ -68,22 +68,22 @@ public Task<IList<ReferenceAssemblyWithTypeResult>> FindReferenceAssembliesWithT ...@@ -68,22 +68,22 @@ public Task<IList<ReferenceAssemblyWithTypeResult>> FindReferenceAssembliesWithT
#region Messages to forward from here to VS #region Messages to forward from here to VS
public Task LogExceptionAsync(string exception, string text) public Task LogExceptionAsync(string exception, string text)
=> this.Rpc.InvokeAsync(nameof(LogExceptionAsync), exception, text); => this.InvokeAsync(nameof(LogExceptionAsync), new object[] { exception, text }, CancellationToken.None);
public Task LogInfoAsync(string text) public Task LogInfoAsync(string text)
=> this.Rpc.InvokeAsync(nameof(LogInfoAsync), text); => this.InvokeAsync(nameof(LogInfoAsync), new object[] { text }, CancellationToken.None);
public Task OnDownloadFullDatabaseStartedAsync(string title) public Task OnDownloadFullDatabaseStartedAsync(string title)
=> this.Rpc.InvokeAsync(nameof(OnDownloadFullDatabaseStartedAsync), title); => this.InvokeAsync(nameof(OnDownloadFullDatabaseStartedAsync), new object[] { title }, CancellationToken.None);
public Task OnDownloadFullDatabaseSucceededAsync() public Task OnDownloadFullDatabaseSucceededAsync()
=> this.Rpc.InvokeAsync(nameof(OnDownloadFullDatabaseSucceededAsync)); => this.InvokeAsync(nameof(OnDownloadFullDatabaseSucceededAsync), CancellationToken.None);
public Task OnDownloadFullDatabaseCanceledAsync() public Task OnDownloadFullDatabaseCanceledAsync()
=> this.Rpc.InvokeAsync(nameof(OnDownloadFullDatabaseCanceledAsync)); => this.InvokeAsync(nameof(OnDownloadFullDatabaseCanceledAsync), CancellationToken.None);
public Task OnDownloadFullDatabaseFailedAsync(string message) public Task OnDownloadFullDatabaseFailedAsync(string message)
=> this.Rpc.InvokeAsync(nameof(OnDownloadFullDatabaseFailedAsync), message); => this.InvokeAsync(nameof(OnDownloadFullDatabaseFailedAsync), new object[] { message }, CancellationToken.None);
#endregion #endregion
} }
......
...@@ -38,7 +38,7 @@ public override async Task<IList<(Checksum, object)>> RequestAssetsAsync(int sco ...@@ -38,7 +38,7 @@ public override async Task<IList<(Checksum, object)>> RequestAssetsAsync(int sco
{ {
return await _owner.RunServiceAsync(cancellationToken => return await _owner.RunServiceAsync(cancellationToken =>
{ {
return _owner.Rpc.InvokeAsync(WellKnownServiceHubServices.AssetService_RequestAssetAsync, return _owner.InvokeAsync(WellKnownServiceHubServices.AssetService_RequestAssetAsync,
new object[] { scopeId, checksums.ToArray() }, new object[] { scopeId, checksums.ToArray() },
(s, c) => ReadAssets(s, scopeId, checksums, serializerService, c), cancellationToken); (s, c) => ReadAssets(s, scopeId, checksums, serializerService, c), cancellationToken);
}, callerCancellation).ConfigureAwait(false); }, callerCancellation).ConfigureAwait(false);
...@@ -52,8 +52,7 @@ public override async Task<IList<(Checksum, object)>> RequestAssetsAsync(int sco ...@@ -52,8 +52,7 @@ public override async Task<IList<(Checksum, object)>> RequestAssetsAsync(int sco
private bool ReportUnlessCanceled(Exception ex, CancellationToken cancellationToken) private bool ReportUnlessCanceled(Exception ex, CancellationToken cancellationToken)
{ {
if (!cancellationToken.IsCancellationRequested && if (!cancellationToken.IsCancellationRequested && _owner.IsDisposed)
((IDisposableObservable)_owner.Rpc).IsDisposed)
{ {
// kill OOP if snapshot service got disconnected due to this exception. // kill OOP if snapshot service got disconnected due to this exception.
FailFast.OnFatalException(ex); FailFast.OnFatalException(ex);
......
...@@ -19,7 +19,7 @@ internal partial class SnapshotService : ServiceHubServiceBase ...@@ -19,7 +19,7 @@ internal partial class SnapshotService : ServiceHubServiceBase
{ {
_source = new JsonRpcAssetSource(this); _source = new JsonRpcAssetSource(this);
Rpc.StartListening(); StartService();
} }
} }
} }
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
...@@ -20,14 +21,17 @@ internal abstract class ServiceHubServiceBase : IDisposable ...@@ -20,14 +21,17 @@ internal abstract class ServiceHubServiceBase : IDisposable
private static int s_instanceId; private static int s_instanceId;
private readonly CancellationTokenSource _shutdownCancellationSource; private readonly CancellationTokenSource _shutdownCancellationSource;
private readonly JsonRpc _rpc;
protected readonly int InstanceId; protected readonly int InstanceId;
protected readonly JsonRpc Rpc;
protected readonly TraceSource Logger; protected readonly TraceSource Logger;
protected readonly AssetStorage AssetStorage; protected readonly AssetStorage AssetStorage;
protected readonly CancellationToken ShutdownCancellationToken; protected readonly CancellationToken ShutdownCancellationToken;
[Obsolete("don't use RPC directly but use it through StartService and InvokeAsync", error: true)]
protected readonly JsonRpc Rpc;
/// <summary> /// <summary>
/// PinnedSolutionInfo.ScopeId. scope id of the solution. caller and callee share this id which one /// PinnedSolutionInfo.ScopeId. scope id of the solution. caller and callee share this id which one
/// can use to find matching caller and callee while exchanging data /// can use to find matching caller and callee while exchanging data
...@@ -62,9 +66,14 @@ protected ServiceHubServiceBase(IServiceProvider serviceProvider, Stream stream) ...@@ -62,9 +66,14 @@ protected ServiceHubServiceBase(IServiceProvider serviceProvider, Stream stream)
// due to this issue - https://github.com/dotnet/roslyn/issues/16900#issuecomment-277378950 // due to this issue - https://github.com/dotnet/roslyn/issues/16900#issuecomment-277378950
// all sub type must explicitly start JsonRpc once everything is // all sub type must explicitly start JsonRpc once everything is
// setup // setup
Rpc = new JsonRpc(new JsonRpcMessageHandler(stream, stream), this); _rpc = new JsonRpc(new JsonRpcMessageHandler(stream, stream), this);
Rpc.JsonSerializer.Converters.Add(AggregateJsonConverter.Instance); _rpc.JsonSerializer.Converters.Add(AggregateJsonConverter.Instance);
Rpc.Disconnected += OnRpcDisconnected; _rpc.Disconnected += OnRpcDisconnected;
// we do this since we want to mark Rpc as obsolete but want to set its value for
// partner teams until they move. we can't use Rpc directly since we will get
// obsolete error and we can't suppress it since it is an error
this.GetType().GetField("Rpc", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, _rpc);
} }
protected string DebugInstanceString => $"{GetType()} ({InstanceId})"; protected string DebugInstanceString => $"{GetType()} ({InstanceId})";
...@@ -82,6 +91,37 @@ protected RoslynServices RoslynServices ...@@ -82,6 +91,37 @@ protected RoslynServices RoslynServices
} }
} }
protected bool IsDisposed => ((IDisposableObservable)_rpc).IsDisposed;
protected void StartService()
{
_rpc.StartListening();
}
protected Task<TResult> InvokeAsync<TResult>(
string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
{
return _rpc.InvokeWithCancellationAsync<TResult>(targetName, arguments, cancellationToken);
}
protected Task<TResult> InvokeAsync<TResult>(
string targetName, IReadOnlyList<object> arguments,
Func<Stream, CancellationToken, TResult> funcWithDirectStream, CancellationToken cancellationToken)
{
return Extensions.InvokeAsync(_rpc, targetName, arguments, funcWithDirectStream, cancellationToken);
}
protected Task InvokeAsync(string targetName, CancellationToken cancellationToken)
{
return InvokeAsync(targetName, SpecializedCollections.EmptyReadOnlyList<object>(), cancellationToken);
}
protected Task InvokeAsync(
string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
{
return _rpc.InvokeWithCancellationAsync(targetName, arguments, cancellationToken);
}
protected Task<Solution> GetSolutionAsync(CancellationToken cancellationToken) protected Task<Solution> GetSolutionAsync(CancellationToken cancellationToken)
{ {
Contract.ThrowIfNull(_solutionInfo); Contract.ThrowIfNull(_solutionInfo);
...@@ -123,7 +163,7 @@ public void Dispose() ...@@ -123,7 +163,7 @@ public void Dispose()
} }
_disposed = true; _disposed = true;
Rpc.Dispose(); _rpc.Dispose();
_shutdownCancellationSource.Dispose(); _shutdownCancellationSource.Dispose();
Dispose(disposing: true); Dispose(disposing: true);
......
...@@ -731,6 +731,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename ...@@ -731,6 +731,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
.Select(Function(loc) reverseMappedLocations(loc))) .Select(Function(loc) reverseMappedLocations(loc)))
ElseIf renamedSymbol.Kind = SymbolKind.Property Then ElseIf renamedSymbol.Kind = SymbolKind.Property Then
conflicts.AddRange(
DeclarationConflictHelpers.GetMembersWithConflictingSignatures(DirectCast(renamedSymbol, IPropertySymbol), trimOptionalParameters:=True) _
.Select(Function(loc) reverseMappedLocations(loc)))
ConflictResolver.AddConflictingParametersOfProperties( ConflictResolver.AddConflictingParametersOfProperties(
referencedSymbols.Select(Function(s) s.Symbol).Concat(renameSymbol).Where(Function(sym) sym.Kind = SymbolKind.Property), referencedSymbols.Select(Function(s) s.Symbol).Concat(renameSymbol).Where(Function(sym) sym.Kind = SymbolKind.Property),
renamedSymbol.Name, renamedSymbol.Name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册