Skip to content
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
744e6c6
Add ParsedDocumentUri: C# port of vscode-uri's URI class
dibarbet Apr 16, 2026
08909d5
Eagerly compute FsPath in ParsedDocumentUri constructor
dibarbet Apr 16, 2026
9ef7108
Update tests to use FsPath property instead of GetFileSystemPath()
dibarbet Apr 16, 2026
f3d84df
Remove With method and Undefined sentinel from ParsedDocumentUri
dibarbet Apr 16, 2026
ead2d19
Integrate ParsedDocumentUri into DocumentUri, obsolete System.Uri
dibarbet Apr 16, 2026
6aa574e
Simplify DocumentUri to single ParsedDocumentUri representation
dibarbet Apr 20, 2026
40321c5
Add case-insensitive equality for UNC/DOS file URIs
dibarbet Apr 20, 2026
9decdb4
Add encoded vs unencoded URI equality test cases
dibarbet Apr 21, 2026
8eb7a81
Switch LSP to ParsedUri
dibarbet Apr 21, 2026
1b0f9ac
review feedback
dibarbet Jul 22, 2026
9dcc5c1
more feedback
dibarbet Jul 22, 2026
3594cf5
Reduce allocations creating URIs
dibarbet Jul 27, 2026
3a17ec1
Optimize ParsedUri file URI allocations
dibarbet Jul 28, 2026
b3a209b
Use span-based ParsedUri parser
dibarbet Jul 28, 2026
4653072
Remove remaining ParsedUri regex helpers
dibarbet Jul 28, 2026
0ecea16
Ensure source generated uri query parameters round-trip properly when…
dibarbet Jul 28, 2026
8d06111
Fix authority equality comparisons and scheme validation
dibarbet Jul 28, 2026
db950c3
Tracking bug for obsolete URI helpers
dibarbet Aug 6, 2026
2f8ddb3
update comment on converting documenturi to system.uri
dibarbet Aug 6, 2026
8521942
clarify usage of escapedatastring
dibarbet Aug 6, 2026
fd688e7
Adjust and add tests to ParsedUri to get 100% coverage
dibarbet Aug 6, 2026
66280ca
Use System.Range for components
dibarbet Aug 6, 2026
c471ecf
Use span decoding
dibarbet Aug 6, 2026
45a232b
more local functions
dibarbet Aug 6, 2026
b0aeff4
explanation comments
dibarbet Aug 6, 2026
250a4c2
encoding comments
dibarbet Aug 6, 2026
96cbf76
add GetEncodeTableEntry doc comment
dibarbet Aug 6, 2026
c53703a
add comment on DecodeUriComponentGraceful behavior matching vscode-uri
dibarbet Aug 6, 2026
27e59cb
clarify naming of EncodeUriComponentFast
dibarbet Aug 6, 2026
143076a
normalize to char.ToLowerInvariant
dibarbet Aug 6, 2026
1a071a5
add comment on fragment with skip encoding
dibarbet Aug 6, 2026
c69fdf7
update obsolete attribute comments
dibarbet Aug 7, 2026
9b46084
progress update comments
dibarbet Aug 7, 2026
738ed07
scheme comment
dibarbet Aug 7, 2026
c29c551
update getrequiredlegacysystemuri
dibarbet Aug 7, 2026
50d0e1b
sg scheme case insensitive
dibarbet Aug 7, 2026
984b85d
update comment on language info provider
dibarbet Aug 7, 2026
3081dba
Merge remote-tracking branch 'upstream/main' into vscode-uri
dibarbet Aug 7, 2026
b0f4631
Merge remote-tracking branch 'upstream/main' into vscode-uri
dibarbet Aug 7, 2026
300676c
respond to razor changes
dibarbet Aug 7, 2026
e6e646e
fix another merge warning
dibarbet Aug 8, 2026
d0b1786
fix razor assertions
dibarbet Aug 10, 2026
e75762d
Merge remote-tracking branch 'upstream/main' into vscode-uri
dibarbet Aug 25, 2026
1b9efcd
review feedback
dibarbet Aug 27, 2026
d2bec4b
Merge remote-tracking branch 'upstream/main' into vscode-uri
dibarbet Aug 27, 2026
0ab110f
Merge remote-tracking branch 'upstream/main' into vscode-uri
dibarbet Aug 28, 2026
9eb6d8d
address new uri usages from merge
dibarbet Aug 28, 2026
af638a5
fix new razor uri usages
dibarbet Aug 28, 2026
b451175
Merge branch 'main' into vscode-uri
dibarbet Sep 2, 2026
8b63c47
fix test from merge
dibarbet Sep 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/LanguageServer/BannedSymbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ T:System.ComponentModel.Composition.PartNotDiscoverableAttribute; Use types from
T:System.ComponentModel.Composition.SharedAttribute; Use types from System.Composition instead
T:System.ComponentModel.Composition.SharingBoundaryAttribute; Use types from System.Composition instead
T:System.ComponentModel.Composition.Convention.AttributedModelProvider; Use types from System.Composition instead
T:System.Uri; Use DocumentUri or ParsedUri unless a System.Uri is absolutely required for API calls.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if we're better off banning Uri.ctor or something so that way some of the static members on it you didn't have to suppress for.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer banning the type to ensure any usage of it is justified (even if we get the System.Uri from someone else)

