Skip to content

Commit a603a40

Browse files
authored
Added overloads to IDiagnosticReporter that accept a simple message string without any formatting etc... (#337)
* Implements #311 * Additional refactoring from real-world consumer - `Ubiquity.NET.SrcGeneration.CSharp.MakeIdentifier()` is now a proper extension method. - This got lost in shift away from use of `extension` keyword. * Unified and clarified use of functions that write comments by including `Comment[s]` in the name.
1 parent 50a34e4 commit a603a40

3 files changed

Lines changed: 52 additions & 3 deletions

File tree

src/Ubiquity.NET.CommandLine/DiagnosticReporterExtensions.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ public static void Error(
365365
{
366366
Error(self, code: null, location, origin: null, subCategory: null, handler);
367367
}
368+
369+
// doc comments don't inherit param correctly, see: https://github.com/dotnet/roslyn/issues/67326#issuecomment-3452843800
370+
371+
/// <inheritdoc cref="Error(IDiagnosticReporter, string?, SourceRange, Uri?, string?, ErrorReportingInterpolatedStringHandler)" path="/summary"/>
372+
/// <param name="self">Reporter to report message to</param>
373+
/// <param name="msg">Message to report</param>
374+
/// <param name="location">Location in the origin that this message refers to</param>
375+
/// <inheritdoc cref="Error(IDiagnosticReporter, string?, SourceRange, Uri?, string?, ErrorReportingInterpolatedStringHandler)" path="/remarks"/>
376+
public static void Error(this IDiagnosticReporter self, string msg, SourceRange location = default)
377+
{
378+
Error(self, code: null, location, origin: null, subCategory: null, formatProvider: null, msg /*, args...*/);
379+
}
368380
#endregion
369381

370382
#region MsgLevel.Warning
@@ -470,6 +482,18 @@ public static void Warning(
470482
{
471483
Warning(self, code: null, location, origin: null, subCategory: null, handler);
472484
}
485+
486+
// doc comments don't inherit param correctly, see: https://github.com/dotnet/roslyn/issues/67326#issuecomment-3452843800
487+
488+
/// <inheritdoc cref="Warning(IDiagnosticReporter, string?, SourceRange, Uri?, string?, WarningReportingInterpolatedStringHandler)" path="/summary"/>
489+
/// <param name="self">Reporter to report message to</param>
490+
/// <param name="msg">Message to report</param>
491+
/// <param name="location">Location in the origin that this message refers to</param>
492+
/// <inheritdoc cref="Warning(IDiagnosticReporter, string?, SourceRange, Uri?, string?, WarningReportingInterpolatedStringHandler)" path="/remarks"/>
493+
public static void Warning( this IDiagnosticReporter self, string msg, SourceRange location = default )
494+
{
495+
Warning( self, code: null, location, origin: null, subCategory: null, formatProvider: null, msg /*, args...*/);
496+
}
473497
#endregion
474498

475499
#region MsgLevel.Information
@@ -575,6 +599,19 @@ public static void Information(
575599
{
576600
Information(self, code: null, location, origin: null, subCategory: null, handler);
577601
}
602+
603+
// doc comments don't inherit param correctly, see: https://github.com/dotnet/roslyn/issues/67326#issuecomment-3452843800
604+
605+
/// <inheritdoc cref="Information(IDiagnosticReporter, string?, SourceRange, Uri?, string?, InformationReportingInterpolatedStringHandler)" path="/summary"/>
606+
/// <param name="self">Reporter to report message to</param>
607+
/// <param name="msg">Message to report</param>
608+
/// <param name="location">Location in the origin that this message refers to</param>
609+
/// <inheritdoc cref="Information(IDiagnosticReporter, string?, SourceRange, Uri?, string?, InformationReportingInterpolatedStringHandler)" path="/remarks"/>
610+
public static void Information( this IDiagnosticReporter self, string msg, SourceRange location = default )
611+
{
612+
Information( self, code: null, location, origin: null, subCategory: null, formatProvider: null, msg /*, args...*/);
613+
}
614+
578615
#endregion
579616

580617
#region MsgLevel.Verbose
@@ -680,6 +717,18 @@ public static void Verbose(
680717
{
681718
Verbose(self, code: null, location, origin: null, subCategory: null, handler);
682719
}
720+
721+
// doc comments don't inherit param correctly, see: https://github.com/dotnet/roslyn/issues/67326#issuecomment-3452843800
722+
723+
/// <inheritdoc cref="Verbose(IDiagnosticReporter, string?, SourceRange, Uri?, string?, VerboseReportingInterpolatedStringHandler)" path="/summary"/>
724+
/// <param name="self">Reporter to report message to</param>
725+
/// <param name="msg">Message to report</param>
726+
/// <param name="location">Location in the origin that this message refers to</param>
727+
/// <inheritdoc cref="Verbose(IDiagnosticReporter, string?, SourceRange, Uri?, string?, VerboseReportingInterpolatedStringHandler)" path="/remarks"/>
728+
public static void Verbose( this IDiagnosticReporter self, string msg, SourceRange location = default )
729+
{
730+
Verbose( self, code: null, location, origin: null, subCategory: null, formatProvider: null, msg /*, args...*/);
731+
}
683732
#endregion
684733
}
685734
}

src/Ubiquity.NET.SrcGeneration/CSharp/CSharpLanguage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static class CSharpLanguage
100100
/// <summary>Makes an identifier (Escaping a language keyword)</summary>
101101
/// <param name="self">identifier string to convert</param>
102102
/// <returns>Syntactically valid identifier</returns>
103-
public static string MakeIdentifier( string self )
103+
public static string MakeIdentifier( this string self )
104104
{
105105
ArgumentNullException.ThrowIfNull( self );
106106

src/Ubiquity.NET.SrcGeneration/CSharp/TextWriterCsExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void WriteAttribute(this TextWriter self, string attributeName, pa
4444
/// <summary>Writes an XML Doc comment summary</summary>
4545
/// <param name="self">The writer to write to</param>
4646
/// <param name="description">Text to include in the summary (Nothing is written if this is <see langword="null"/> </param>
47-
public static void WriteSummary(this TextWriter self, string? description )
47+
public static void WriteSummaryComment(this TextWriter self, string? description )
4848
{
4949
ArgumentNullException.ThrowIfNull( self );
5050

@@ -92,7 +92,7 @@ public static void WriteRemarksComment( this TextWriter self, string? txt )
9292
/// is used as the summary. If <paramref name="defaultSummary"/> is also empty or all Whitespace then nothing
9393
/// is output.
9494
/// </remarks>
95-
public static void WriteSummaryAndRemarks( this TextWriter self, string? txt, string defaultSummary = "" )
95+
public static void WriteSummaryAndRemarksComments( this TextWriter self, string? txt, string defaultSummary = "" )
9696
{
9797
ArgumentNullException.ThrowIfNull( self );
9898

0 commit comments

Comments
 (0)