-
Notifications
You must be signed in to change notification settings - Fork 669
DYN-10081: Preserve warnings/info stack format and Batch node info updates #16955
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 all commits
cb30868
8497710
db9155a
c0e7861
1cfa9db
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 |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ public override int GetHashCode() | |
| unchecked | ||
| { | ||
| int hash = 17; | ||
| hash = hash * 23 + Message == null ? 0 : Message.GetHashCode(); | ||
| hash = hash * 23 + (Message == null ? 0 : Message.GetHashCode()); | ||
| hash = hash * 23 + State.GetHashCode(); | ||
| return hash; | ||
| } | ||
|
|
@@ -81,6 +81,12 @@ public abstract class NodeModel : ModelBase, IRenderPackageSource<NodeModel>, ID | |
| private bool canUpdatePeriodically; | ||
| private string name; | ||
| private ElementState state; | ||
| /// <summary> | ||
| /// Suppresses ClearTransientWarningsAndErrors() in the State setter during | ||
| /// Info() state restoration. Access is single-threaded (NodeModel state mutations | ||
| /// are not thread-safe by design). | ||
| /// </summary> | ||
| private bool suppressClearTransientMessages; | ||
| private readonly ObservableHashSet<Info> infos = new ObservableHashSet<Info>(); | ||
| private string description; | ||
|
|
||
|
|
@@ -390,7 +396,8 @@ public ElementState State | |
| get { return state; } | ||
| set | ||
| { | ||
| if (value != ElementState.Error && value != ElementState.Info && value != ElementState.PersistentInfo && value != ElementState.AstBuildBroken) | ||
| if (!suppressClearTransientMessages && | ||
| value != ElementState.Error && value != ElementState.Info && value != ElementState.PersistentInfo && value != ElementState.AstBuildBroken) | ||
| ClearTransientWarningsAndErrors(); | ||
|
|
||
| // Check before settings and raising | ||
|
|
@@ -1797,13 +1804,12 @@ public virtual void ClearErrorsAndWarnings() | |
| } | ||
|
|
||
| /// <summary> | ||
| /// Clears the info messages that are generated when running the graph, | ||
| /// the State will be set to ElementState.Active. | ||
| /// Clears the info messages that are generated when running the graph. | ||
| /// If the current State is Info or PersistentInfo, it will be set to Active. | ||
| /// If the current State is Warning, Error, or another non-info state, it is preserved. | ||
| /// </summary> | ||
| public virtual void ClearInfoMessages() | ||
| { | ||
| // It is very unlikely a node could be in both info state and persistent info state from the current design | ||
| // If that exception happens, we should redesign this function or have particular node override the behavior | ||
| if (State == ElementState.Info) | ||
| { | ||
| infos.RemoveWhere(x => x.State == ElementState.Info); | ||
|
|
@@ -1812,12 +1818,21 @@ public virtual void ClearInfoMessages() | |
| { | ||
| infos.RemoveWhere(x => x.State == ElementState.PersistentInfo); | ||
| } | ||
| // If there are still warnings/errors, keep the state unchanged. | ||
| else if (State == ElementState.Warning || State == ElementState.Error) | ||
| else | ||
| { | ||
| // For any other state (Warning, Error, Active, Dead, etc.), clear all info types. | ||
| // This fixes the case where State was restored (e.g., by Info() method) and no | ||
| // longer matches Info/PersistentInfo, but info entries still exist in Infos. | ||
| infos.RemoveWhere(x => x.State == ElementState.PersistentInfo || x.State == ElementState.Info); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This confusing naming has been there for a while. We have a notion of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a good time to rename some of these fields/properties to something more sensible and have a clear separation of meaning?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will look into this, this has bothered me for a while too |
||
| } | ||
| State = ElementState.Active; | ||
|
|
||
| // Only reset State to Active if it was info-related. | ||
| // Don't demote Warning/Error to Active — that would trigger | ||
| // ClearTransientWarningsAndErrors() via the setter side effect. | ||
| if (State == ElementState.Info || State == ElementState.PersistentInfo) | ||
| { | ||
| State = ElementState.Active; | ||
| } | ||
| OnNodeInfoMessagesClearing(); | ||
| } | ||
|
|
||
|
|
@@ -1985,7 +2000,13 @@ public void Info(string p, bool isPersistent = false) | |
| initialState == ElementState.PersistentWarning || | ||
| initialState == ElementState.Error) | ||
| { | ||
| State = initialState; | ||
| // Suppress the ClearTransientWarningsAndErrors() side effect in the State setter | ||
| // during restoration. Without this, restoring State to Warning triggers the setter | ||
| // which calls ClearTransientWarningsAndErrors(), wiping the warning entry from Infos | ||
| // that was just added before Info() was called. | ||
| suppressClearTransientMessages = true; | ||
| try { State = initialState; } | ||
| finally { suppressClearTransientMessages = false; } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.