Skip to content

Commit 238e824

Browse files
committed
Logger isn't null
1 parent 77b30be commit 238e824

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Endpoints/RazorCustomMessageTarget.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,50 +141,50 @@ private async Task<SynchronizedResult<TVirtualDocumentSnapshot>> TrySynchronizeV
141141
return await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync<TVirtualDocumentSnapshot>(requiredHostDocumentVersion, hostDocument.Uri, cancellationToken).ConfigureAwait(false);
142142
}
143143

144-
_logger?.LogDebug($"Trying to synchronize for {caller} to version {requiredHostDocumentVersion} of {hostDocument.Uri} for {hostDocument.GetProjectContext()?.Id ?? "(no project context)"}");
144+
_logger.LogDebug($"Trying to synchronize for {caller} to version {requiredHostDocumentVersion} of {hostDocument.Uri} for {hostDocument.GetProjectContext()?.Id ?? "(no project context)"}");
145145

146146
var virtualDocument = FindVirtualDocument<TVirtualDocumentSnapshot>(hostDocument.Uri, hostDocument.GetProjectContext());
147147

148148
if (virtualDocument is { ProjectKey.Id: null })
149149
{
150-
_logger?.LogDebug($"Trying to sync to a doc with no project Id. Waiting for document add.");
150+
_logger.LogDebug($"Trying to sync to a doc with no project Id. Waiting for document add.");
151151
if (await _csharpVirtualDocumentAddListener.WaitForDocumentAddAsync(cancellationToken).ConfigureAwait(false))
152152
{
153-
_logger?.LogDebug($"Wait successful!");
153+
_logger.LogDebug($"Wait successful!");
154154
virtualDocument = FindVirtualDocument<TVirtualDocumentSnapshot>(hostDocument.Uri, hostDocument.GetProjectContext());
155155
}
156156
else
157157
{
158-
_logger?.LogDebug($"Timed out :(");
158+
_logger.LogDebug($"Timed out :(");
159159
}
160160
}
161161

162162
if (virtualDocument is null)
163163
{
164-
_logger?.LogDebug($"No virtual document found, falling back to old code.");
164+
_logger.LogDebug($"No virtual document found, falling back to old code.");
165165
return await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync<TVirtualDocumentSnapshot>(requiredHostDocumentVersion, hostDocument.Uri, cancellationToken).ConfigureAwait(false);
166166
}
167167

168168
var result = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync<TVirtualDocumentSnapshot>(requiredHostDocumentVersion, hostDocument.Uri, virtualDocument.Uri, rejectOnNewerParallelRequest, cancellationToken).ConfigureAwait(false);
169-
_logger?.LogDebug($"{(result.Synchronized ? "Did" : "Did NOT")} synchronize for {caller}: Version {requiredHostDocumentVersion} for {result.VirtualSnapshot?.Uri}");
169+
_logger.LogDebug($"{(result.Synchronized ? "Did" : "Did NOT")} synchronize for {caller}: Version {requiredHostDocumentVersion} for {result.VirtualSnapshot?.Uri}");
170170

171171
// If we failed to sync on version 1, then it could be that we got new information while waiting, so try again
172172
if (requiredHostDocumentVersion == 1 && !result.Synchronized)
173173
{
174-
_logger?.LogDebug($"Sync failed for v1 document. Trying to get virtual document again.");
174+
_logger.LogDebug($"Sync failed for v1 document. Trying to get virtual document again.");
175175
virtualDocument = FindVirtualDocument<TVirtualDocumentSnapshot>(hostDocument.Uri, hostDocument.GetProjectContext());
176176

177177
if (virtualDocument is null)
178178
{
179-
_logger?.LogDebug($"No virtual document found, falling back to old code.");
179+
_logger.LogDebug($"No virtual document found, falling back to old code.");
180180
return await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync<TVirtualDocumentSnapshot>(requiredHostDocumentVersion, hostDocument.Uri, cancellationToken).ConfigureAwait(false);
181181
}
182182

183-
_logger?.LogDebug($"Got virtual document after trying again {virtualDocument.Uri}. Trying to synchronize again.");
183+
_logger.LogDebug($"Got virtual document after trying again {virtualDocument.Uri}. Trying to synchronize again.");
184184

185185
// try again
186186
result = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync<TVirtualDocumentSnapshot>(requiredHostDocumentVersion, hostDocument.Uri, virtualDocument.Uri, rejectOnNewerParallelRequest, cancellationToken).ConfigureAwait(false);
187-
_logger?.LogDebug($"{(result.Synchronized ? "Did" : "Did NOT")} synchronize for {caller}: Version {requiredHostDocumentVersion} for {result.VirtualSnapshot?.Uri}");
187+
_logger.LogDebug($"{(result.Synchronized ? "Did" : "Did NOT")} synchronize for {caller}: Version {requiredHostDocumentVersion} for {result.VirtualSnapshot?.Uri}");
188188
}
189189

