Skip to content

Commit 08591a1

Browse files
authored
Revert "Enc logging (#76042)"
This reverts commit d5cf1ea.
1 parent ecb4ca5 commit 08591a1

32 files changed

+375
-338
lines changed

src/EditorFeatures/Core/EditAndContinue/EditAndContinueLanguageService.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
using System.Linq;
1010
using System.Threading;
1111
using System.Threading.Tasks;
12+
using Microsoft.CodeAnalysis.BrokeredServices;
1213
using Microsoft.CodeAnalysis.Diagnostics;
1314
using Microsoft.CodeAnalysis.ErrorReporting;
1415
using Microsoft.CodeAnalysis.Host;
1516
using Microsoft.CodeAnalysis.Host.Mef;
1617
using Microsoft.CodeAnalysis.PooledObjects;
1718
using Microsoft.CodeAnalysis.Shared.Extensions;
19+
using Microsoft.CodeAnalysis.Shared.TestHooks;
1820
using Microsoft.VisualStudio.Debugger.Contracts.HotReload;
1921
using Roslyn.Utilities;
2022

@@ -29,12 +31,13 @@ namespace Microsoft.CodeAnalysis.EditAndContinue;
2931
[method: ImportingConstructor]
3032
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
3133
internal sealed class EditAndContinueLanguageService(
34+
IServiceBrokerProvider serviceBrokerProvider,
3235
EditAndContinueSessionState sessionState,
3336
Lazy<IHostWorkspaceProvider> workspaceProvider,
3437
Lazy<IManagedHotReloadService> debuggerService,
3538
PdbMatchingSourceTextProvider sourceTextProvider,
36-
IEditAndContinueLogReporter logReporter,
37-
IDiagnosticsRefresher diagnosticRefresher) : IManagedHotReloadLanguageService2, IEditAndContinueSolutionProvider
39+
IDiagnosticsRefresher diagnosticRefresher,
40+
IAsynchronousOperationListenerProvider listenerProvider) : IManagedHotReloadLanguageService2, IEditAndContinueSolutionProvider
3841
{
3942
private sealed class NoSessionException : InvalidOperationException
4043
{
@@ -46,6 +49,9 @@ public NoSessionException()
4649
}
4750
}
4851

52+
private readonly IAsynchronousOperationListener _asyncListener = listenerProvider.GetListener(FeatureAttribute.EditAndContinue);
53+
private readonly HotReloadLoggerProxy _logger = new(serviceBrokerProvider.ServiceBroker);
54+
4955
private bool _disabled;
5056
private RemoteDebuggingSessionProxy? _debuggingSession;
5157

@@ -88,7 +94,11 @@ private IActiveStatementTrackingService GetActiveStatementTrackingService()
8894
internal void Disable(Exception e)
8995
{
9096
_disabled = true;
91-
logReporter.Report(e.ToString(), LogMessageSeverity.Error);
97+
98+
var token = _asyncListener.BeginAsyncOperation(nameof(EditAndContinueLanguageService) + ".LogToOutput");
99+
100+
_ = _logger.LogAsync(new HotReloadLogMessage(HotReloadVerbosity.Diagnostic, e.ToString(), errorLevel: HotReloadDiagnosticErrorLevel.Error), CancellationToken.None).AsTask()
101+
.ReportNonFatalErrorAsync().CompletesAsyncOperation(token);
92102
}
93103

94104
private void UpdateApplyChangesDiagnostics(ImmutableArray<DiagnosticData> diagnostics)
@@ -255,7 +265,7 @@ public async ValueTask UpdateBaselinesAsync(ImmutableArray<string> projectPaths,
255265
}
256266

257267
_committedDesignTimeSolution = currentDesignTimeSolution;
258-
var projectIds = GetProjectIds(projectPaths, currentCompileTimeSolution);
268+
var projectIds = await GetProjectIdsAsync(projectPaths, currentCompileTimeSolution, cancellationToken).ConfigureAwait(false);
259269

