| File: Errors\CSDiagnostic.cs | Web Access |
| Project: src\roslyn\src\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj (Microsoft.CodeAnalysis.CSharp) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; namespace Microsoft.CodeAnalysis.CSharp { /// <summary> /// A diagnostic, along with the location where it occurred. /// </summary> internal sealed class CSDiagnostic : DiagnosticWithInfo { internal CSDiagnostic(DiagnosticInfo info, Location location, bool isSuppressed = false) : base(info, location, isSuppressed) { } public override string ToString() { return CSharpDiagnosticFormatter.Instance.Format(this); } internal override Diagnostic WithLocation(Location location) { if (location == null) { throw new ArgumentNullException(nameof(location)); } if (location != this.Location) { return new CSDiagnostic(this.Info, location, this.IsSuppressed); } return this; } internal override Diagnostic WithSeverity(DiagnosticSeverity severity) { var info = this.Info.GetInstanceWithSeverity(severity); if (info != this.Info) { return new CSDiagnostic(info, this.Location, this.IsSuppressed); } return this; } internal override Diagnostic WithIsSuppressed(bool isSuppressed) { if (this.IsSuppressed != isSuppressed) { return new CSDiagnostic(this.Info, this.Location, isSuppressed); } return this; } } }