Repository: dotnet/maui
File: src/Controls/src/Core/Routing.cs (C#)

Code before:
			obj.SetValue(RouteProperty, value);
		}

		private static void RemoveRouteFromSet(string route)
		{
			if (!string.IsNullOrEmpty(route) && IsUserDefined(route))
			{
				routeSet.TryRemove(route, out _);
			}
		}

		internal static void ValidateForDuplicates(Element element, string route)
		{
			var currentRoute = GetRoute(element);

			// Remove the old route when it's being changed
			if (!string.IsNullOrEmpty(currentRoute) && IsUserDefined(currentRoute) && currentRoute != route)
			{
				RemoveRouteFromSet(currentRoute);
			}

			if (!string.IsNullOrEmpty(route) && IsUserDefined(route))
			{
				if (!routeSet.TryAdd(route, 0))
				{
					throw new ArgumentException($"Duplicated Route: \"{route}\" ");
				}
			}
		}

		internal static void RemoveElementRoute(Element element)
		{
			if (element == null)
				return;

			var route = GetRoute(element);
			RemoveRouteFromSet(route);
		}

		static void ValidateRoute(string route, RouteFactory routeFactory)
		{
			if (string.IsNullOrWhiteSpace(route))
				throw new ArgumentNullException(nameof(route), "Route cannot be an empty string");

			routeFactory = routeFactory ?? throw new ArgumentNullException(nameof(routeFactory), "Route Factory cannot be null");

			var uri = new Uri(route, UriKind.RelativeOrAbsolute);

			var parts = uri.OriginalString.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (var part in parts)
			{

Review comment (refactor):
The generic duplicate message lacks context (e.g., element type or location), can expand?

```
if (!routeSet.TryAdd(route, 0))
{
    var existingElement = FindElementWithRoute(route); // Hypothetical helper to locate
    throw new ArgumentException(
        $"Duplicated Route: \"{route}\" is already registered on another element (e.g., {existingElement?.GetType().Name}). " +
        $"Routes must be unique across the Shell hierarchy to avoid navigation conflicts.",
        nameof(route));
}

```

Code after:
		{
			// If setting the same route to the same element, no need to validate
			var currentRoute = GetRoute(element);
			if (currentRoute == route)
			{
				return;
			}

			// Only validate user-defined routes
			if (string.IsNullOrEmpty(route) || !IsUserDefined(route))
			{
				return;
			}

			// Check for duplicate routes among siblings (elements with the same parent)
			var parent = element.Parent;
			if (parent == null)
			{
				return;
			}

			foreach (var child in parent.LogicalChildrenInternal)
			{
				if (child == element)
					continue;

				var siblingRoute = GetRoute(child);
				if (siblingRoute == route)
				{
					throw new ArgumentException(
						$"Duplicated Route: \"{route}\" is already registered to another element of type {child.GetType().Name}. " +
						$"Routes must be unique among siblings to avoid navigation conflicts.",
						nameof(route));
				}
			}
		}

		internal static void RemoveElementRoute(Element element)
		{
			// No longer needed with sibling-based validation, but keep for API compatibility
		}

		static void ValidateRoute(string route, RouteFactory routeFactory)
		{
			if (string.IsNullOrWhiteSpace(route))
				throw new ArgumentNullException(nameof(route), "Route cannot be an empty string");

			routeFactory = routeFactory ?? throw new ArgumentNullException(nameof(routeFactory), "Route Factory cannot be null");

			var uri = new Uri(route, UriKind.RelativeOrAbsolute);