public override bool HasCapability(object project, string capability)
        {
            if (project is not DotNetProject dotnetProject)
            {
                return(false);
            }

            try
            {
                var hasCapability = dotnetProject.IsCapabilityMatch(capability);
                return(hasCapability);
            }
            catch (NotSupportedException)
            {
                // IsCapabilityMatch throws a NotSupportedException if it can't create a
                // BooleanSymbolExpressionEvaluator COM object
                _razorLogger.LogWarning("Could not resolve project capability for hierarchy due to NotSupportedException.");
                return(false);
            }
            catch (ObjectDisposedException)
            {
                // IsCapabilityMatch throws an ObjectDisposedException if the underlying hierarchy has been disposed
                _razorLogger.LogWarning("Could not resolve project capability for hierarchy due to hierarchy being disposed.");
                return(false);
            }
        }
예제 #2
0
        private bool LocalHasCapability(IVsHierarchy hierarchy, string capability)
        {
            if (hierarchy is null)
            {
                return(false);
            }

            try
            {
                var hasCapability = hierarchy.IsCapabilityMatch(capability);
                return(hasCapability);
            }
            catch (NotSupportedException)
            {
                // IsCapabilityMatch throws a NotSupportedException if it can't create a
                // BooleanSymbolExpressionEvaluator COM object
                _razorLogger.LogWarning("Could not resolve project capability for hierarchy due to NotSupportedException.");
                return(false);
            }
            catch (ObjectDisposedException)
            {
                // IsCapabilityMatch throws an ObjectDisposedException if the underlying hierarchy has been disposed
                _razorLogger.LogWarning("Could not resolve project capability for hierarchy due to hierarchy being disposed.");
                return(false);
            }
        }