260270
try
261271
{
@@ -271,7 +281,7 @@ public async ValueTask UpdateBaselinesAsync(ImmutableArray<string> projectPaths,
271281
}
272282
}
273283

274-
private ImmutableArray<ProjectId> GetProjectIds(ImmutableArray<string> projectPaths, Solution solution)
284+
private async ValueTask<ImmutableArray<ProjectId>> GetProjectIdsAsync(ImmutableArray<string> projectPaths, Solution solution, CancellationToken cancellationToken)
275285
{
276286
using var _ = ArrayBuilder<ProjectId>.GetInstance(out var projectIds);
277287
foreach (var path in projectPaths)
@@ -283,7 +293,11 @@ private ImmutableArray<ProjectId> GetProjectIds(ImmutableArray<string> projectPa
283293
}
284294
else
285295
{
286-
logReporter.Report($"Project with path '{path}' not found in the current solution.", LogMessageSeverity.Info);
296+
await _logger.LogAsync(new HotReloadLogMessage(
297+
HotReloadVerbosity.Diagnostic,
298+
$"Project with path '{path}' not found in the current solution.",
299+
errorLevel: HotReloadDiagnosticErrorLevel.Warning),
300+
cancellationToken).ConfigureAwait(false);
287301
}
288302
}
289303

src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
<ItemGroup>
3737
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\IsExternalInit.cs" Link="Utilities\IsExternalInit.cs" />
3838
<Compile Include="..\..\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\BrokeredServices\ServiceBrokerProvider.cs" Link="BrokeredServices\ServiceBrokerProvider.cs" />
39-
<Compile Include="..\..\Workspaces\Remote\ServiceHub\Services\EditAndContinue\EditAndContinueLogReporter.cs" Link="EditAndContinue\EditAndContinueLogReporter.cs" />
40-
<Compile Include="..\..\Workspaces\Remote\ServiceHub\Services\EditAndContinue\HotReloadLoggerProxy.cs" Link="EditAndContinue\HotReloadLoggerProxy.cs" />
4139
</ItemGroup>
4240
<ItemGroup>
4341
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" LoadsWithinVisualStudio="false" />

src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
using Microsoft.CodeAnalysis.CSharp.Syntax;
1616
using Microsoft.CodeAnalysis.Differencing;
1717
using Microsoft.CodeAnalysis.EditAndContinue;
18+
using Microsoft.CodeAnalysis.Formatting;
19+
using Microsoft.CodeAnalysis.Host;
1820
using Microsoft.CodeAnalysis.Host.Mef;
1921
using Microsoft.CodeAnalysis.PooledObjects;
2022
using Microsoft.CodeAnalysis.Shared.Collections;
@@ -24,11 +26,17 @@
2426

2527
namespace Microsoft.CodeAnalysis.CSharp.EditAndContinue;
2628

