Skip to content

Fix traffic role editing and network validation#7

Merged
wnj00524 merged 1 commit into
masterfrom
codex/wpf-network-simulator
Apr 7, 2026
Merged

Fix traffic role editing and network validation#7
wnj00524 merged 1 commit into
masterfrom
codex/wpf-network-simulator

Conversation

@wnj00524
Copy link
Copy Markdown
Owner

@wnj00524 wnj00524 commented Apr 7, 2026

No description provided.

@wnj00524 wnj00524 merged commit 61e143f into master Apr 7, 2026
0 of 2 checks passed
@wnj00524 wnj00524 deleted the codex/wpf-network-simulator branch April 7, 2026 20:41
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive validation for network edges and traffic profiles, ensuring numerical values are valid and non-negative. It also refactors the view model to centralize traffic definition creation and adds logic to handle name changes, including normalization and duplicate detection. A potential runtime exception was identified in the name change handler due to collection modification during iteration, which should be addressed by using a snapshot of the collection.

foreach (var node in Nodes)
{
foreach (var profile in node.TrafficProfiles.Where(profile => Comparer.Equals(profile.TrafficType, e.OldValue)))
foreach (var profile in node.TrafficProfiles.Where(profile => Comparer.Equals(profile.TrafficType, oldValue)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Iterating over node.TrafficProfiles while modifying its elements' properties can lead to an InvalidOperationException (Collection was modified) if the property change triggers a profile normalization that removes items from the collection. Since profile.TrafficType = normalizedName can cause NormalizeNodeTrafficProfiles to run and potentially remove duplicate profiles, you should create a snapshot of the matching profiles before iterating.

            foreach (var profile in node.TrafficProfiles.Where(profile => Comparer.Equals(profile.TrafficType, oldValue)).ToList())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant