protected override bool IsAnalyzerEnabled(AnalyzerOptions options, Compilation compilation)
        {
            var isSingleFileAnalyzerEnabled = options.GetMSBuildPropertyValue(MSBuildPropertyOptionNames.EnableSingleFileAnalyzer, compilation);

            if (!string.Equals(isSingleFileAnalyzerEnabled?.Trim(), "true", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            var includesAllContent = options.GetMSBuildPropertyValue(MSBuildPropertyOptionNames.IncludeAllContentForSelfExtract, compilation);

            if (string.Equals(includesAllContent?.Trim(), "true", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            return(true);
        }
        protected override bool IsAnalyzerEnabled(AnalyzerOptions options, Compilation compilation)
        {
            var isTrimAnalyzerEnabled = options.GetMSBuildPropertyValue(MSBuildPropertyOptionNames.EnableTrimAnalyzer, compilation);

            if (!string.Equals(isTrimAnalyzerEnabled?.Trim(), "true", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            return(true);
        }
Example #3
0
        /// <summary>
        /// Gets a value indicating whether the project of the compilation is a Web SDK project based on project properties.
        /// </summary>
        internal static bool IsWebProject(this Compilation compilation, AnalyzerOptions options)
        {
            var propertyValue = options.GetMSBuildPropertyValue(MSBuildPropertyOptionNames.UsingMicrosoftNETSdkWeb, compilation);

            if (string.Equals(propertyValue?.Trim(), "true", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            propertyValue = options.GetMSBuildPropertyValue(MSBuildPropertyOptionNames.ProjectTypeGuids, compilation);
            if (!RoslynString.IsNullOrEmpty(propertyValue) &&
                (propertyValue.Contains(WebAppProjectGuidString, StringComparison.OrdinalIgnoreCase) ||
                 propertyValue.Contains(WebSiteProjectGuidString, StringComparison.OrdinalIgnoreCase)))
            {
                var guids = propertyValue.Split(';').Select(g => g.Trim()).ToImmutableArray();
                return(guids.Contains(WebAppProjectGuidString, StringComparer.OrdinalIgnoreCase) ||
                       guids.Contains(WebSiteProjectGuidString, StringComparer.OrdinalIgnoreCase));
            }

            return(false);
        }