Repository: dotnet/runtime
File: src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs (C#)

Code before:
            }

            BindingFlags flags = BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance;
            if (IgnoreCase)
            {
                flags |= BindingFlags.IgnoreCase;
            }

            bool componentReflect = false;
            if (value is IComponent)
            {
                ISite? site = ((IComponent)value).Site;
                if (site != null && site.DesignMode)
                {
                    componentReflect = true;
                }
            }

            foreach (KeyValuePair<string, object?> kvp in resources)
            {
                // See if this key matches our object.
                string key = kvp.Key;

                if (IgnoreCase)
                {
                    if (!key.AsSpan().StartsWith(objectName, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!key.AsSpan().StartsWith(objectName, StringComparison.Ordinal))
                    {
                        continue;
                    }
                }

                // Character after objectName.Length should be a "." or a '-', or else we should continue.
                int idx = objectName.Length;
                if (key.Length <= idx || (key[idx] != '.' && key[idx] != '-'))
                {
                    continue;
                }

                // Bypass type descriptor if we are not in design mode. TypeDescriptor does an attribute
                // scan which is quite expensive.
                string propName = key.Substring(idx + 1);

                if (componentReflect)
                {

Review comment (suggestion):
The branches here can be simplified to
```c#
if (!key.StartsWith(objectName, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
```

Code after:
            }

            BindingFlags flags = BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance;
            if (IgnoreCase)
            {
                flags |= BindingFlags.IgnoreCase;
            }

            bool componentReflect = false;
            if (value is IComponent)
            {
                ISite? site = ((IComponent)value).Site;
                if (site != null && site.DesignMode)
                {
                    componentReflect = true;
                }
            }

            foreach (KeyValuePair<string, object?> kvp in resources)
            {
                // See if this key matches our object.
                string key = kvp.Key;

                if (!key.StartsWith(objectName, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
                {
                    continue;
                }

                // Character after objectName.Length should be a "." or a '-', or else we should continue.
                int idx = objectName.Length;
                if (key.Length <= idx || (key[idx] != '.' && key[idx] != '-'))
                {
                    continue;
                }

                // Bypass type descriptor if we are not in design mode. TypeDescriptor does an attribute
                // scan which is quite expensive.
                string propName = key.Substring(idx + 1);

                if (componentReflect)
                {
                    PropertyDescriptor? prop = TypeDescriptorGetProperties(value).Find(propName, IgnoreCase);

                    if (prop != null && !prop.IsReadOnly && (kvp.Value == null || prop.PropertyType.IsInstanceOfType(kvp.Value)))
                    {
                        prop.SetValue(value, kvp.Value);
                    }
                }
                else
                {
                    PropertyInfo? prop;