27-
[ExportLanguageService(typeof(IEditAndContinueAnalyzer), LanguageNames.CSharp), Shared]
28-
[method: ImportingConstructor]
29-
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
30-
internal sealed class CSharpEditAndContinueAnalyzer() : AbstractEditAndContinueAnalyzer
29+
internal sealed class CSharpEditAndContinueAnalyzer(Action<SyntaxNode>? testFaultInjector = null) : AbstractEditAndContinueAnalyzer(testFaultInjector)
3130
{
31+
[ExportLanguageServiceFactory(typeof(IEditAndContinueAnalyzer), LanguageNames.CSharp), Shared]
32+
[method: ImportingConstructor]
33+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
34+
internal sealed class Factory() : ILanguageServiceFactory
35+
{
36+
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
37+
=> new CSharpEditAndContinueAnalyzer(testFaultInjector: null);
38+
}
39+
3240
#region Syntax Analysis
3341

3442
private enum BlockPart

src/Features/CSharpTest/EditAndContinue/CSharpEditAndContinueAnalyzerTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,10 @@ private static async Task<DocumentAnalysisResults> AnalyzeDocumentAsync(
122122
EditAndContinueCapabilities capabilities = EditAndContinueTestVerifier.Net5RuntimeCapabilities,
123123
ImmutableArray<ActiveStatementLineSpan> newActiveStatementSpans = default)
124124
{
125-
var analyzer = oldProject.Services.GetRequiredService<IEditAndContinueAnalyzer>();
125+
var analyzer = new CSharpEditAndContinueAnalyzer();
126126
var baseActiveStatements = AsyncLazy.Create(activeStatementMap ?? ActiveStatementsMap.Empty);
127127
var lazyCapabilities = AsyncLazy.Create(capabilities);
128-
var log = new TraceLog("Test");
129-
return await analyzer.AnalyzeDocumentAsync(oldProject, baseActiveStatements, newDocument, newActiveStatementSpans.NullToEmpty(), lazyCapabilities, log, CancellationToken.None);
128+
return await analyzer.AnalyzeDocumentAsync(oldProject, baseActiveStatements, newDocument, newActiveStatementSpans.NullToEmpty(), lazyCapabilities, CancellationToken.None);
130129
}
131130

132131
#endregion
@@ -750,17 +749,15 @@ public async Task AnalyzeDocumentAsync_InternalError(bool outOfMemory)
750749
var baseActiveStatements = AsyncLazy.Create(ActiveStatementsMap.Empty);
751750
var capabilities = AsyncLazy.Create(EditAndContinueTestVerifier.Net5RuntimeCapabilities);
752751

753-
var analyzer = Assert.IsType<CSharpEditAndContinueAnalyzer>(oldProject.Services.GetRequiredService<IEditAndContinueAnalyzer>());
754-
analyzer.GetTestAccessor().FaultInjector = node =>
752+
var analyzer = new CSharpEditAndContinueAnalyzer(node =>
755753
{
756754
if (node is CompilationUnitSyntax)
757755
{
758756
throw outOfMemory ? new OutOfMemoryException() : new NullReferenceException("NullRef!");
759757
}
760-
};
758+
});
761759

762-
var log = new TraceLog("Test");
763-
var result = await analyzer.AnalyzeDocumentAsync(oldProject, baseActiveStatements, newDocument, [], capabilities, log, CancellationToken.None);
760+
var result = await analyzer.AnalyzeDocumentAsync(oldProject, baseActiveStatements, newDocument, [], capabilities, CancellationToken.None);
764761

765762
var expectedDiagnostic = outOfMemory
766763
? $"ENC0089: {string.Format(FeaturesResources.Modifying_source_file_0_requires_restarting_the_application_because_the_file_is_too_big, filePath)}"

src/Features/CSharpTest/EditAndContinue/Helpers/CSharpEditAndContinueTestVerifier.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
using System.Collections.Immutable;
77
using Microsoft.CodeAnalysis.CSharp.Symbols;
88
using Microsoft.CodeAnalysis.Differencing;
9+
using Microsoft.CodeAnalysis.EditAndContinue;
910
using Microsoft.CodeAnalysis.EditAndContinue.UnitTests;
1011
using Xunit;
1112

1213
namespace Microsoft.CodeAnalysis.CSharp.EditAndContinue.UnitTests;
1314

