Skip to content

Precursor work to merge EditorFeatures.WPF into EditorFeatures. #78308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.Editor.CSharp</RootNamespace>
<TargetFrameworks>$(NetVS);netstandard2.0</TargetFrameworks>
<TargetFramework>net472</TargetFramework>
<UseWpf>true</UseWpf>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>
<!--Temporarily bypass ibcmerge due to an error
https://github.com/dotnet/roslyn/issues/57863 -->
<ApplyNgenOptimization></ApplyNgenOptimization>
<!-- NuGet -->
<IsPackable>true</IsPackable>
<PackageDescription>
Expand Down
15 changes: 15 additions & 0 deletions src/EditorFeatures/Core.Wpf/Peek/IPeekableItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@

#nullable disable

using System;
using System.Collections.Generic;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Implementation.Peek;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.MetadataAsSource;
using Microsoft.CodeAnalysis.Options;
using Microsoft.VisualStudio.Language.Intellisense;

namespace Microsoft.CodeAnalysis.Editor.Peek;
Expand All @@ -15,3 +22,11 @@ public interface IPeekableItemFactory
{
Task<IEnumerable<IPeekableItem>> GetPeekableItemsAsync(ISymbol symbol, Project project, IPeekResultFactory peekResultFactory, CancellationToken cancellationToken);
}

