-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add obsolete compatibility shims for moved Microsoft.Extensions.Logging internal types #127194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e57fd52
Add NullScope compatibility type to Microsoft.Extensions.Logging.Abst…
Copilot 0b9a8d7
Add compatibility shims with public counterparts in both namespaces f…
Copilot e02c2db
Rename NullScopeLogging.cs to NullScopeAbstractions.cs to match class…
Copilot 2b95207
Remove non-obsolete public types; keep only the Internal obsolete shims
Copilot c449159
Rename NullScope.cs to NullScopeObsolete.cs; remove unnecessary type …
Copilot 140dbb8
Make API compatible with 2.1 Logging.Abstractiosn
ericstj 06cd5ec
Fix ref
ericstj 8aa478e
Adjust obsolete messages
ericstj 058c150
Apply suggestions from code review
ericstj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
46 changes: 46 additions & 0 deletions
46
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/FormattedLogValuesObsolete.cs
This file contains hidden or 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,46 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Microsoft.Extensions.Logging.Internal | ||
| { | ||
| /// <summary> | ||
| /// LogValues to enable formatting options supported by <see cref="string.Format(IFormatProvider, string, object?)"/>. | ||
| /// This also enables using {NamedFormatItem} in the format string. | ||
| /// </summary> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| [Obsolete("This type is retained only for compatibility. The recommended alternative is the Microsoft.Extensions.Diagnostics.Testing package.", error: true)] | ||
| public class FormattedLogValues : IReadOnlyList<KeyValuePair<string, object?>> | ||
|
ericstj marked this conversation as resolved.
|
||
| { | ||
| private Microsoft.Extensions.Logging.FormattedLogValues _inner; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="FormattedLogValues"/> class. | ||
| /// </summary> | ||
| /// <param name="format">The format string.</param> | ||
| /// <param name="values">The values.</param> | ||
| public FormattedLogValues(string? format, params object?[]? values) | ||
| { | ||
| _inner = new Microsoft.Extensions.Logging.FormattedLogValues(format, values); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public KeyValuePair<string, object?> this[int index] => _inner[index]; | ||
|
|
||
| /// <inheritdoc /> | ||
| public int Count => _inner.Count; | ||
|
|
||
| /// <inheritdoc /> | ||
| public IEnumerator<KeyValuePair<string, object?>> GetEnumerator() => _inner.GetEnumerator(); | ||
|
|
||
| /// <inheritdoc /> | ||
| IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
|
|
||
| /// <inheritdoc /> | ||
| public override string ToString() => _inner.ToString(); | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatterObsolete.cs
This file contains hidden or 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,43 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Microsoft.Extensions.Logging.Internal | ||
| { | ||
| /// <summary> | ||
| /// Formatter to convert the named format items like {NamedformatItem} to <see cref="string.Format(IFormatProvider, string, object)"/> format. | ||
| /// </summary> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| [Obsolete("This type is retained only for compatibility. The recommended alternative is the Microsoft.Extensions.Diagnostics.Testing package.", error: true)] | ||
| public class LogValuesFormatter | ||
|
ericstj marked this conversation as resolved.
|
||
| { | ||
| private readonly Microsoft.Extensions.Logging.LogValuesFormatter _inner; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="LogValuesFormatter"/> class. | ||
| /// </summary> | ||
| /// <param name="format">The named format string.</param> | ||
| public LogValuesFormatter(string format) | ||
| { | ||
| _inner = new Microsoft.Extensions.Logging.LogValuesFormatter(format); | ||
| } | ||
|
|
||
| /// <summary>Gets the original format string.</summary> | ||
| public string OriginalFormat => _inner.OriginalFormat; | ||
|
|
||
| /// <summary>Gets the list of named format parameter names.</summary> | ||
| public List<string> ValueNames => _inner.ValueNames; | ||
|
|
||
| /// <summary>Formats the given values using the format string.</summary> | ||
| public string Format(object?[]? values) => _inner.Format(values); | ||
|
|
||
| /// <summary>Gets the key/value pair for the format item at the specified index.</summary> | ||
| public KeyValuePair<string, object?> GetValue(object?[] values, int index) => _inner.GetValue(values, index); | ||
|
|
||
| /// <summary>Gets an enumerable of key/value pairs for all format items.</summary> | ||
| public IEnumerable<KeyValuePair<string, object?>> GetValues(object[] values) => _inner.GetValues(values); | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullScopeObsolete.cs
This file contains hidden or 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,30 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Microsoft.Extensions.Logging.Abstractions.Internal | ||
| { | ||
| /// <summary> | ||
| /// An empty scope without any logic. | ||
| /// </summary> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| [Obsolete("This type is retained only for compatibility.", error: true)] | ||
| public class NullScope : IDisposable | ||
|
ericstj marked this conversation as resolved.
|
||
| { | ||
| /// <summary> | ||
| /// Returns the shared instance of <see cref="NullScope"/>. | ||
| /// </summary> | ||
| public static NullScope Instance { get; } = new NullScope(); | ||
|
|
||
| private NullScope() | ||
|
ericstj marked this conversation as resolved.
|
||
| { | ||
| } | ||
|
ericstj marked this conversation as resolved.
|
||
|
|
||
| /// <inheritdoc /> | ||
| public void Dispose() | ||
| { | ||
| } | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/TypeNameHelperObsolete.cs
This file contains hidden or 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,20 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Microsoft.Extensions.Logging.Abstractions.Internal | ||
| { | ||
| /// <summary> | ||
| /// Helper to process type names. | ||
| /// </summary> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| [Obsolete("This type is retained only for compatibility.", error: true)] | ||
| public class TypeNameHelper | ||
| { | ||
| /// <summary>Pretty prints a type name.</summary> | ||
| public static string GetTypeDisplayName(Type type) | ||
| => Microsoft.Extensions.Internal.TypeNameHelper.GetTypeDisplayName(type); | ||
|
ericstj marked this conversation as resolved.
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.