private bool IsSuppressedInSuppressionFile(SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellation)
        {
            cancellation.ThrowIfCancellationRequested();

            var(assembly, message) = SuppressMessage.GetSuppressionInfo(semanticModel, diagnostic, cancellation);

            if (assembly == null)
            {
                return(false);
            }

            SuppressionFile file = GetSuppressionFile(assembly);

            if (file == null)
            {
                return(false);
            }

            if (file.GenerateSuppressionBase)
            {
                if (IsSuppressableSeverity(diagnostic?.Descriptor.DefaultSeverity))
                {
                    file.AddMessage(message);
                }

                return(true);
            }

            return(file.ContainsMessage(message));
        }
        public static bool SuppressDiagnostic(SemanticModel semanticModel, string diagnosticID, TextSpan diagnosticSpan,
                                              DiagnosticSeverity defaultDiagnosticSeverity, CancellationToken cancellation = default)
        {
            CheckIfInstanceIsInitialized(throwOnNotInitialized: true);

            if (!IsSuppressableSeverity(defaultDiagnosticSeverity))
            {
                return(false);
            }

            var(fileAssemblyName, suppressMessage) = SuppressMessage.GetSuppressionInfo(semanticModel, diagnosticID,
                                                                                        diagnosticSpan, cancellation);
            if (fileAssemblyName.IsNullOrWhiteSpace() || !suppressMessage.IsValid)
            {
                return(false);
            }

            lock (Instance._fileSystemService)
            {
                if (!Instance._fileByAssembly.TryGetValue(fileAssemblyName, out var file) || file == null)
                {
                    return(false);
                }

                file.AddMessage(suppressMessage);
                XDocument newSuppressionXmlFile = file.MessagesToDocument(Instance._fileSystemService);
                Instance._fileSystemService.Save(newSuppressionXmlFile, file.Path);
            }

            return(true);
        }