[Export(typeof(IPeekableItemFactory)), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class EditorPeekableItemFactory(
IMetadataAsSourceFileService metadataAsSourceFileService,
IGlobalOptionService globalOptions,
IThreadingContext threadingContext) : PeekableItemFactory(metadataAsSourceFileService, globalOptions, threadingContext);
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private async ValueTask BreakStateOrCapabilitiesChangedAsync(bool? inBreakState,
// We start the operation but do not wait for it to complete.
// The tracking session is cancelled when we exit the break state.

Debug.Assert(solution != null);
Contract.ThrowIfNull(solution);
GetActiveStatementTrackingService().StartTracking(solution, session);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public int Compare(VSCompletionItem? x, VSCompletionItem? y)
var yRoslyn = y is not null ? CompletionItemData.GetOrAddDummyRoslynItem(y) : null;

// Sort by default comparer of Roslyn CompletionItem
return Comparer<RoslynCompletionItem>.Default.Compare(xRoslyn, yRoslyn);
return Comparer<RoslynCompletionItem?>.Default.Compare(xRoslyn, yRoslyn);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis</RootNamespace>
<TargetFrameworks>$(NetVS);netstandard2.0</TargetFrameworks>
<TargetFramework>net472</TargetFramework>
<UseWpf>true</UseWpf>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!--Temporarily bypass ibcmerge due to an error
https://github.com/dotnet/roslyn/issues/57863 -->
<ApplyNgenOptimization></ApplyNgenOptimization>
<DefineConstants>$(DefineConstants);EDITOR_FEATURES</DefineConstants>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>

<!-- NuGet -->
<PackageId>Microsoft.CodeAnalysis.EditorFeatures.Common</PackageId>
Expand All @@ -19,19 +22,23 @@
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" />
<ProjectReference Include="..\..\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" />
<ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" Aliases="InteractiveHost" />
<ProjectReference Include="..\..\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" />
<ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" Aliases="Scripting,global" />
<ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" />
<ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" />
<ProjectReference Include="..\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Language.StandardClassification" />
<PackageReference Include="Microsoft.VisualStudio.Debugger.Contracts" />
<PackageReference Include="Microsoft.VisualStudio.ImageCatalog" />
<PackageReference Include="Microsoft.VisualStudio.InteractiveWindow" />
<PackageReference Include="Microsoft.VisualStudio.Language" />
<PackageReference Include="Microsoft.VisualStudio.Language.NavigateTo.Interfaces" />
<PackageReference Include="Microsoft.VisualStudio.Language.StandardClassification" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.Debugger.Contracts" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client.Implementation" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.Text.UI.Wpf" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\BrokeredServices\ServiceBrokerProvider.cs" Link="BrokeredServices\ServiceBrokerProvider.cs" />
Expand All @@ -41,7 +48,6 @@
<ItemGroup>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" LoadsWithinVisualStudio="false" />
<InternalsVisibleTo Include="IdeBenchmarks" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CodeLens" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
Expand All @@ -67,8 +73,10 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" />
<InternalsVisibleTo Include="Microsoft.Test.Apex.VisualStudio" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CodeLens" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.ExternalAccess.Copilot" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.ExternalDependencyServices" WorkItem="https://github.com/dotnet/roslyn/issues/35085" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare" />
Expand All @@ -78,13 +86,14 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.VisualBasic" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Xaml" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.ExternalAccess.Copilot" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.TestWindow.CodeLens" Key="$(UnitTestingKey)" />
<InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" />
<InternalsVisibleTo Include="Roslyn.Services.Editor.TypeScript.UnitTests" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.DiagnosticsWindow" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Setup" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.TestWindow.CodeLens" Key="$(UnitTestingKey)" />

<!-- Eventually a bunch of these unit tests should move into Roslyn.Services.Implementation.UnitTests
and this should be removed. -->
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" />
Expand All @@ -98,6 +107,10 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="EditorFeaturesResources.resx" GenerateSource="true" />
<EmbeddedResource Update="EditorFeaturesWpfResources.resx">
<GenerateSource>true</GenerateSource>
<Generator>MSBuild:_GenerateResxSource</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PublicAPI Include="PublicAPI.Shipped.txt" />
Expand All @@ -106,4 +119,4 @@
<ItemGroup>
<Folder Include="BrokeredServices\" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Peek;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;
Expand All @@ -24,8 +23,8 @@

namespace Microsoft.CodeAnalysis.Editor.Implementation.Peek;

[Export(typeof(IPeekableItemFactory))]
internal sealed class PeekableItemFactory : IPeekableItemFactory
[Export(typeof(PeekableItemFactory))]
internal class PeekableItemFactory
{
private readonly IMetadataAsSourceFileService _metadataAsSourceFileService;
private readonly IGlobalOptionService _globalOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Peek;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.Navigation;
Expand All @@ -24,14 +23,14 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Peek;
internal sealed class PeekableItemSource : IPeekableItemSource
{
private readonly ITextBuffer _textBuffer;
private readonly IPeekableItemFactory _peekableItemFactory;
private readonly PeekableItemFactory _peekableItemFactory;
private readonly IPeekResultFactory _peekResultFactory;
private readonly IThreadingContext _threadingContext;
private readonly IUIThreadOperationExecutor _uiThreadOperationExecutor;

public PeekableItemSource(
ITextBuffer textBuffer,
IPeekableItemFactory peekableItemFactory,
PeekableItemFactory peekableItemFactory,
IPeekResultFactory peekResultFactory,
IThreadingContext threadingContext,
IUIThreadOperationExecutor uiThreadOperationExecutor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Editor.Peek;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.Language.Intellisense;
Expand All @@ -20,15 +19,15 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Peek;
[SupportsPeekRelationship("IsDefinedBy")]
internal sealed class PeekableItemSourceProvider : IPeekableItemSourceProvider
{
private readonly IPeekableItemFactory _peekableItemFactory;
private readonly PeekableItemFactory? _peekableItemFactory;
private readonly IPeekResultFactory _peekResultFactory;
private readonly IThreadingContext _threadingContext;
private readonly IUIThreadOperationExecutor _uiThreadOperationExecutor;

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public PeekableItemSourceProvider(
IPeekableItemFactory peekableItemFactory,
[Import(AllowDefault = true)] PeekableItemFactory? peekableItemFactory,
IPeekResultFactory peekResultFactory,
IThreadingContext threadingContext,
IUIThreadOperationExecutor uiThreadOperationExecutor)
Expand All @@ -39,7 +38,7 @@ public PeekableItemSourceProvider(
_uiThreadOperationExecutor = uiThreadOperationExecutor;
}

public IPeekableItemSource TryCreatePeekableItemSource(ITextBuffer textBuffer)
=> textBuffer.Properties.GetOrCreateSingletonProperty(() =>
public IPeekableItemSource? TryCreatePeekableItemSource(ITextBuffer textBuffer)
=> _peekableItemFactory is null ? null : textBuffer.Properties.GetOrCreateSingletonProperty(() =>
new PeekableItemSource(textBuffer, _peekableItemFactory, _peekResultFactory, _threadingContext, _uiThreadOperationExecutor));
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ private sealed class ViewSpanChangedEventSource : AbstractTaggerEventSource

public ViewSpanChangedEventSource(IThreadingContext threadingContext, ITextView textView)
{
Debug.Assert(textView != null);
_threadingContext = threadingContext;
_textView = textView;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.ExternalAccess.Debugger</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net472</TargetFramework>
<UseWPF>true</UseWPF>
Copy link
Member

Choose a reason for hiding this comment

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

I don't imagine this change was necessary? This reminds me of the other CodeLens change you weren't sure about.

Copy link
Member Author

Choose a reason for hiding this comment

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

No. this debugger lib def talks to EditorFEatures. it is @tmat 's EA layer so that he can populate the FAR window with symbolic results. He'd have to say why this is needed. BUt it will def have to change like this.


<!-- NuGet -->
<IsPackable>true</IsPackable>
Expand Down Expand Up @@ -38,4 +39,4 @@
<PublicAPI Include="InternalAPI.Unshipped.txt" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>$(NetVS);netstandard2.0</TargetFrameworks>
<RootNamespace></RootNamespace>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>
<UseWpf>true</UseWpf>
<TargetFramework>net472</TargetFramework>
<!--Temporarily bypass ibcmerge due to an error
https://github.com/dotnet/roslyn/issues/57863 -->
<ApplyNgenOptimization></ApplyNgenOptimization>
<!-- NuGet -->
<IsPackable>true</IsPackable>
<PackageDescription>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<RootNamespace>Microsoft.CodeAnalysis.ExternalAccess.Razor</RootNamespace>
<TargetFrameworks>$(NetVS);netstandard2.0</TargetFrameworks>
<TargetFrameworks>net472</TargetFrameworks>
<UseWPF>true</UseWPF>

<!-- NuGet -->
<IsPackable>true</IsPackable>
Expand Down Expand Up @@ -60,4 +61,4 @@
<PublicAPI Include="InternalAPI.Unshipped.txt" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Collections.Generic;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Implementation.Peek;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.MetadataAsSource;
using Microsoft.CodeAnalysis.Options;
using Microsoft.VisualStudio.Language.Intellisense;

namespace Microsoft.VisualStudio.LanguageServices.Xaml.Features.Peek;

internal interface IXamlPeekableItemFactory
Copy link
Member Author

Choose a reason for hiding this comment

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

new EA layer code for xaml to use.

{
Task<IEnumerable<IPeekableItem>> GetPeekableItemsAsync(ISymbol symbol, Project project, IPeekResultFactory peekResultFactory, CancellationToken cancellationToken);
}

[Export(typeof(IXamlPeekableItemFactory)), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class XamlPeekableItemFactory(
IMetadataAsSourceFileService metadataAsSourceFileService,
IGlobalOptionService globalOptions,
IThreadingContext threadingContext) : PeekableItemFactory(metadataAsSourceFileService, globalOptions, threadingContext);
Loading