当前位置: 首页>>代码示例>>C#>>正文


C# DiagnosticSeverity类代码示例

本文整理汇总了C#中DiagnosticSeverity的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticSeverity类的具体用法?C# DiagnosticSeverity怎么用?C# DiagnosticSeverity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DiagnosticSeverity类属于命名空间,在下文中一共展示了DiagnosticSeverity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDescriptorWithId

 private DiagnosticDescriptor CreateDescriptorWithId(string id, LocalizableString title, LocalizableString message, DiagnosticSeverity severity, params string[] customTags)
     => new DiagnosticDescriptor(
         id, title, message,
         DiagnosticCategory.Style,
         severity,
         isEnabledByDefault: true,
         customTags: customTags);
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:7,代码来源:AbstractCodeStyleDiagnosticAnalyzer.cs

示例2: SimpleDiagnostic

            private SimpleDiagnostic(
                DiagnosticDescriptor descriptor,
                DiagnosticSeverity severity,
                int warningLevel,
                Location location,
                IEnumerable<Location> additionalLocations,
                object[] messageArgs)
            {
                if ((warningLevel == 0 && severity != DiagnosticSeverity.Error) ||
                    (warningLevel != 0 && severity == DiagnosticSeverity.Error))
                {
                    throw new ArgumentException(nameof(warningLevel));
                }

                if(descriptor == null)
                {
                    throw new ArgumentNullException(nameof(descriptor));
                }

                _descriptor = descriptor;
                _severity = severity;
                _warningLevel = warningLevel;
                _location = location ?? Location.None;
                _additionalLocations = additionalLocations == null ? SpecializedCollections.EmptyReadOnlyList<Location>() : additionalLocations.ToImmutableArray();
                _messageArgs = messageArgs ?? SpecializedCollections.EmptyArray<object>();
            }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:Diagnostic_SimpleDiagnostic.cs

示例3: Diagnostic

        public readonly TextSpan TextSpan; //opt

        #endregion Fields

        #region Constructors

        public Diagnostic(DiagnosticSeverity severity, int code, string message, TextSpan textSpan)
        {
            Severity = severity;
            Code = code;
            Message = message;
            TextSpan = textSpan;
        }
开发者ID:knat,项目名称:CSharpParser,代码行数:13,代码来源:Diagnostics.cs

示例4: DiagnosticResult

 /// <summary>
 /// インスタンスを初期化します。
 /// </summary>
 /// <param name="id">解析したルールの識別子</param>
 /// <param name="message">解析結果のメッセージ</param>
 /// <param name="severity">解析したルールの重大度</param>
 /// <param name="locations">解析結果が示すソースコードの位置</param>
 public DiagnosticResult(string id, string message, DiagnosticSeverity? severity, params DiagnosticResultLocation[] locations)
 {
     Id = id;
     Message = message;
     Severity = severity;
     Locations = locations ?? new DiagnosticResultLocation[0];
 }
开发者ID:munyabe,项目名称:MunyabeCSharpAnalysis,代码行数:14,代码来源:DiagnosticResult.cs

示例5: DiagnosticData

 public DiagnosticData(
     string id,
     string category,
     string message,
     string enuMessageForBingSearch,
     DiagnosticSeverity severity,
     bool isEnabledByDefault,
     int warningLevel,
     Workspace workspace,
     ProjectId projectId,
     DocumentId documentId = null,
     TextSpan? span = null,
     string originalFilePath = null,
     int originalStartLine = 0,
     int originalStartColumn = 0,
     int originalEndLine = 0,
     int originalEndColumn = 0,
     string title = null,
     string description = null,
     string helpLink = null) :
         this(
             id, category, message, enuMessageForBingSearch,
             severity, severity, isEnabledByDefault, warningLevel,
             ImmutableArray<string>.Empty, ImmutableDictionary<string, string>.Empty,
             workspace, projectId, documentId, span,
             null, originalStartLine, originalStartColumn, originalEndLine, originalEndColumn,
             originalFilePath, originalStartLine, originalStartColumn, originalEndLine, originalEndColumn,
             title, description, helpLink)
 {
 }
