未验证 提交 93d92142 编写于 作者: M msftbot[bot] 提交者: GitHub

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

Merge master to master-vs-deps
......@@ -231,6 +231,8 @@ dotnet_diagnostic.IDE0005.severity = warning
# IDE0011: Add braces
csharp_prefer_braces = when_multiline:warning
# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201
dotnet_diagnostic.IDE0011.severity = warning
# IDE0035: Remove unreachable code
dotnet_diagnostic.IDE0035.severity = warning
......
......@@ -50,12 +50,6 @@
<NoWarn>$(NoWarn);Nullable</NoWarn>
</PropertyGroup>
<!-- Workaround for https://github.com/dotnet/roslyn/issues/42166 -->
<!-- PERF: This property group prevents the analyzers from CodeStyle NuGet package from being executed by default in all explicit builds (i.e. csc/vbc invocations both inside Visual Studio and from command line prompt) -->
<PropertyGroup Condition="'$(DesignTimeBuild)' != 'true'">
<NoWarn>$(NoWarn);IDE0004;IDE0004WithoutSuggestion;IDE0005;IDE0007;IDE0007WithoutSuggestion;IDE0008;IDE0008WithoutSuggestion;IDE0009;IDE0009WithoutSuggestion;IDE0010;IDE0010WithoutSuggestion;IDE0011;IDE0011WithoutSuggestion;IDE0016;IDE0016WithoutSuggestion;IDE0017;IDE0017WithoutSuggestion;IDE0018;IDE0018WithoutSuggestion;IDE0019;IDE0019WithoutSuggestion;IDE0020;IDE0020WithoutSuggestion;IDE0021;IDE0022;IDE0023;IDE0024;IDE0025;IDE0026;IDE0027;IDE0028;IDE0028WithoutSuggestion;IDE0029;IDE0029WithoutSuggestion;IDE0030;IDE0030WithoutSuggestion;IDE0031;IDE0031WithoutSuggestion;IDE0032;IDE0032WithoutSuggestion;IDE0033;IDE0033WithoutSuggestion;IDE0034;IDE0034WithoutSuggestion;IDE0035;IDE0035WithoutSuggestion;IDE0036;IDE0036WithoutSuggestion;IDE0037;IDE0037WithoutSuggestion;IDE0040;IDE0040WithoutSuggestion;IDE0041;IDE0041WithoutSuggestion;IDE0042;IDE0042WithoutSuggestion;IDE0043;IDE0044;IDE0044WithoutSuggestion;IDE0045;IDE0045WithoutSuggestion;IDE0046;IDE0046WithoutSuggestion;IDE0047;IDE0048;IDE0048WithoutSuggestion;IDE0050;IDE0050WithoutSuggestion;IDE0051;IDE0052;IDE0054;IDE0054WithoutSuggestion;IDE0055;IDE0056;IDE0056WithoutSuggestion;IDE0057;IDE0057WithoutSuggestion;IDE0058;IDE0059;IDE0060;IDE0061;IDE0062;IDE0062WithoutSuggestion;IDE0063;IDE0063WithoutSuggestion;IDE0064;IDE0065;IDE0066;IDE0066WithoutSuggestion;IDE0070;IDE0070WithoutSuggestion;IDE0071;IDE0071WithoutSuggestion;IDE0072;IDE0072WithoutSuggestion;IDE0073;IDE0073WithoutSuggestion;IDE0074;IDE0074WithoutSuggestion;IDE0075;IDE0075WithoutSuggestion;IDE1005;IDE1005WithoutSuggestion;IDE1006;IDE1006WithoutSuggestion</NoWarn>
</PropertyGroup>
<ItemGroup Condition="'$(Language)' == 'CSharp' and '$(TargetFramework)' == 'net20'">
<_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" />
</ItemGroup>
......
......@@ -12,8 +12,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.RemoveUnnecessaryParentheses
......@@ -40,12 +38,6 @@ private async Task TestAsync(string initial, string expected, bool offeredWhenRe
internal override bool ShouldSkipMessageDescriptionVerification(DiagnosticDescriptor descriptor)
=> descriptor.CustomTags.Contains(WellKnownDiagnosticTags.Unnecessary) && descriptor.DefaultSeverity == DiagnosticSeverity.Hidden;
private DiagnosticDescription GetRemoveUnnecessaryParenthesesDiagnostic(string text, int line, int column)
=> TestHelpers.Diagnostic(IDEDiagnosticIds.RemoveUnnecessaryParenthesesDiagnosticId, text, startLocation: new LinePosition(line, column));
private DiagnosticDescription GetRemoveUnnecessaryParenthesesDiagnostic(string text, int line, int column, DiagnosticSeverity severity)
=> GetRemoveUnnecessaryParenthesesDiagnostic(text, line, column).WithEffectiveSeverity(severity);
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnnecessaryParentheses)]
public async Task TestArithmeticRequiredForClarity2()
{
......
......@@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.UseIsNullCheck;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
......@@ -13,12 +12,18 @@
using Roslyn.Test.Utilities;
using Xunit;
#if !CODE_STYLE
using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
#endif
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.UseIsNullCheck
{
public partial class UseIsNullCheckForReferenceEqualsTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
private static readonly ParseOptions CSharp7 = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7);
#if !CODE_STYLE
private static readonly ParseOptions CSharp9 = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersionExtensions.CSharp9);
#endif
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (new CSharpUseIsNullCheckForReferenceEqualsDiagnosticAnalyzer(), new CSharpUseIsNullCheckForReferenceEqualsCodeFixProvider());
......
......@@ -72,7 +72,11 @@ private static bool InvalidLevel(int? level)
case SyntaxKind.NamespaceDeclaration:
{
var ns = (NamespaceDeclarationSyntax)node;
foreach (var decl in ns.Members) ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
foreach (var decl in ns.Members)
{
ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
var declInfo = GetDeclarationInfo(model, node, getSymbol, cancellationToken);
builder.Add(declInfo);
......@@ -94,7 +98,11 @@ private static bool InvalidLevel(int? level)
case SyntaxKind.InterfaceDeclaration:
{
var t = (TypeDeclarationSyntax)node;
foreach (var decl in t.Members) ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
foreach (var decl in t.Members)
{
ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
var attributes = GetAttributes(t.AttributeLists).Concat(GetTypeParameterListAttributes(t.TypeParameterList));
builder.Add(GetDeclarationInfo(model, node, getSymbol, attributes, cancellationToken));
return;
......@@ -103,7 +111,11 @@ private static bool InvalidLevel(int? level)
case SyntaxKind.EnumDeclaration:
{
var t = (EnumDeclarationSyntax)node;
foreach (var decl in t.Members) ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
foreach (var decl in t.Members)
{
ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
var attributes = GetAttributes(t.AttributeLists);
builder.Add(GetDeclarationInfo(model, node, getSymbol, attributes, cancellationToken));
return;
......@@ -133,7 +145,10 @@ private static bool InvalidLevel(int? level)
var t = (EventDeclarationSyntax)node;
if (t.AccessorList != null)
{
foreach (var decl in t.AccessorList.Accessors) ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
foreach (var decl in t.AccessorList.Accessors)
{
ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
}
var attributes = GetAttributes(t.AttributeLists);
builder.Add(GetDeclarationInfo(model, node, getSymbol, attributes, cancellationToken));
......@@ -170,7 +185,10 @@ private static bool InvalidLevel(int? level)
var t = (PropertyDeclarationSyntax)node;
if (t.AccessorList != null)
{
foreach (var decl in t.AccessorList.Accessors) ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
foreach (var decl in t.AccessorList.Accessors)
{
ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
}
if (t.ExpressionBody != null)
......@@ -259,7 +277,10 @@ private static bool InvalidLevel(int? level)
case SyntaxKind.CompilationUnit:
{
var t = (CompilationUnitSyntax)node;
foreach (var decl in t.Members) ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
foreach (var decl in t.Members)
{
ComputeDeclarations(model, decl, shouldSkip, getSymbol, builder, newLevel, cancellationToken);
}
if (t.AttributeLists.Any())
{
......
......@@ -163,7 +163,7 @@ internal class SerializableSourceReferenceItem
{
public int DefinitionId;
public SerializableDocumentSpan SourceSpan;
public SymbolUsageInfo SymbolUsageInfo;
public SerializableSymbolUsageInfo SymbolUsageInfo;
public (string Key, string Value)[] AdditionalProperties;
public static SerializableSourceReferenceItem Dehydrate(
......@@ -173,7 +173,7 @@ internal class SerializableSourceReferenceItem
{
DefinitionId = definitionId,
SourceSpan = SerializableDocumentSpan.Dehydrate(item.SourceSpan),
SymbolUsageInfo = item.SymbolUsageInfo,
SymbolUsageInfo = SerializableSymbolUsageInfo.Dehydrate(item.SymbolUsageInfo),
AdditionalProperties = item.AdditionalProperties.Select(kvp => (kvp.Key, kvp.Value)).ToArray(),
};
}
......@@ -183,7 +183,7 @@ public SourceReferenceItem Rehydrate(Solution solution, DefinitionItem definitio
return new SourceReferenceItem(
definition,
SourceSpan.Rehydrate(solution),
SymbolUsageInfo,
SymbolUsageInfo.Rehydrate(),
AdditionalProperties.ToImmutableDictionary(t => t.Key, t => t.Value));
}
}
......
......@@ -98,8 +98,10 @@ public bool TryConvert(out DocumentUpdateInfo documentUpdateInfo)
{
if (!documentUpdateInfo.Source.IsParentKind(SyntaxKind.Block) &&
documentUpdateInfo.Destinations.Length > 1)
{
documentUpdateInfo = new DocumentUpdateInfo(documentUpdateInfo.Source, SyntaxFactory.Block(documentUpdateInfo.Destinations));
}
return true;
}
......
......@@ -155,7 +155,9 @@ where m.IsAccessibleWithin(enclosingType)
{
if (!CanFix(semanticModel, diagnostic, cancellationToken,
out var nameNode, out var matchingMember, out _))
{
continue;
}
var newNameNode = matchingMember.Name.ToIdentifierName();
var newExpr = (ExpressionSyntax)newNameNode;
......
......@@ -419,8 +419,10 @@ private int GetFirstStatementAffectedIndex(SyntaxNode innermostCommonBlock, ISet
var nextStatementLeading = nextStatement.GetLeadingTrivia();
var precedingEndOfLine = nextStatementLeading.LastOrDefault(t => t.Kind() == SyntaxKind.EndOfLineTrivia);
if (precedingEndOfLine == default)
{
return oldStatements.ReplaceRange(
nextStatement, new[] { newStatement, nextStatement });
}
var endOfLineIndex = nextStatementLeading.IndexOf(precedingEndOfLine) + 1;
......
......@@ -53,7 +53,9 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
if (declaration == null ||
declaration.Variables.Count != 1 ||
forStatement.Incrementors.Count != 1)
{
return;
}
var variable = declaration.Variables[0];
var after = forStatement.Incrementors[0];
......
......@@ -93,7 +93,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
// issue there.
if (startTrivia.RawKind == _syntaxKinds.ConflictMarkerTrivia ||
middleTrivia.RawKind == _syntaxKinds.ConflictMarkerTrivia)
{
return false;
}
}
return true;
......
......@@ -484,6 +484,7 @@ private static void AssertCompilation(Project project, Compilation compilation1)
private static bool IsCanceled(Exception ex, CancellationToken cancellationToken)
=> (ex as OperationCanceledException)?.CancellationToken == cancellationToken;
#if DEBUG
private static async Task VerifyDiagnosticLocationsAsync(ImmutableArray<Diagnostic> diagnostics, Project project, CancellationToken cancellationToken)
{
foreach (var diagnostic in diagnostics)
......@@ -564,6 +565,7 @@ async Task VerifyDiagnosticLocationAsync(string id, Location location)
return null;
}
}
#endif
public static IEnumerable<DiagnosticData> ConvertToLocalDiagnostics(this IEnumerable<Diagnostic> diagnostics, Document targetDocument, TextSpan? span = null)
{
......
......@@ -131,7 +131,7 @@ public Task<ImmutableArray<DiagnosticData>> GetDiagnosticsAsync(Solution solutio
return SpecializedTasks.EmptyImmutableArray<DiagnosticData>();
}
public async Task ForceAnalyzeAsync(Solution solution, ProjectId? projectId = null, CancellationToken cancellationToken = default)
public async Task ForceAnalyzeAsync(Solution solution, Action<Project> onProjectAnalyzed, ProjectId? projectId = null, CancellationToken cancellationToken = default)
{
if (_map.TryGetValue(solution.Workspace, out var analyzer))
{
......@@ -141,6 +141,7 @@ public async Task ForceAnalyzeAsync(Solution solution, ProjectId? projectId = nu
if (project != null)
{
await analyzer.ForceAnalyzeProjectAsync(project, cancellationToken).ConfigureAwait(false);
onProjectAnalyzed(project);
}
}
else
......@@ -149,8 +150,11 @@ public async Task ForceAnalyzeAsync(Solution solution, ProjectId? projectId = nu
var index = 0;
foreach (var project in solution.Projects)
{
tasks[index++] = Task.Run(
() => analyzer.ForceAnalyzeProjectAsync(project, cancellationToken));
tasks[index++] = Task.Run(async () =>
{
await analyzer.ForceAnalyzeProjectAsync(project, cancellationToken).ConfigureAwait(false);
onProjectAnalyzed(project);
});
}
await Task.WhenAll(tasks).ConfigureAwait(false);
......
......@@ -271,20 +271,20 @@ private void VerifyDiagnostics(SemanticModel model)
GC.KeepAlive(wholeMethodBodyDiagnostics);
GC.KeepAlive(wholeDiagnostics);
}
#endif
}
private static bool IsUnusedImportDiagnostic(Diagnostic d)
{
switch (d.Id)
static bool IsUnusedImportDiagnostic(Diagnostic d)
{
case "CS8019":
case "BC50000":
case "BC50001":
return true;
default:
return false;
switch (d.Id)
{
case "CS8019":
case "BC50000":
case "BC50001":
return true;
default:
return false;
}
}
#endif
}
private static TextSpan AdjustSpan(Document document, SyntaxNode root, TextSpan span)
......
......@@ -43,7 +43,7 @@ internal interface IDiagnosticAnalyzerService
/// <summary>
/// Force computes diagnostics and raises diagnostic events for the given project or solution. all diagnostics returned should be up-to-date with respect to the given project or solution.
/// </summary>
Task ForceAnalyzeAsync(Solution solution, ProjectId? projectId = null, CancellationToken cancellationToken = default);
Task ForceAnalyzeAsync(Solution solution, Action<Project> onProjectAnalyzed, ProjectId? projectId = null, CancellationToken cancellationToken = default);
/// <summary>
/// True if given project has any diagnostics
......
......@@ -269,7 +269,9 @@ private static bool CharInClassInternal(char ch, string set, int start, int mySe
// reverse this check.
Debug.Assert((SETSTART & 0x1) == 1, "If SETSTART is not odd, the calculation below this will be reversed");
if ((min & 0x1) == (start & 0x1))
{
return true;
}
else
{
if (myCategoryLength == 0)
......@@ -302,7 +304,9 @@ private static bool CharInCategory(char ch, string set, int start, int mySetLeng
if (curcat == SpaceConst)
{
if (char.IsWhiteSpace(ch))
{
return true;
}
else
{
i++;
......@@ -320,7 +324,9 @@ private static bool CharInCategory(char ch, string set, int start, int mySetLeng
if (curcat == NotSpaceConst)
{
if (!char.IsWhiteSpace(ch))
{
return true;
}
else
{
i++;
......
......@@ -562,14 +562,6 @@ private IList<ITypeSymbol> GetArgumentTypes(IList<TArgumentSyntax> argumentList)
return typeSymbol.RemoveUnnamedErrorTypes(compilation);
}
private ICodeGenerationService GetCodeGenerationService()
{
var language = _state.TypeToGenerateInOpt == null
? _state.SimpleName.Language
: _state.TypeToGenerateInOpt.Language;
return _semanticDocument.Project.Solution.Workspace.Services.GetLanguageServices(language).GetService<ICodeGenerationService>();
}
private bool TryFindMatchingField(
ParameterName parameterName,
ITypeSymbol parameterType,
......
......@@ -199,29 +199,30 @@ public void RunAnalyzers(IVsHierarchy? hierarchy)
string? projectOrSolutionName = project?.Name ?? PathUtilities.GetFileName(solution.FilePath);
// Add a message to VS status bar that we are running code analysis.
var statusMessage = projectOrSolutionName != null
? string.Format(ServicesVSResources.Running_code_analysis_for_0, projectOrSolutionName)
: ServicesVSResources.Running_code_analysis_for_Solution;
var statusBar = _serviceProvider?.GetService(typeof(SVsStatusbar)) as IVsStatusbar;
statusBar?.SetText(statusMessage);
var totalProjectCount = project != null ? 1 : (uint)solution.ProjectIds.Count;
var statusBarUpdater = statusBar != null ?
new StatusBarUpdater(statusBar, _threadingContext, projectOrSolutionName, totalProjectCount) :
null;
// Force complete analyzer execution in background.
var asyncToken = _listener.BeginAsyncOperation($"{nameof(VisualStudioDiagnosticAnalyzerService)}_{nameof(RunAnalyzers)}");
Task.Run(async () =>
{
await _diagnosticService.ForceAnalyzeAsync(solution, project?.Id, CancellationToken.None).ConfigureAwait(false);
// If user has disabled live analyzer execution for any project(s), i.e. set RunAnalyzersDuringLiveAnalysis = false,
// then ForceAnalyzeAsync will not cause analyzers to execute.
// We explicitly fetch diagnostics for such projects and report these as "Host" diagnostics.
HandleProjectsWithDisabledAnalysis();
try
{
var onProjectAnalyzed = statusBarUpdater != null ? statusBarUpdater.OnProjectAnalyzed : (Action<Project>)((Project _) => { });
await _diagnosticService.ForceAnalyzeAsync(solution, onProjectAnalyzed, project?.Id, CancellationToken.None).ConfigureAwait(false);
// Add a message to VS status bar that we completed executing code analysis.
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync();
var notificationMesage = projectOrSolutionName != null
? string.Format(ServicesVSResources.Code_analysis_completed_for_0, projectOrSolutionName)
: ServicesVSResources.Code_analysis_completed_for_Solution;
statusBar?.SetText(notificationMesage);
// If user has disabled live analyzer execution for any project(s), i.e. set RunAnalyzersDuringLiveAnalysis = false,
// then ForceAnalyzeAsync will not cause analyzers to execute.
// We explicitly fetch diagnostics for such projects and report these as "Host" diagnostics.
HandleProjectsWithDisabledAnalysis();
}
finally
{
statusBarUpdater?.Dispose();
}
}).CompletesAsyncOperation(asyncToken);
return;
......@@ -348,5 +349,94 @@ private bool IsBuildActive()
}
}
}
private sealed class StatusBarUpdater : IDisposable
{
private readonly IVsStatusbar _statusBar;
private readonly IThreadingContext _threadingContext;
private readonly uint _totalProjectCount;
private readonly string _statusMessageWhileRunning;
private readonly string _statusMesageOnCompleted;
private readonly string _statusMesageOnTerminated;
private readonly Timer _timer;
private int _analyzedProjectCount;
private bool _disposed;
private uint _statusBarCookie;
public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingContext, string? projectOrSolutionName, uint totalProjectCount)
{
Contract.ThrowIfFalse(threadingContext.HasMainThread);
_statusBar = statusBar;
_threadingContext = threadingContext;
_totalProjectCount = totalProjectCount;
_statusMessageWhileRunning = projectOrSolutionName != null
? string.Format(ServicesVSResources.Running_code_analysis_for_0, projectOrSolutionName)
: ServicesVSResources.Running_code_analysis_for_Solution;
_statusMesageOnCompleted = projectOrSolutionName != null
? string.Format(ServicesVSResources.Code_analysis_completed_for_0, projectOrSolutionName)
: ServicesVSResources.Code_analysis_completed_for_Solution;
_statusMesageOnTerminated = projectOrSolutionName != null
? string.Format(ServicesVSResources.Code_analysis_terminated_before_completion_for_0, projectOrSolutionName)
: ServicesVSResources.Code_analysis_terminated_before_completion_for_Solution;
// Set the initial status bar progress and text.
_statusBar.Progress(ref _statusBarCookie, fInProgress: 1, _statusMessageWhileRunning, nComplete: 0, nTotal: totalProjectCount);
_statusBar.SetText(_statusMessageWhileRunning);
// Create a timer to periodically update the status message while running analysis.
_timer = new Timer(new TimerCallback(UpdateStatusOnTimer), new AutoResetEvent(false),
dueTime: TimeSpan.FromSeconds(5), period: TimeSpan.FromSeconds(5));
}
internal void OnProjectAnalyzed(Project _)
{
Interlocked.Increment(ref _analyzedProjectCount);
UpdateStatusCore();
}
// Add a message to VS status bar that we are running code analysis.
private void UpdateStatusOnTimer(object state)
=> UpdateStatusCore();
public void Dispose()
{
_timer.Dispose();
_disposed = true;
UpdateStatusCore();
}
private void UpdateStatusCore()
{
_threadingContext.JoinableTaskFactory.RunAsync(async () =>
{
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync();
string message;
int fInProgress;
var analyzedProjectCount = (uint)_analyzedProjectCount;
if (analyzedProjectCount == _totalProjectCount)
{
message = _statusMesageOnCompleted;
fInProgress = 0;
}
else if (_disposed)
{
message = _statusMesageOnTerminated;
fInProgress = 0;
}
else
{
message = _statusMessageWhileRunning;
fInProgress = 1;
}
// Update the status bar progress and text.
_statusBar.Progress(ref _statusBarCookie, fInProgress, message, analyzedProjectCount, _totalProjectCount);
_statusBar.SetText(message);
});
}
}
}
}
......@@ -1344,6 +1344,12 @@ I agree to all of the foregoing:</value>
<data name="Code_analysis_completed_for_Solution" xml:space="preserve">
<value>Code analysis completed for Solution.</value>
</data>
<data name="Code_analysis_terminated_before_completion_for_0" xml:space="preserve">
<value>Code analysis terminated before completion for '{0}'.</value>
</data>
<data name="Code_analysis_terminated_before_completion_for_Solution" xml:space="preserve">
<value>Code analysis terminated before completion for Solution.</value>
</data>
<data name="Background_analysis_scope_colon" xml:space="preserve">
<value>Background analysis scope:</value>
</data>
......
......@@ -127,6 +127,16 @@
<target state="translated">Dokončila se analýza kódu pro řešení.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Obarvit regulární výrazy</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">Die Codeanalyse für die Projektmappe wurde abgeschlossen.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Reguläre Ausdrücke farbig hervorheben</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">El análisis de código se ha completado para la solución.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Colorear expresiones regulares</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">Analyse du code effectuée pour la solution.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Coloriser les expressions régulières</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">Analisi codice completata per la soluzione.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Colora espressioni regolari</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">ソリューションのコード分析が完了しました。</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">正規表現をカラー化</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">솔루션에 대한 코드 분석이 완료되었습니다.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">정규식 색 지정</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">Ukończono analizę kodu dla rozwiązania.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Koloruj wyrażenia regularne</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">Análise de código concluída para a Solução.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Colorir expressões regulares</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">Анализ кода для решения выполнен.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Выделить регулярные выражения цветом</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">Çözüm için kod analizi tamamlandı.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">Normal ifadeleri renklendir</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">解决方案的代码分析已完成。</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">为正规表达式着色</target>
......
......@@ -127,6 +127,16 @@
<target state="translated">解決方案的程式碼分析已完成。</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source>
<target state="translated">為規則運算式添加色彩</target>
......
......@@ -508,7 +508,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Throw New NotImplementedException()
End Function
Public Function ForceAnalyzeAsync(solution As Solution, Optional projectId As ProjectId = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task Implements IDiagnosticAnalyzerService.ForceAnalyzeAsync
Public Function ForceAnalyzeAsync(solution As Solution, onProjectAnalyzed As Action(Of Project), Optional projectId As ProjectId = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task Implements IDiagnosticAnalyzerService.ForceAnalyzeAsync
Throw New NotImplementedException()
End Function
End Class
......
......@@ -237,8 +237,10 @@ internal async Task<Solution> SimplifyAsync(Solution solution, IEnumerable<Docum
var builder = ImmutableDictionary.CreateBuilder<DocumentId, ImmutableArray<ComplexifiedSpan>>();
foreach (var (docId, spans) in _documentToComplexifiedSpansMap)
{
builder.Add(docId, spans.SelectAsArray(
s => new ComplexifiedSpan(s.OriginalSpan, s.NewSpan, s.ModifiedSubSpans.ToImmutableArray())));
}
return builder.ToImmutable();
}
......
......@@ -31,10 +31,12 @@ internal class SqlConnection
/// </summary>
private readonly SafeSqliteHandle _handle;
#pragma warning disable IDE0052 // Remove unread private members - TODO: Can this field be removed?
/// <summary>
/// For testing purposes to simulate failures during testing.
/// </summary>
private readonly IPersistentStorageFaultInjector _faultInjector;
#pragma warning restore IDE0052 // Remove unread private members
/// <summary>
/// Our cache of prepared statements for given sql strings.
......
......@@ -31,10 +31,12 @@ internal class SqlConnection
/// </summary>
private readonly SafeSqliteHandle _handle;
#pragma warning disable IDE0052 // Remove unread private members - TODO: Can this field be removed?
/// <summary>
/// For testing purposes to simulate failures during testing.
/// </summary>
private readonly IPersistentStorageFaultInjector _faultInjector;
#pragma warning restore IDE0052 // Remove unread private members
/// <summary>
/// Our cache of prepared statements for given sql strings.
......
......@@ -23,7 +23,7 @@ public TestDynamicFileInfoProviderThatProducesFiles()
{
}
public event EventHandler<string> Updated;
event EventHandler<string> IDynamicFileInfoProvider.Updated { add { } remove { } }
public Task<DynamicFileInfo> GetDynamicFileInfoAsync(ProjectId projectId, string projectFilePath, string filePath, CancellationToken cancellationToken)
{
......@@ -48,8 +48,5 @@ public static string GetDynamicFileText(string filePath)
public Task RemoveDynamicFileInfoAsync(ProjectId projectId, string projectFilePath, string filePath, CancellationToken cancellationToken)
=> Task.CompletedTask;
private void OnUpdate()
=> Updated?.Invoke(this, "test");
}
}
......@@ -22,15 +22,12 @@ public TestDynamicFileInfoProviderThatProducesNoFiles()
{
}
public event EventHandler<string> Updated;
event EventHandler<string> IDynamicFileInfoProvider.Updated { add { } remove { } }
public Task<DynamicFileInfo> GetDynamicFileInfoAsync(ProjectId projectId, string projectFilePath, string filePath, CancellationToken cancellationToken)
=> Task.FromResult<DynamicFileInfo>(null);
public Task RemoveDynamicFileInfoAsync(ProjectId projectId, string projectFilePath, string filePath, CancellationToken cancellationToken)
=> Task.CompletedTask;
private void OnUpdate()
=> Updated?.Invoke(this, "test");
}
}
......@@ -68,7 +68,7 @@ public override void AddAnchorIndentationOperations(List<AnchorIndentationOperat
case AccessorDeclarationSyntax accessorDeclNode:
AddAnchorIndentationOperation(list, accessorDeclNode);
return;
case CSharpSyntaxNode switchExpressionArm when switchExpressionArm.IsKind(SyntaxKind.SwitchExpressionArm):
case SwitchExpressionArmSyntax switchExpressionArm:
// The expression in a switch expression arm should be anchored to the beginning of the arm
// ```
// e switch
......
......@@ -7,12 +7,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
......@@ -177,13 +175,8 @@ private void AddAlignmentBlockOperation(List<IndentBlockOperation> list, SyntaxN
case ImplicitArrayCreationExpressionSyntax implicitArrayCreation when implicitArrayCreation.Initializer != null:
SetAlignmentBlockOperation(list, implicitArrayCreation.NewKeyword, implicitArrayCreation.Initializer.OpenBraceToken, implicitArrayCreation.Initializer.CloseBraceToken, IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine);
return;
case CSharpSyntaxNode syntaxNode when syntaxNode.IsKind(SyntaxKind.SwitchExpression):
SetAlignmentBlockOperation(
list,
syntaxNode.GetFirstToken(),
syntaxNode.ChildNodesAndTokens().First(child => child.IsKind(SyntaxKind.OpenBraceToken)).AsToken(),
syntaxNode.ChildNodesAndTokens().Last(child => child.IsKind(SyntaxKind.CloseBraceToken)).AsToken(),
IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine);
case SwitchExpressionSyntax switchExpression:
SetAlignmentBlockOperation(list, switchExpression.GetFirstToken(), switchExpression.OpenBraceToken, switchExpression.CloseBraceToken, IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine);
return;
}
}
......
......@@ -102,7 +102,9 @@ void AddSelectedFieldOrPropertyDeclarations(TMemberDeclarationSyntax member)
{
if (!(member is TFieldDeclarationSyntax) &&
!(member is TPropertyDeclarationSyntax))
{
return;
}
// first, check if entire member is selected. If so, we definitely include this member.
if (textSpan.Contains(member.Span))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册