Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 24 additions & 0 deletions Roslyn.sln
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CommonLanguageSer
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests", "src\Compilers\CSharp\Test\Emit3\Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests.csproj", "{4E273CBC-BB1D-4AC1-91DB-C62FC83E0350}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SemanticSearch", "SemanticSearch", "{52ABB0E4-C3A1-4897-B51B-18EDA83F5D20}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticSearch.BuildTask", "src\Tools\SemanticSearch\BuildTask\SemanticSearch.BuildTask.csproj", "{FCE88BBD-9BBD-4871-B9B0-DE176D73A6B0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticSearch.ReferenceAssemblies", "src\Tools\SemanticSearch\ReferenceAssemblies\SemanticSearch.ReferenceAssemblies.csproj", "{EDEF898A-CEFA-4151-8168-D0231A602093}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticSearch.BuildTask.UnitTests", "src\Tools\SemanticSearch\Tests\SemanticSearch.BuildTask.UnitTests.csproj", "{D817E3CE-F603-499B-B02A-7DECD017B170}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1375,6 +1383,18 @@ Global
{4E273CBC-BB1D-4AC1-91DB-C62FC83E0350}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E273CBC-BB1D-4AC1-91DB-C62FC83E0350}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E273CBC-BB1D-4AC1-91DB-C62FC83E0350}.Release|Any CPU.Build.0 = Release|Any CPU
{FCE88BBD-9BBD-4871-B9B0-DE176D73A6B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCE88BBD-9BBD-4871-B9B0-DE176D73A6B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCE88BBD-9BBD-4871-B9B0-DE176D73A6B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCE88BBD-9BBD-4871-B9B0-DE176D73A6B0}.Release|Any CPU.Build.0 = Release|Any CPU
{EDEF898A-CEFA-4151-8168-D0231A602093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDEF898A-CEFA-4151-8168-D0231A602093}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDEF898A-CEFA-4151-8168-D0231A602093}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDEF898A-CEFA-4151-8168-D0231A602093}.Release|Any CPU.Build.0 = Release|Any CPU
{D817E3CE-F603-499B-B02A-7DECD017B170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D817E3CE-F603-499B-B02A-7DECD017B170}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D817E3CE-F603-499B-B02A-7DECD017B170}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D817E3CE-F603-499B-B02A-7DECD017B170}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1630,6 +1650,10 @@ Global
{64EADED3-4B5D-4431-BBE5-A4ABA1C38C00} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
{730CADBA-701F-4722-9B6F-1FCC0DF2C95D} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
{4E273CBC-BB1D-4AC1-91DB-C62FC83E0350} = {32A48625-F0AD-419D-828B-A50BDABA38EA}
{52ABB0E4-C3A1-4897-B51B-18EDA83F5D20} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{FCE88BBD-9BBD-4871-B9B0-DE176D73A6B0} = {52ABB0E4-C3A1-4897-B51B-18EDA83F5D20}
{EDEF898A-CEFA-4151-8168-D0231A602093} = {52ABB0E4-C3A1-4897-B51B-18EDA83F5D20}
{D817E3CE-F603-499B-B02A-7DECD017B170} = {52ABB0E4-C3A1-4897-B51B-18EDA83F5D20}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29}
Expand Down
1 change: 1 addition & 0 deletions eng/targets/Services.props
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.StackTraceExplorer" ClassName="Microsoft.CodeAnalysis.Remote.RemoteStackTraceExplorerService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.UnitTestingSearch" ClassName="Microsoft.CodeAnalysis.Remote.RemoteUnitTestingSearchService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.SourceGeneration" ClassName="Microsoft.CodeAnalysis.Remote.RemoteSourceGenerationService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.SemanticSearch" ClassName="Microsoft.CodeAnalysis.Remote.RemoteSemanticSearchService+Factory" />
</ItemGroup>