Comment thread
dibarbet marked this conversation as resolved.
Resolved
M:System.Uri.#ctor(System.String); Use Extensions.GetURI() if you have a document, or ProtocolConversions.CreateAbsoluteUri if you are sure the path is a real file path and not a generated file path
M:System.Uri.#ctor(System.String,System.Boolean); Use Extensions.GetURI() if you have a document, or ProtocolConversions.CreateAbsoluteUri if you are sure the path is a real file path and not a generated file path
M:System.Uri.#ctor(System.String,System.UriCreationOptions); Use Extensions.GetURI() if you have a document, or ProtocolConversions.CreateAbsoluteUri if you are sure the path is a real file path and not a generated file path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@ internal abstract class AbstractCompilerDeveloperSdkLspServiceDocumentRequestHan
{
public abstract bool RequiresLSPSolution { get; }
public abstract Task<TResponse> HandleRequestAsync(TRequest request, RequestContext context, CancellationToken cancellationToken);
public abstract Uri GetTextDocumentIdentifier(TRequest request);

[Obsolete("Override GetDocumentUri instead. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public virtual Uri GetTextDocumentIdentifier(TRequest request)
=> throw new NotImplementedException();

public virtual DocumentUri GetDocumentUri(TRequest request)
{
#pragma warning disable CS0618 // Delegating to the legacy override for compatibility.
return new(GetTextDocumentIdentifier(request));
#pragma warning restore CS0618
}

public abstract bool MutatesSolutionState { get; }

bool IMethodHandler.MutatesSolutionState => MutatesSolutionState;
bool ISolutionRequiredHandler.RequiresLSPSolution => RequiresLSPSolution;

TextDocumentIdentifier ITextDocumentIdentifierHandler<TRequest, TextDocumentIdentifier>.GetTextDocumentIdentifier(TRequest request)
=> new() { DocumentUri = new(GetTextDocumentIdentifier(request)) };
=> new() { DocumentUri = GetDocumentUri(request) };
Task<TResponse> IRequestHandler<TRequest, TResponse, LspRequestContext>.HandleRequestAsync(TRequest request, LspRequestContext context, CancellationToken cancellationToken)
=> HandleRequestAsync(request, new RequestContext(context), cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot;
internal abstract class AbstractCopilotLspServiceDocumentRequestHandler<TRequest, TResponse> : ILspServiceDocumentRequestHandler<TRequest, TResponse>
{
public abstract Task<TResponse> HandleRequestAsync(TRequest request, CopilotRequestContext context, CancellationToken cancellationToken);
public abstract Uri GetTextDocumentUri(TRequest request);

[Obsolete("Override GetDocumentUri instead. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public virtual Uri GetTextDocumentUri(TRequest request)
=> throw new NotImplementedException();

public virtual DocumentUri GetDocumentUri(TRequest request)
{
#pragma warning disable CS0618 // Delegating to the legacy override for compatibility.
return new(GetTextDocumentUri(request));
#pragma warning restore CS0618
}

bool IMethodHandler.MutatesSolutionState => false;
bool ISolutionRequiredHandler.RequiresLSPSolution => true;

TextDocumentIdentifier ITextDocumentIdentifierHandler<TRequest, TextDocumentIdentifier>.GetTextDocumentIdentifier(TRequest request)
=> new() { DocumentUri = new(GetTextDocumentUri(request)) };
=> new() { DocumentUri = GetDocumentUri(request) };

Task<TResponse> IRequestHandler<TRequest, TResponse, RequestContext>.HandleRequestAsync(TRequest request, RequestContext context, CancellationToken cancellationToken)
=> HandleRequestAsync(request, new CopilotRequestContext(context), cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
using System.Linq;
using Microsoft.CodeAnalysis.LanguageServer;
using Microsoft.CodeAnalysis.QuickInfo;
using Roslyn.LanguageServer.Protocol;
using LSP = Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.ExternalAccess.Xaml;

internal static class ConversionHelpers
{
[Obsolete("Use CreateAbsoluteDocumentUri instead. This method will be removed in a future version. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public static Uri CreateAbsoluteUri(string absolutePath)
=> ProtocolConversions.CreateAbsoluteUri(absolutePath);

public static DocumentUri CreateAbsoluteDocumentUri(string absolutePath)
=> ProtocolConversions.CreateAbsoluteDocumentUri(absolutePath);

public static (string content, bool isMarkdown) CreateMarkdownContent(TextDocument document, QuickInfoItem info, XamlRequestContext context)
{
var clientSupportsMarkdown = context.ClientCapabilities?.TextDocument?.Hover?.ContentFormat?.Contains(LSP.MarkupKind.Markdown) == true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.ExternalAccess.Xaml;

Expand All @@ -14,6 +15,11 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Xaml;
/// </remarks>
internal interface IResolveCachedDataService
{
[Obsolete("Use overload that takes a DocumentUri instead of Uri. This method will be removed in a future version. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
object ToResolveData(object data, Uri uri);
[Obsolete("Use FromResolveDataDocumentUri instead. This method will be removed in a future version. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
(object? data, Uri? uri) FromResolveData(object? resolveData);

object ToResolveData(object data, DocumentUri uri);
(object? data, DocumentUri? uri) FromResolveDataDocumentUri(object? resolveData);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.Json;
using Microsoft.CodeAnalysis.LanguageServer;
using Microsoft.CodeAnalysis.LanguageServer.Handler;
using Roslyn.LanguageServer.Protocol;
using LSP = Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.ExternalAccess.Xaml;
Expand All @@ -15,24 +16,14 @@ internal static class ResolveDataConversions
private record DataResolveData(object Data, LSP.TextDocumentIdentifier Document) : DocumentResolveData(Document);
private record DataIdResolveData(long DataId, LSP.TextDocumentIdentifier Document) : DocumentResolveData(Document);

public static object ToResolveData(object data, Uri uri)
Comment thread
dibarbet marked this conversation as resolved.
Resolved
=> new DataResolveData(data, new LSP.TextDocumentIdentifier { DocumentUri = new(uri) });

public static (object? data, Uri? uri) FromResolveData(object? requestData)
{
Contract.ThrowIfNull(requestData);
var resolveData = JsonSerializer.Deserialize<DataResolveData>((JsonElement)requestData);
return (resolveData?.Data, resolveData?.Document.DocumentUri.GetRequiredParsedUri());
}

internal static object ToCachedResolveData(object data, Uri uri, ResolveDataCache resolveDataCache)
internal static object ToCachedResolveData(object data, DocumentUri uri, ResolveDataCache resolveDataCache)
{
var dataId = resolveDataCache.UpdateCache(data);

return new DataIdResolveData(dataId, new LSP.TextDocumentIdentifier { DocumentUri = new(uri) });
return new DataIdResolveData(dataId, new LSP.TextDocumentIdentifier { DocumentUri = uri });
}

internal static (object? data, Uri? uri) FromCachedResolveData(object? lspData, ResolveDataCache resolveDataCache)
internal static (object? data, DocumentUri? uri) FromCachedResolveData(object? lspData, ResolveDataCache resolveDataCache)
{
DataIdResolveData? resolveData;
if (lspData is JsonElement token)
Expand All @@ -48,6 +39,6 @@ internal static (object? data, Uri? uri) FromCachedResolveData(object? lspData,
var data = resolveDataCache.GetCachedEntry(resolveData.DataId);
var document = resolveData.Document;

return (data, document.DocumentUri.GetRequiredParsedUri());
return (data, document.DocumentUri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using Microsoft.CodeAnalysis.LanguageServer.Handler;
using Roslyn.LanguageServer.Protocol;
using LSP = Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.ExternalAccess.Xaml;
Expand All @@ -27,14 +28,27 @@ private XamlRequestContext(RequestContext context)
[Obsolete("Use ClientCapabilities instead.")]
public readonly IClientCapabilityProvider ClientCapabilityProvider => new ClientCapabilityProvider(_context.GetRequiredClientCapabilities());

[Obsolete("Use overload that takes a DocumentUri instead of Uri. This method will be removed in a future version. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public object ToCachedResolveData(object data, Uri uri)
{
return ToCachedResolveData(data, new DocumentUri(uri));
}

public object ToCachedResolveData(object data, DocumentUri uri)
{
var resolveDataCache = _context.GetRequiredLspService<ResolveDataCache>();

return ResolveDataConversions.ToCachedResolveData(data, uri, resolveDataCache);
}

[Obsolete("Use FromCachedResolveDataDocumentUri instead. This method will be removed in a future version. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public (object? data, Uri? uri) FromCachedResolveData(object? lspData)
{
var (data, documentUri) = FromCachedResolveDataDocumentUri(lspData);
return (data, documentUri?.ParsedUri);
}

public (object? data, DocumentUri? uri) FromCachedResolveDataDocumentUri(object? lspData)
{
var resolveDataCache = _context.GetRequiredLspService<ResolveDataCache>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.LanguageServer.Handler;
using Roslyn.LanguageServer.Protocol;
using LSP = Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.ExternalAccess.Xaml;
Expand All @@ -24,9 +25,18 @@ public XamlRequestHandlerBase(IXamlRequestHandler<TRequest, TResponse>? xamlRequ
public bool RequiresLSPSolution => true;

public LSP.TextDocumentIdentifier GetTextDocumentIdentifier(TRequest request)
=> new() { DocumentUri = new(GetTextDocumentUri(request)) };
=> new() { DocumentUri = GetDocumentUri(request) };

public abstract Uri GetTextDocumentUri(TRequest request);
public virtual LSP.DocumentUri GetDocumentUri(TRequest request)
{
#pragma warning disable CS0618 // Delegating to the legacy override for compatibility.
return new(GetTextDocumentUri(request));
#pragma warning restore CS0618
}

[Obsolete("Override GetDocumentUri instead. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public virtual Uri GetTextDocumentUri(TRequest request)
=> throw new NotImplementedException();

public Task<TResponse> HandleRequestAsync(TRequest request, RequestContext context, CancellationToken cancellationToken)
=> _xamlRequestHandler?.HandleRequestAsync(request, XamlRequestContext.FromRequestContext(context), cancellationToken) ?? throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using Microsoft.CodeAnalysis.LanguageServer;
using Microsoft.CodeAnalysis.LanguageServer.Handler;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.ExternalAccess.Xaml;

Expand Down Expand Up @@ -36,10 +37,21 @@ public ResolveCachedDataService(ResolveDataCache resolveDataCache)
_resolveDataCache = resolveDataCache ?? throw new ArgumentNullException(nameof(resolveDataCache));
}

[Obsolete("Use overload that takes a DocumentUri instead of Uri. This method will be removed in a future version. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public object ToResolveData(object data, Uri uri)
=> ResolveDataConversions.ToCachedResolveData(data, uri, _resolveDataCache);
=> ResolveDataConversions.ToCachedResolveData(data, new(uri), _resolveDataCache);

[Obsolete("Use FromResolveDataDocumentUri instead. This method will be removed in a future version. Tracking: https://github.com/dotnet/roslyn/issues/84785")]
public (object? data, Uri? uri) FromResolveData(object? lspData)
=> ResolveDataConversions.FromCachedResolveData(lspData, _resolveDataCache);
{
var (data, documentUri) = ResolveDataConversions.FromCachedResolveData(lspData, _resolveDataCache);
return (data, documentUri?.ParsedUri);
}

public object ToResolveData(object data, DocumentUri uri)
=> ResolveDataConversions.ToCachedResolveData(data, uri, _resolveDataCache);

public (object? data, DocumentUri? uri) FromResolveDataDocumentUri(object? resolveData)
=> ResolveDataConversions.FromCachedResolveData(resolveData, _resolveDataCache);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private void OnProjectInitializationComplete()

private string GetRelativePath(DocumentUri documentUri)
{
var localPath = Path.GetFullPath(documentUri.GetRequiredParsedUri().LocalPath);
var localPath = Path.GetFullPath(documentUri.GetRequiredParsedUri().FsPath);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you consider using the old names? perhaps through extensions? making the diff simpler, then potentially having followup prs that remove the extensions? those prs would then be trivlally mechnical.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - I'll try adding an extension and see how much it simplifies the diff (will get to that tmrw)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looked into this - it would remove ~6 locations from the diff, so I am not sure it's really necessary. Would be able to remove more if we also did ParsedDocumentUri, but can't do that as mentioned below. Doesn't seem to be a huge amount better, so unless you feel strongly plan on leaving it as-is.

var relativePath = PathUtilities.GetRelativePath(_workspaceRootPath, localPath);

Assert.False(PathUtilities.IsAbsolute(relativePath), $"Document URI is not under the workspace root: {documentUri}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Task HandleProgress(JsonElement progressParams, CancellationToken _)
{
foreach (var (title, source) in _unitSourcesByTitle)
{
if (title == begin.Title)
if (MatchingTitle(title, begin.Title))
source.TrySetResult(unit);
}
}
Expand All @@ -154,7 +154,7 @@ public Task<WorkDoneProgressUnit> WaitForWorkDoneProgressCreation(string title)
{
lock (_gate)
{
if (_unitsByToken.Values.FirstOrDefault(unit => unit.Title == title) is { } unit)
if (_unitsByToken.Values.FirstOrDefault(unit => MatchingTitle(title, unit.Title)) is { } unit)
return Task.FromResult(unit);

var unitSource = new TaskCompletionSource<WorkDoneProgressUnit>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand All @@ -163,6 +163,10 @@ public Task<WorkDoneProgressUnit> WaitForWorkDoneProgressCreation(string title)
}
}

// Progress titles can contain URIs whose canonical form changes casing, so compare them case-insensitively.
private static bool MatchingTitle(string expectedTitle, string? actualTitle)
=> expectedTitle.Equals(actualTitle, StringComparison.OrdinalIgnoreCase);
Comment thread
dibarbet marked this conversation as resolved.
Resolved

private static string GetToken(SumType<int, string> token)
=> token.Value?.ToString() ?? throw new InvalidOperationException("Work-done progress token must not be null.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ private static async Task AssertAutoLoadCompletedAsync(TestLspClient testLspServ
Assert.NotNull(unit.CreateParams.Token.Value);

var end = await unit.WaitForEndAsync().WaitAsync(TestHelpers.HangMitigatingTimeout);
Assert.Equal(expectedEndMessage, end.Message);
// Progress messages can contain URIs whose canonical form changes casing, so compare them case-insensitively.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit suspicious...

Assert.Equal(expectedEndMessage, end.Message, ignoreCase: true);
Comment thread
dibarbet marked this conversation as resolved.
Resolved
}

private static async Task AssertProjectsLoadedAsync(TestLspClient testLspServer, int projectCount, bool assertInitialProgressReport = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void ChangedFileReplacesPreviousVersion()
var otherReference = GetReference(cache, otherPath);
Assert.Same(firstReference, GetReference(cache, path));

File.Copy(typeof(Uri).Assembly.Location, path, overwrite: true);
File.Copy(typeof(Console).Assembly.Location, path, overwrite: true);
File.SetLastWriteTimeUtc(path, timestamp.AddSeconds(1));

Assert.NotSame(firstReference, GetReference(cache, path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ await testLspServer.DeleteTextAsync(appCsUri,
var fileChangeTcs = new TaskCompletionSource();
fileChangeContext.FileChanged += (_, path) =>
{
if (path == appCsFile.Path)
if (path.Equals(appCsFile.Path, StringComparison.OrdinalIgnoreCase))
fileChangeTcs.TrySetResult();
};
Comment thread
dibarbet marked this conversation as resolved.
Resolved

Expand Down Expand Up @@ -1186,7 +1186,7 @@ internal class Util { }
// the project for the primary file still loaded and the secondary file moved to that project.
(workspace, document) = await GetRequiredLspWorkspaceAndDocumentAsync(utilCsUri, testLspServer).ConfigureAwait(false);
Assert.Equal(WorkspaceKind.Host, workspace.Kind);
Assert.Contains(document.Project.Documents, document => document.FilePath == appCsFile.Path);
Assert.Contains(document.Project.Documents, document => appCsFile.Path.Equals(document.FilePath, StringComparison.OrdinalIgnoreCase));
}

[Theory, CombinatorialData, WorkItem("https://github.com/dotnet/roslyn/issues/81410")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private Assembly LoadAssemblyFromCodeBase(AssemblyName assemblyName, string code
// This can cause issues during URI parsing, but we will handle that below. First we try to parse the code base as a normal URI, which handles all the cases where we get
// a non-URI string as well as the majority of the cases where we get a file URI string.
var codeBaseUri = ProtocolConversions.CreateAbsoluteUri(codeBaseUriStr);
#pragma warning disable RS0030 // Do not use banned APIs - System.Uri is required here by corlib APIs.
if (!codeBaseUri.IsFile)
{
throw new ArgumentException($"Code base {codeBaseUriStr} for {assemblyName} is not a file URI.", nameof(codeBaseUriStr));
Expand All @@ -109,6 +110,8 @@ private Assembly LoadAssemblyFromCodeBase(AssemblyName assemblyName, string code
// We can attempt to reconstruct the real code base file path by combining all the URI parts following the authority (the path, query, and fragment).
// Note - System.URI returns the escaped versions of all these parts, so we unescape them first.
var possibleCodeBasePath = Uri.UnescapeDataString(codeBaseUri.PathAndQuery) + Uri.UnescapeDataString(codeBaseUri.Fragment);
#pragma warning restore RS0030 // Do not use banned APIs

if (TryLoadAssemblyFromCodeBasePath(assemblyName, possibleCodeBasePath, out assembly))
{
return assembly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async Task StartAndReportProgressAsync(Func<IWorkDoneProgressReporter, Task> loa

internal static bool TryGetFolderPath(WorkspaceFolder folder, ILogger logger, [NotNullWhen(returnValue: true)] out string? folderPath)
{
if (folder.DocumentUri.ParsedUri is null || folder.DocumentUri.ParsedUri.Scheme != Uri.UriSchemeFile)
if (folder.DocumentUri.ParsedDocumentUri?.IsFile != true)
{
logger.LogWarning("Workspace folder {FolderUri} is not a file URI, skipping.", folder.DocumentUri);
folderPath = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void WatchedFilesHandler_OnNotificationRaised(object? sender, DidChangeW
{
foreach (var changedFile in e.Changes)
{
var filePath = changedFile.Uri.GetRequiredParsedUri().LocalPath;
var filePath = changedFile.Uri.GetRequiredParsedUri().FsPath;

// Unfortunately the LSP protocol doesn't give us any hint of which of the file watches we might have sent to the client
// was the one that registered for this change, so we have to check paths to see if this one we should respond to.
Expand Down
Loading