开发者ID:reidwooten99apps,项目名称:roslyn,代码行数:30,代码来源:DiagnosticData.cs

示例6: SimpleDiagnostic

            private SimpleDiagnostic(
                DiagnosticDescriptor descriptor,
                DiagnosticSeverity severity,
                int warningLevel,
                Location location,
                IEnumerable<Location> additionalLocations,
                object[] messageArgs,
                ImmutableDictionary<string, string> properties,
                bool isSuppressed)
            {
                if ((warningLevel == 0 && severity != DiagnosticSeverity.Error) ||
                    (warningLevel != 0 && severity == DiagnosticSeverity.Error))
                {
                    throw new ArgumentException(nameof(warningLevel));
                }

                if (descriptor == null)
                {
                    throw new ArgumentNullException(nameof(descriptor));
                }

                _descriptor = descriptor;
                _severity = severity;
                _warningLevel = warningLevel;
                _location = location ?? Location.None;
                _additionalLocations = additionalLocations?.ToImmutableArray() ?? SpecializedCollections.EmptyReadOnlyList<Location>();
                _messageArgs = messageArgs ?? Array.Empty<object>();
                _properties = properties ?? ImmutableDictionary<string, string>.Empty;
                _isSuppressed = isSuppressed;
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:30,代码来源:Diagnostic_SimpleDiagnostic.cs

示例7: SimpleDiagnostic

            internal SimpleDiagnostic(string id, string category, string message, DiagnosticSeverity severity, bool isEnabledByDefault,
                                      int warningLevel, bool isWarningAsError, Location location,
                                      IEnumerable<Location> additionalLocations)
            {
                if (isWarningAsError && severity != DiagnosticSeverity.Warning)
                {
                    throw new ArgumentException("isWarningAsError");
                }

                if ((warningLevel == 0 && severity == DiagnosticSeverity.Warning) ||
                    (warningLevel != 0 && severity != DiagnosticSeverity.Warning))
                {
                    throw new ArgumentException("warningLevel");
                }

                this.id = id;
                this.category = category;
                this.message = message;
                this.severity = severity;
                this.isEnabledByDefault = isEnabledByDefault;
                this.warningLevel = warningLevel;
                this.isWarningAsError = isWarningAsError;
                this.location = location;
                this.additionalLocations = additionalLocations == null ? SpecializedCollections.EmptyReadOnlyList<Location>() : additionalLocations.ToImmutableArray();
            }
开发者ID:pheede,项目名称:roslyn,代码行数:25,代码来源:Diagnostic_SimpleDiagnostic.cs

示例8: TestParseEditorConfigCodeStyleOption

        static void TestParseEditorConfigCodeStyleOption(string args, bool isEnabled, DiagnosticSeverity severity)
        {
            var notificationOption = NotificationOption.None;
            switch (severity)
            {
                case DiagnosticSeverity.Hidden:
                    notificationOption = NotificationOption.None;
                    break;
                case DiagnosticSeverity.Info:
                    notificationOption = NotificationOption.Suggestion;
                    break;
                case DiagnosticSeverity.Warning:
                    notificationOption = NotificationOption.Warning;
                    break;
                case DiagnosticSeverity.Error:
                    notificationOption = NotificationOption.Error;
                    break;
            }

            var codeStyleOption = new CodeStyleOption<bool>(value: isEnabled, notification: notificationOption);

            var result = CodeStyleHelpers.ParseEditorConfigCodeStyleOption(args);
            Assert.True(result.Value == isEnabled,
                        $"Expected {nameof(isEnabled)} to be {isEnabled}, was {result.Value}");
            Assert.True(result.Notification.Value == severity,
                        $"Expected {nameof(severity)} to be {severity}, was {result.Notification.Value}");
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:27,代码来源:EditorConfigCodeStyleParserTests.cs

示例9: AnalyzerDetails

        public AnalyzerDetails(string className, 
                               AnalyzerCategoryDetails category,
                               DefaultState defaultState,
                               DiagnosticSeverity severity,
                               string titleResourceName,
                               string descriptionResourceName,
                               string messageFormatResourceName,
                               IList<Type> suppressionAttributes)
        {
            var decomposedDetails = DecomposeDetailsFromClassName(className);
            var code = decomposedDetails.Item1;
            Name = decomposedDetails.Item2;
            NameWithCode = $"{decomposedDetails.Item3} - {Name}";
            Category = category;
            _defaultState = defaultState;
            Severity = severity;
            SuppressionAttributes = suppressionAttributes;

            Title = LocalizableStringFactory.LocalizableResourceString(titleResourceName);
            Description = LocalizableStringFactory.LocalizableResourceString(descriptionResourceName);
            MessageFormat = LocalizableStringFactory.LocalizableResourceString(messageFormatResourceName);
            DiagnosticId = Title.ToString().Replace("-", "");

            if (Title.ToString() != code)
            {
                throw new ArgumentException([email protected]"Title resource value isn't of the correct format: should be {code}",
                                            nameof(titleResourceName));
            }
        }
开发者ID:DavidArno,项目名称:Arnolyzer,代码行数:29,代码来源:AnalyzerDetails.cs

示例10: GetMessagePrefix

 // Given a message identifier (e.g., CS0219), severity, warning as error and a culture, 
 // get the entire prefix (e.g., "error CS0219: Warning as Error:" for C#) used on error messages.
 public override string GetMessagePrefix(string id, DiagnosticSeverity severity, bool isWarningAsError, CultureInfo culture)
 {
     return String.Format(culture, "{0} {1}{2}",
         severity == DiagnosticSeverity.Error || isWarningAsError ? "error" : "warning",
         id,
         isWarningAsError ? ErrorFacts.GetMessage(MessageID.IDS_WarnAsError, culture) : "");
 }
开发者ID:riversky,项目名称:roslyn,代码行数:9,代码来源:MessageProvider.cs

示例11: EnforcementLevel

 public EnforcementLevel(DiagnosticSeverity severity)
 {
     Value = severity;
     switch (severity)
     {
         case DiagnosticSeverity.Hidden:
             Name = "None";
             Moniker = KnownMonikers.None;
             return;
         case DiagnosticSeverity.Info:
             Name = "Suggestion";
             Moniker = KnownMonikers.StatusInformation;
             return;
         case DiagnosticSeverity.Warning:
             Name = "Warning";
             Moniker = KnownMonikers.StatusWarning;
             return;
         case DiagnosticSeverity.Error:
             Name = "Error";
             Moniker = KnownMonikers.StatusError;
             return;
         default:
             throw new ArgumentException("Unexpected DiagnosticSeverity", nameof(severity));
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:25,代码来源:EnforcementLevel.cs

示例12: GetDiagnosticReport

        // Take a warning and return the final deposition of the given warning,
        // based on both command line options and pragmas.
        // If you update this method, also update DiagnosticItemSource.GetEffectiveSeverity. 
        internal static ReportDiagnostic GetDiagnosticReport(DiagnosticSeverity severity, bool isEnabledByDefault, string id, int diagnosticWarningLevel, Location location, string category, int warningLevelOption, ReportDiagnostic generalDiagnosticOption, IDictionary<string, ReportDiagnostic> specificDiagnosticOptions)
        {
            // Read options (e.g., /nowarn or /warnaserror)
            ReportDiagnostic report = ReportDiagnostic.Default;
            var isSpecified = specificDiagnosticOptions.TryGetValue(id, out report);
            if (!isSpecified)
            {
                report = isEnabledByDefault ? ReportDiagnostic.Default : ReportDiagnostic.Suppress;
            }

            // Compute if the reporting should be suppressed.
            if (diagnosticWarningLevel > warningLevelOption  // honor the warning level
                || report == ReportDiagnostic.Suppress)                // check options (/nowarn)
            {
                return ReportDiagnostic.Suppress;
            }

            // If location is available, check out pragmas
            if (location != null &&
                location.SourceTree != null &&
                ((SyntaxTree)location.SourceTree).GetPragmaDirectiveWarningState(id, location.SourceSpan.Start) == ReportDiagnostic.Suppress)
            {
                return ReportDiagnostic.Suppress;
            }

            // Unless specific warning options are defined (/warnaserror[+|-]:<n> or /nowarn:<n>, 
            // follow the global option (/warnaserror[+|-] or /nowarn).
            if (report == ReportDiagnostic.Default)
            {
                switch (generalDiagnosticOption)
                {
                    case ReportDiagnostic.Error:
                        // If we've been asked to do warn-as-error then don't raise severity for anything below warning (info or hidden).
                        if (severity == DiagnosticSeverity.Warning)
                        {
                            // In the case where /warnaserror+ is followed by /warnaserror-:<n> on the command line,
                            // do not promote the warning specified in <n> to an error.
                            if (!isSpecified && (report == ReportDiagnostic.Default))
                            {
                                return ReportDiagnostic.Error;
                            }
                        }
                        break;
                    case ReportDiagnostic.Suppress:
                        // When doing suppress-all-warnings, don't lower severity for anything other than warning and info.
                        // We shouldn't suppress hidden diagnostics here because then features that use hidden diagnostics to
                        // display a lightbulb would stop working if someone has suppress-all-warnings (/nowarn) specified in their project.
                        if (severity == DiagnosticSeverity.Warning || severity == DiagnosticSeverity.Info)
                        {
                            return ReportDiagnostic.Suppress;
                        }
                        break;
                    default:
                        break;
                }
            }

            return report;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:62,代码来源:CSharpDiagnosticFilter.cs

示例13: Result

		public Result (TextSpan region, string message, DiagnosticSeverity level, IssueMarker inspectionMark, bool underline = true)
		{
			this.Region = region;
			this.Message = message;
			this.Level = level;
			this.InspectionMark = inspectionMark;
			this.Underline = underline;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:8,代码来源:Result.cs

示例14: CreateDiagnosticDescriptor

 private DiagnosticDescriptor CreateDiagnosticDescriptor(DiagnosticSeverity severity) =>
     new DiagnosticDescriptor(
         _diagnosticId,
         _title,
         _message,
         DiagnosticCategory.Style,
         severity,
         isEnabledByDefault: true);
开发者ID:natidea,项目名称:roslyn,代码行数:8,代码来源:CSharpTypeStyleDiagnosticAnalyzerBase.cs

示例15: DiagnosticDescriptor

 /// <summary>
 /// Create a DiagnosticDescriptor, which provides description about a <see cref="Diagnostic"/>.
 /// </summary>
 /// <param name="id">A unique identifier for the diagnostic. For example, code analysis diagnostic ID "CA1001".</param>
 /// <param name="description">A short localizable description of the diagnostic. For example, for CA1001: "Types that own disposable fields should be disposable".</param>
 /// <param name="messageFormat">A localizable format message string, which can be passed as the first argument to <see cref="M:System.String.Format"/> when creating the diagnostic message with this descriptor.
 /// For example, for CA1001: "Implement IDisposable on '{0}' because it creates members of the following IDisposable types: '{1}'."</param>
 /// <param name="category">The category of the diagnostic (like Design, Naming etc.). For example, for CA1001: "Microsoft.Design".</param>
 /// <param name="defaultSeverity">Default severity of the diagnostic.</param>
 public DiagnosticDescriptor(string id, string description, string messageFormat, string category, DiagnosticSeverity defaultSeverity)
 {
     this.Id = id;
     this.Description = description;
     this.Category = category;
     this.MessageFormat = messageFormat;
     this.DefaultSeverity = defaultSeverity;
 }
开发者ID:riversky,项目名称:roslyn,代码行数:17,代码来源:DiagnosticDescriptor.cs


注:本文中的DiagnosticSeverity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。