<!--
Expand Down
4 changes: 4 additions & 0 deletions eng/test-rebuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ try {
" --exclude net472\Zip\tools\vsixexpinstaller\System.ValueTuple.dll" +
" --exclude net472\Zip\tools\vsixexpinstaller\VSIXExpInstaller.exe" +

# Semantic Search reference assemblies can't be reconstructed from source.
# The assemblies are not marked with ReferenceAssemblyAttribute attribute.
" --exclude net8.0\GeneratedRefAssemblies\Microsoft.CodeAnalysis.dll" +

" --debugPath `"$ArtifactsDir/BuildValidator`"" +
" --sourcePath `"$RepoRoot/`"" +
" --referencesPath `"$ArtifactsDir/bin`"" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<InternalsVisibleTo Include="CompilerBenchmarks" />
<InternalsVisibleTo Include="Microsoft.Build.Tasks.CodeAnalysis.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Features.Test.Utilities" />
<InternalsVisibleTo Include="SemanticSearch.BuildTask.UnitTests" />
</ItemGroup>
<Import Project="..\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems" Label="Shared" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ namespace Microsoft.CodeAnalysis.UnitTests.Collections
{
public class ArrayBuilderTests
{
[Fact]
public void RemoveAll()
{
var builder = new ArrayBuilder<int> { 6, 5, 1, 2, 3, 2, 4, 5, 1, 7 };

builder.RemoveAll((_, _) => false, arg: 0);
AssertEx.Equal([6, 5, 1, 2, 3, 2, 4, 5, 1, 7], builder);

builder.RemoveAll((i, arg) => i == arg, arg: 6);
AssertEx.Equal([5, 1, 2, 3, 2, 4, 5, 1, 7], builder);

builder.RemoveAll((i, arg) => i == arg, arg: 7);
AssertEx.Equal([5, 1, 2, 3, 2, 4, 5, 1], builder);

builder.RemoveAll((i, arg) => i < arg, arg: 3);
AssertEx.Equal([5, 3, 4, 5], builder);

builder.RemoveAll((_, _) => true, arg: 0);
AssertEx.Equal([], builder);

builder.RemoveAll((_, _) => true, arg: 0);
AssertEx.Equal([], builder);
}

[Fact]
public void RemoveDuplicates1()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<InternalsVisibleTo Include="Roslyn.Test.PdbUtilities" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests" />
<InternalsVisibleTo Include="SemanticSearch.BuildTask.UnitTests"/>
</ItemGroup>
<ItemGroup>
<!-- TODO: Remove the below IVTs to CodeStyle Unit test projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing -->
Expand Down
24 changes: 24 additions & 0 deletions src/Dependencies/PooledObjects/ArrayBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,30 @@ public void RemoveLast()
_builder.RemoveAt(_builder.Count - 1);
}

public void RemoveAll(Predicate<T> match)
{
_builder.RemoveAll(match);
}

public void RemoveAll<TArg>(Func<T, TArg, bool> match, TArg arg)
{
var i = 0;
for (var j = 0; j < _builder.Count; j++)
{
if (!match(_builder[j], arg))
{
if (i != j)
{
_builder[i] = _builder[j];
}

i++;
}
}

Clip(i);
}

public void ReverseContents()
{
_builder.Reverse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
namespace Microsoft.CodeAnalysis.Editor;

internal static class TextEditApplication
{
Expand All @@ -31,7 +31,7 @@ public static void UpdateText(ImmutableArray<TextChange> textChanges, ITextBuffe
private static void UpdateText(ImmutableArray<TextChange> textChanges, ITextBuffer buffer, ITextSnapshot oldSnapshot, SourceText oldText, EditOptions options)
{
using var edit = buffer.CreateEdit(options, reiteratedVersionNumber: null, editTag: null);
if (CodeAnalysis.Workspace.TryGetWorkspace(oldText.Container, out var workspace))
if (Workspace.TryGetWorkspace(oldText.Container, out var workspace))
{
var undoService = workspace.Services.GetRequiredService<ISourceTextUndoService>();
undoService.BeginUndoTransaction(oldSnapshot);
Expand Down
3 changes: 3 additions & 0 deletions src/EditorFeatures/Core/EditorFeaturesResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ Do you want to proceed?</value>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="Run" xml:space="preserve">
<value>Run</value>
</data>
<data name="Changes" xml:space="preserve">
<value>Changes</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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.

using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.SemanticSearch;

internal sealed class SemanticSearchEditorWorkspace(
HostServices services,
SemanticSearchProjectConfiguration config,
IThreadingContext threadingContext,
IAsynchronousOperationListenerProvider listenerProvider)
: SemanticSearchWorkspace(services, config)
{
private readonly IAsynchronousOperationListener _asyncListener = listenerProvider.GetListener(FeatureAttribute.SemanticSearch);

private ITextBuffer? _queryTextBuffer;
private DocumentId? _queryDocumentId;

public async Task OpenQueryDocumentAsync(ITextBuffer buffer, CancellationToken cancellationToken)
{
_queryTextBuffer = buffer;

// initialize solution with default query, unless it has already been initialized:
var queryDocument = await UpdateQueryDocumentAsync(query: null, cancellationToken).ConfigureAwait(false);

_queryDocumentId = queryDocument.Id;

OnDocumentOpened(queryDocument.Id, buffer.AsTextContainer());
}

/// <summary>
/// Used by code actions through <see cref="Workspace.TryApplyChanges(Solution)"/>.
/// </summary>
protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText newText)
{
if (documentId == _queryDocumentId)
{
ApplyQueryDocumentTextChanged(newText);
}
}

protected override void ApplyQueryDocumentTextChanged(SourceText newText)
{
Contract.ThrowIfNull(_queryTextBuffer);

// update the buffer on UI thread:

var completionToken = _asyncListener.BeginAsyncOperation(nameof(SemanticSearchEditorWorkspace) + "." + nameof(ApplyQueryDocumentTextChanged));
_ = UpdateTextAsync().ReportNonFatalErrorAsync().CompletesAsyncOperation(completionToken);

async Task UpdateTextAsync()
{
await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(CancellationToken.None);
TextEditApplication.UpdateText(newText, _queryTextBuffer, EditOptions.DefaultMinimalChange);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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.

using System;
using System.Composition;
using Microsoft.CodeAnalysis.Editor.Shared;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.Text;

namespace Microsoft.CodeAnalysis.SemanticSearch;

[ExportWorkspaceService(typeof(ITextBufferSupportsFeatureService), WorkspaceKind.SemanticSearch), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal class SemanticSeatchTextBufferSupportsFeatureService() : ITextBufferSupportsFeatureService
{
public bool SupportsCodeFixes(ITextBuffer textBuffer)
=> true;

public bool SupportsRefactorings(ITextBuffer textBuffer)
=> true;

public bool SupportsRename(ITextBuffer textBuffer)
=> true;

public bool SupportsNavigationToAnyPosition(ITextBuffer textBuffer)
=> true;
}
5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading