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
Original file line number Diff line number Diff line change
Expand Up @@ -5537,7 +5537,7 @@ private Conversion GenerateConversionForConditionalOperator(BoundExpression sour
private static Conversion GenerateConversion(Conversions conversions, BoundExpression sourceExpression, TypeSymbol sourceType, TypeSymbol destinationType, bool fromExplicitCast, bool extensionMethodThisArgument)
{
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
bool useExpression = UseExpressionForConversion(sourceExpression);
bool useExpression = sourceType is null || UseExpressionForConversion(sourceExpression);
if (extensionMethodThisArgument)
{
return conversions.ClassifyImplicitExtensionMethodThisArgConversion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128501,5 +128501,36 @@ internal interface IB : IA { }
var comp = CreateCompilation(source);
comp.VerifyEmitDiagnostics();
}

[Fact]
[WorkItem(45862, "https://github.com/dotnet/roslyn/issues/45862")]
public void Issue_45862()
{
var source =
@"#nullable enable

class C
{
void M()
{
_ = 0 switch
{
0 =
_ = null,
};
}
}";
var comp = CreateCompilation(source);
comp.VerifyEmitDiagnostics(
// (9,15): error CS1003: Syntax error, '=>' expected
// 0 =
Diagnostic(ErrorCode.ERR_SyntaxError, "=").WithArguments("=>", "=").WithLocation(9, 15),
// (9,15): error CS1525: Invalid expression term '='
// 0 =
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "=").WithArguments("=").WithLocation(9, 15),
// (10,13): error CS8183: Cannot infer the type of implicitly-typed discard.
// _ = null,
Diagnostic(ErrorCode.ERR_DiscardTypeInferenceFailed, "_").WithLocation(10, 13));
}
}
}
14 changes: 14 additions & 0 deletions src/VisualStudio/Core/Def/ColorSchemes/VisualStudio2019.pkgdef

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void InitializeCore()
return;
}

var vsShell = _serviceProvider.GetService<IVsShell, SVsShell>();
var vsShell = _serviceProvider.GetService<SVsShell, IVsShell>();
var hr = vsShell.IsPackageInstalled(ReSharperPackageGuid, out var extensionEnabled);
if (ErrorHandler.Failed(hr))
{
Expand All @@ -127,7 +127,7 @@ private void InitializeCore()
if (_resharperExtensionInstalledAndEnabled)
{
// We need to monitor for suspend/resume commands, so create and install the command target and the modal callback.
var priorityCommandTargetRegistrar = _serviceProvider.GetService<IVsRegisterPriorityCommandTarget, SVsRegisterPriorityCommandTarget>();
var priorityCommandTargetRegistrar = _serviceProvider.GetService<SVsRegisterPriorityCommandTarget, IVsRegisterPriorityCommandTarget>();
hr = priorityCommandTargetRegistrar.RegisterPriorityCommandTarget(
dwReserved: 0 /* from docs must be 0 */,
pCmdTrgt: this,
Expand Down Expand Up @@ -335,7 +335,7 @@ async Task EnsureOleCommandTargetAsync()

await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

_oleCommandTarget = _serviceProvider.GetService<IOleCommandTarget, SUIHostCommandDispatcher>();
_oleCommandTarget = _serviceProvider.GetService<SUIHostCommandDispatcher, IOleCommandTarget>();
}
}

Expand All @@ -345,7 +345,7 @@ private void RestoreVsKeybindings()

if (_uiShell == null)
{
_uiShell = _serviceProvider.GetService<IVsUIShell, SVsUIShell>();
_uiShell = _serviceProvider.GetService<SVsUIShell, IVsUIShell>();
}

ErrorHandler.ThrowOnFailure(_uiShell.PostExecCommand(
Expand Down Expand Up @@ -432,7 +432,7 @@ private async Task ShutdownAsync()

if (_priorityCommandTargetCookie != VSConstants.VSCOOKIE_NIL)
{
var priorityCommandTargetRegistrar = _serviceProvider.GetService<IVsRegisterPriorityCommandTarget, SVsRegisterPriorityCommandTarget>();
var priorityCommandTargetRegistrar = _serviceProvider.GetService<SVsRegisterPriorityCommandTarget, IVsRegisterPriorityCommandTarget>();
var cookie = _priorityCommandTargetCookie;
_priorityCommandTargetCookie = VSConstants.VSCOOKIE_NIL;
var hr = priorityCommandTargetRegistrar.UnregisterPriorityCommandTarget(cookie);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions;
using Microsoft.VisualStudio.LanguageServices.Utilities;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ private bool TryGetFrame(CodeAnalysis.TextDocument document, [NotNullWhen(return
// document using its ItemId. Thus, we must use OpenDocumentViaProject, which only
// depends on the file path.

var openDocumentService = ServiceProvider.GlobalProvider.GetService<IVsUIShellOpenDocument, SVsUIShellOpenDocument>();
var openDocumentService = ServiceProvider.GlobalProvider.GetService<SVsUIShellOpenDocument, IVsUIShellOpenDocument>();
return ErrorHandler.Succeeded(openDocumentService.OpenDocumentViaProject(
document.FilePath,
VSConstants.LOGVIEWID.TextView_guid,
Expand Down Expand Up @@ -1072,7 +1072,7 @@ public void CloseDocumentCore(DocumentId documentId)
var filePath = this.GetFilePath(documentId);
if (filePath != null)
{
var openDocumentService = ServiceProvider.GlobalProvider.GetService<IVsUIShellOpenDocument, SVsUIShellOpenDocument>();
var openDocumentService = ServiceProvider.GlobalProvider.GetService<SVsUIShellOpenDocument, IVsUIShellOpenDocument>();
if (ErrorHandler.Succeeded(openDocumentService.IsDocumentOpen(null, 0, filePath, Guid.Empty, 0, out var uiHierarchy, null, out var frame, out var isOpen)))
{
// TODO: do we need save argument for CloseDocument?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions;
using Microsoft.VisualStudio.LanguageServices.Implementation.Library;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.LanguageServices.Utilities;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Class="Microsoft.VisualStudio.LanguageServices.Setup.RoslynPackage"
AllowsBackgroundLoad="true"/>
<None Include="PackageRegistration.pkgdef" PkgDefEntry="FileContent" />
<None Include=".\ColorSchemes\VisualStudio2019.pkgdef" PkgDefEntry="FileContent" />
</ItemGroup>
<ItemGroup Label="Build Items">
<Compile Include="..\..\..\Compilers\Shared\GlobalAssemblyCacheHelpers\GlobalAssemblyCacheLocation.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;

namespace Microsoft.VisualStudio.LanguageServices.Utilities
{
internal static class IServiceProviderExtensions
{
/// <summary>
/// Returns the specified interface from the service. This is useful when the service and interface differ
/// </summary>
public static TInterfaceType GetService<TInterfaceType, TServiceType>(this IServiceProvider sp)
where TInterfaceType : class
where TServiceType : class
/// <inheritdoc cref="Shell.ServiceExtensions.GetService{TService, TInterface}(IServiceProvider, bool)"/>
public static TInterface GetService<TService, TInterface>(this IServiceProvider sp)
{
return (TInterfaceType)sp.GetService(typeof(TServiceType));
var service = (TInterface)sp.GetService(typeof(TService));
Debug.Assert(service != null);
return service;
}

/// <summary>
Expand Down