-
Notifications
You must be signed in to change notification settings - Fork 857
[AOT] Removed support for ParseStateValues if the state neither implements IReadOnlyList nor IEnumberable when ParseStateValues is true.
#4560
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
Changes from 19 commits
d59c258
3413cfb
715ad28
a74ed86
ea364a4
af5df9f
1e17473
f018b04
4b19d17
aa0f470
7ff4a77
5050f6f
136cec1
7e60a6c
c005f46
6f528ce
5daab01
9589b76
9089a63
aff152f
cbdef79
90771fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #nullable enable | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| using System.ComponentModel; | ||||||||||||||||||||||||||||||||||||||
| using System.Diagnostics; | ||||||||||||||||||||||||||||||||||||||
| using System.Diagnostics.CodeAnalysis; | ||||||||||||||||||||||||||||||||||||||
| using System.Runtime.CompilerServices; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -194,36 +193,8 @@ internal static void SetLogRecordSeverityFields(ref LogRecordData logRecordData, | |||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| try | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| PropertyDescriptorCollection itemProperties = TypeDescriptor.GetProperties(state); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| var attributeStorage = logRecord.AttributeStorage ??= new List<KeyValuePair<string, object?>>(itemProperties.Count); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| foreach (PropertyDescriptor? itemProperty in itemProperties) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if (itemProperty == null) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| object? value = itemProperty.GetValue(state); | ||||||||||||||||||||||||||||||||||||||
| if (value == null) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| attributeStorage.Add(new KeyValuePair<string, object?>(itemProperty.Name, value)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| return attributeStorage; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| catch (Exception parseException) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| OpenTelemetrySdkEventSource.Log.LoggerParseStateException<TState>(parseException); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| return Array.Empty<KeyValuePair<string, object?>>(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| OpenTelemetrySdkEventSource.Log.LoggerProcessStateSkipped<TState>(typeof(TState).FullName!, "This can be fixed by updating the state to be a type that implements either IReadOnlyList<KeyValuePair<string, object>> or IEnumerable<KeyValuePair<string, object>>."); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| /// <summary> | |
| /// Gets or sets a value indicating whether or not log state should be | |
| /// parsed into <see cref="LogRecord.Attributes"/> on generated <see | |
| /// cref="LogRecord"/>s. Default value: <see langword="false"/>. | |
| /// </summary> | |
| /// <remarks> | |
| /// Notes: | |
| /// <list type="bullet"> | |
| /// <item>Parsing is only executed when the state logged does NOT | |
| /// implement <see cref="IReadOnlyList{T}"/> or <see | |
| /// cref="IEnumerable{T}"/> where <c>T</c> is <c>KeyValuePair<string, | |
| /// object></c>.</item> | |
| /// <item>When <see cref="ParseStateValues"/> is set to <see | |
| /// langword="true"/> <see cref="LogRecord.State"/> will always be <see | |
| /// langword="null"/>.</item> | |
| /// </list> | |
| /// </remarks> | |
| public bool ParseStateValues { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI removing this code ParseStateValues essentially does nothing. Should we obsolete it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would break build for users who have used this option in their Logs SDK setup, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4334 redefines ParseStateValues.
With the redefined ParseStateValues, value of public bool ParseStateValues { get; set; } is default to false and only should be set to true if state does not implement either IReadOnlyList or IEnumerable if users want to get the properties with Reflection.
Shall we obsolete this API in this PR or use a follow-up PR for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we obsolete this API in this PR or use a follow-up PR for that?
It should be its own PR (if at all we decide to do that).
Uh oh!
There was an error while loading. Please reload this page.