// Private protected virtual for testing
        private protected virtual bool ProjectSupportsLSPEditor(string documentFilePath, DotNetProject?project)
        {
            if (project is null)
            {
                project = _textBufferProjectService.GetHostProject(documentFilePath) as DotNetProject;

                if (project is null)
                {
                    return(false);
                }
            }

            // We alow projects to specifically opt-out of the legacy Razor editor because there are legacy scenarios which would rely on behind-the-scenes
            // opt-out mechanics to enable the .NET Core editor in non-.NET Core scenarios. Therefore, we need a similar mechanic to continue supporting
            // those types of scenarios for the new .NET Core Razor editor.
            if (_projectCapabilityResolver.HasCapability(documentFilePath, project, LegacyRazorEditorProjectCapability))
            {
                // CPS project that requires the legacy editor
                return(false);
            }

            if (_projectCapabilityResolver.HasCapability(documentFilePath, project, DotNetCoreCSharpProjectCapability))
            {
                // .NET Core project that supports C#
                return(true);
            }

            // Not a C# .NET Core project. This typically happens for legacy Razor scenarios
            return(false);
        }
        // Private protected virtual for testing
        private protected virtual bool ProjectSupportsLSPEditor(string documentMoniker, IVsHierarchy?hierarchy)
        {
            if (hierarchy is null)
            {
                var hr = _vsUIShellOpenDocument.Value.IsDocumentInAProject(documentMoniker, out var uiHierarchy, out _, out _, out _);
                hierarchy = uiHierarchy;
                if (!ErrorHandler.Succeeded(hr) || hierarchy is null)
                {
                    return(false);
                }
            }

            // We alow projects to specifically opt-out of the legacy Razor editor because there are legacy scenarios which would rely on behind-the-scenes
            // opt-out mechanics to enable the .NET Core editor in non-.NET Core scenarios. Therefore, we need a similar mechanic to continue supporting
            // those types of scenarios for the new .NET Core Razor editor.
            if (_projectCapabilityResolver.HasCapability(documentMoniker, hierarchy, LegacyRazorEditorCapability))
            {
                // CPS project that requires the legacy editor
                return(false);
            }

            if (_projectCapabilityResolver.HasCapability(documentMoniker, hierarchy, DotNetCoreCSharpCapability))
            {
                // .NET Core project that supports C#
                return(true);
            }

            // Not a C# .NET Core project. This typically happens for legacy Razor scenarios
            return(false);
        }
예제 #3
0
        public override bool IsSupportedProject(object project)
        {
            if (project is null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            var capabilitySupported = _projectCapabilityResolver.HasCapability(project, DotNetCoreCapability);

            return(capabilitySupported);
        }
        public override bool IsSupportedProject(object project)
        {
            var capabilitySupported = _projectCapabilityResolver.HasCapability(project, DotNetCoreRazorCapability);

            return(capabilitySupported);
        }