190190
return result;

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Endpoints/RazorCustomMessageTarget_Diagnostics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal partial class RazorCustomMessageTarget
4343
{
4444
if (e is not OperationCanceledException)
4545
{
46-
_logger?.LogError(e, $"Exception thrown in PullDiagnostic delegation");
46+
_logger.LogError(e, $"Exception thrown in PullDiagnostic delegation");
4747
}
4848
// Return null if any of the tasks getting diagnostics results in an error
4949
return null;

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Endpoints/RazorCustomMessageTarget_SemanticTokens.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ internal partial class RazorCustomMessageTarget
132132

133133
if (response?.Data is null)
134134
{
135-
_logger?.LogDebug($"Made one semantic token request to Roslyn for {semanticTokensParams.Ranges.Length} ranges but got null result back, due to sync issues");
135+
_logger.LogDebug($"Made one semantic token request to Roslyn for {semanticTokensParams.Ranges.Length} ranges but got null result back, due to sync issues");
136136
// Weren't able to re-invoke C# semantic tokens but we have to indicate it's due to out of sync by providing the old version
137137
return new ProvideSemanticTokensResponse(tokens: null, hostDocumentSyncVersion: csharpDoc.HostDocumentSyncVersion ?? -1);
138138
}
139139

140-
_logger?.LogDebug($"Made one semantic token requests to Roslyn for {semanticTokensParams.Ranges.Length} ranges");
140+
_logger.LogDebug($"Made one semantic token requests to Roslyn for {semanticTokensParams.Ranges.Length} ranges");
141141
return new ProvideSemanticTokensResponse(response.Data, semanticTokensParams.RequiredHostDocumentVersion);
142142
}
143143

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Endpoints/RazorCustomMessageTarget_UpdateCSharpBuffer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT license. See License.txt in the project root for license information.
33

44
using System;
@@ -40,7 +40,7 @@ internal async Task UpdateCSharpBufferCoreAsync(UpdateBufferRequest request, Can
4040

4141
var hostDocumentUri = new Uri(request.HostDocumentFilePath);
4242

43-
_logger?.LogDebug($"UpdateCSharpBuffer for {request.HostDocumentVersion} of {hostDocumentUri} in {request.ProjectKeyId}");
43+
_logger.LogDebug($"UpdateCSharpBuffer for {request.HostDocumentVersion} of {hostDocumentUri} in {request.ProjectKeyId}");
4444

4545
// If we're generating unique file paths for virtual documents, then we have to take a different path here, and do more work
4646
if (_languageServerFeatureOptions.IncludeProjectKeyInGeneratedFilePath &&
@@ -54,7 +54,7 @@ request.ProjectKeyId is not null &&
5454
// but the server clearly knows about it in a real project. That means its probably new, as Visual Studio opens a buffer
5555
// for a document before we get the notifications about it being added to any projects. Lets try refreshing before
5656
// we worry.
57-
_logger?.LogDebug($"Refreshing virtual documents, and waiting for them, (for {hostDocumentUri})");
57+
_logger.LogDebug($"Refreshing virtual documents, and waiting for them, (for {hostDocumentUri})");
5858

5959
var task = _csharpVirtualDocumentAddListener.WaitForDocumentAddAsync(cancellationToken);
6060
_documentManager.RefreshVirtualDocuments();
@@ -70,7 +70,7 @@ request.ProjectKeyId is not null &&
7070
// sync with their understanding of the document contents, and since changes come in as a list of changes,
7171
// the user experience is broken. All we can do is hope the user closes and re-opens the document.
7272
Debug.Fail($"Server wants to update {hostDocumentUri} in {request.ProjectKeyId} but we don't know about the document being in any projects");
73-
_logger?.LogError($"Server wants to update {hostDocumentUri} in {request.ProjectKeyId} by we only know about that document in misc files. Server and client are now out of sync.");
73+
_logger.LogError($"Server wants to update {hostDocumentUri} in {request.ProjectKeyId} by we only know about that document in misc files. Server and client are now out of sync.");
7474
return;
7575
}
7676
}
@@ -79,7 +79,7 @@ request.ProjectKeyId is not null &&
7979
{
8080
if (virtualDocument.ProjectKey.Equals(ProjectKey.FromString(request.ProjectKeyId)))
8181
{
82-
_logger?.LogDebug($"UpdateCSharpBuffer virtual doc for {request.HostDocumentVersion} of {virtualDocument.Uri}");
82+
_logger.LogDebug($"UpdateCSharpBuffer virtual doc for {request.HostDocumentVersion} of {virtualDocument.Uri}");
8383

8484
_documentManager.UpdateVirtualDocument<CSharpVirtualDocument>(
8585
hostDocumentUri,
@@ -99,14 +99,14 @@ request.ProjectKeyId is not null &&
9999
Debug.Fail("Multiple virtual documents seem to be supported, but none were updated, which is not impossible, but surprising.");
100100
}
101101

102-
_logger?.LogDebug($"UpdateCSharpBuffer couldn't find any virtual docs for {request.HostDocumentVersion} of {hostDocumentUri}");
102+
_logger.LogDebug($"UpdateCSharpBuffer couldn't find any virtual docs for {request.HostDocumentVersion} of {hostDocumentUri}");
103103

104104
// Don't know about document, no-op. This can happen if the language server found a project.razor.bin from an old build
105105
// and is sending us updates.
106106
return;
107107
}
108108

109-
_logger?.LogDebug($"UpdateCSharpBuffer fallback for {request.HostDocumentVersion} of {hostDocumentUri}");
109+
_logger.LogDebug($"UpdateCSharpBuffer fallback for {request.HostDocumentVersion} of {hostDocumentUri}");
110110

111111
_documentManager.UpdateVirtualDocument<CSharpVirtualDocument>(
112112
hostDocumentUri,

0 commit comments

Comments
 (0)