-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better titles for Find References windows
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
namespace MonoDevelop.MSBuild; | ||
|
||
// consider moving some of these down to the XML layer? | ||
static partial class MSBuildLoggerExtensions | ||
{ | ||
/// <summary> | ||
/// Helper for switch expressions to log a message about missing cases when they can gracefully return a default value instead of throwing | ||
/// </summary> | ||
/// <remarks>This must be kept internal so that analyzers and fixes don't use it, as it does not sanitize the callsite for PII.</remarks> | ||
internal static TReturn LogUnhandledCaseAndReturnDefaultValue<TReturn,TSwitchValue> (this ILogger logger, TReturn valueToReturn, TSwitchValue missingValue, [CallerMemberName] string methodName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = 0) | ||
{ | ||
LogUnhandledCase(logger, missingValue, methodName, filePath, lineNumber); | ||
return valueToReturn; | ||
} | ||
|
||
/// <remarks>This must be kept internal so that analyzers and fixes don't use it, as it does not sanitize the callsite for PII.</remarks> | ||
[LoggerMessage (EventId = 0, Level = LogLevel.Warning, Message = "Unhandled case '{missingValue}' in method {methodName} at {filePath}:{lineNumber}'")] | ||
static partial void LogUnhandledCase (ILogger logger, object missingValue, string methodName, string filePath, int lineNumber); | ||
} |