14-
internal sealed class CSharpEditAndContinueTestVerifier(Action<SyntaxNode>? faultInjector = null) : EditAndContinueTestVerifier(faultInjector)
15+
internal sealed class CSharpEditAndContinueTestVerifier(Action<SyntaxNode>? faultInjector = null) : EditAndContinueTestVerifier
1516
{
17+
private readonly CSharpEditAndContinueAnalyzer _analyzer = new(faultInjector);
18+
19+
public override AbstractEditAndContinueAnalyzer Analyzer => _analyzer;
1620
public override string LanguageName => LanguageNames.CSharp;
1721
public override string ProjectFileExtension => ".csproj";
1822
public override TreeComparer<SyntaxNode> TopSyntaxComparer => SyntaxComparer.TopLevel;

src/Features/CSharpTest/EditAndContinue/Helpers/EditAndContinueValidation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using Microsoft.CodeAnalysis.Contracts.EditAndContinue;
5+
using Microsoft.CodeAnalysis.Differencing;
66
using Microsoft.CodeAnalysis.EditAndContinue;
7+
using Microsoft.CodeAnalysis.Contracts.EditAndContinue;
78
using Microsoft.CodeAnalysis.EditAndContinue.UnitTests;
89
using Roslyn.Test.Utilities;
910
using Xunit;

src/Features/CSharpTest/EditAndContinue/Helpers/EditingTestBase.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
using System;
66
using System.Collections.Generic;
77
using System.IO;
8-
using System.Linq;
9-
using Microsoft.CodeAnalysis.Contracts.EditAndContinue;
108
using Microsoft.CodeAnalysis.CSharp.Syntax;
119
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
1210
using Microsoft.CodeAnalysis.CSharp.UnitTests;
1311
using Microsoft.CodeAnalysis.Differencing;
1412
using Microsoft.CodeAnalysis.EditAndContinue;
13+
using Microsoft.CodeAnalysis.Contracts.EditAndContinue;
1514
using Microsoft.CodeAnalysis.EditAndContinue.UnitTests;
1615
using Microsoft.CodeAnalysis.Emit;
17-
using Microsoft.CodeAnalysis.Host.Mef;
1816
using Microsoft.CodeAnalysis.Test.Utilities;
1917
using Microsoft.CodeAnalysis.Text;
2018
using Roslyn.Utilities;
@@ -29,6 +27,11 @@ public abstract class EditingTestBase : CSharpTestBase
2927
namespace System.Runtime.CompilerServices { class CreateNewOnMetadataUpdateAttribute : Attribute {} }
3028
";
3129

30+
internal static CSharpEditAndContinueAnalyzer CreateAnalyzer()
31+
{
32+
return new CSharpEditAndContinueAnalyzer(testFaultInjector: null);
33+
}
34+
3235
internal enum MethodKind
3336
{
3437
Regular,
@@ -181,8 +184,7 @@ internal static Match<SyntaxNode> GetMethodMatch(string src1, string src2, Metho
181184
internal static IEnumerable<KeyValuePair<SyntaxNode, SyntaxNode>> GetMethodMatches(string src1, string src2, MethodKind kind = MethodKind.Regular)
182185
{
183186
var methodMatch = GetMethodMatch(src1, src2, kind);
184-
var analyzer = EditAndContinueTestVerifier.CreateAnalyzer(faultInjector: null, LanguageNames.CSharp);
185-
return EditAndContinueTestVerifier.GetMethodMatches(analyzer, methodMatch);
187+
return EditAndContinueTestVerifier.GetMethodMatches(CreateAnalyzer(), methodMatch);
186188
}
187189

188190
public static MatchingPairs ToMatchingPairs(Match<SyntaxNode> match)

src/Features/CSharpTest/EditAndContinue/StatementMatchingTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
using System.Collections.Generic;
88
using Microsoft.CodeAnalysis.CSharp.Syntax;
99
using Microsoft.CodeAnalysis.EditAndContinue.UnitTests;
10-
using Microsoft.CodeAnalysis.Test.Utilities;
1110
using Roslyn.Test.Utilities;
1211
using Xunit;
1312

1413
namespace Microsoft.CodeAnalysis.CSharp.EditAndContinue.UnitTests;
1514

16-
[UseExportProvider]
1715
public class StatementMatchingTests : EditingTestBase
1816
{
1917
#region Known Matches

0 commit comments

Comments
 (0)