From ebae0b1128057005cf09c7a7b58a302fd83d6943 Mon Sep 17 00:00:00 2001 From: ThomasGoulet73 <51839772+ThomasGoulet73@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:58:22 -0400 Subject: [PATCH] Cleanup: Use named arguments in System.Xaml. Contributes to dotnet/wpf#10018 --- .../System/Xaml/Context/ObjectWriterContext.cs | 4 ++-- .../System/Xaml/InfosetObjects/XamlObjectWriter.cs | 8 ++++---- .../System/Xaml/InfosetObjects/XamlTextReader.cs | 2 +- .../src/System.Xaml/System/Xaml/Parser/MeScanner.cs | 4 ++-- .../src/System.Xaml/System/Xaml/Parser/XamlAttribute.cs | 2 +- .../System/Xaml/Runtime/DynamicMethodRuntime.cs | 4 ++-- .../System/Xaml/Runtime/PartialTrustTolerantRuntime.cs | 2 +- .../System.Xaml/System/Xaml/Schema/CollectionReflector.cs | 8 ++++---- .../src/System.Xaml/System/Xaml/Schema/Reflector.cs | 2 +- .../src/System.Xaml/System/Xaml/Schema/TypeReflector.cs | 6 +++--- .../src/System.Xaml/System/Xaml/Schema/XmlNamespace.cs | 2 +- .../src/System.Xaml/System/Xaml/XamlMember.cs | 8 ++++---- .../src/System.Xaml/System/Xaml/XamlObjectReader.cs | 6 +++--- .../src/System.Xaml/System/Xaml/XamlType.cs | 6 +++--- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/ObjectWriterContext.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/ObjectWriterContext.cs index efb5a16d29b..a8f10407afe 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/ObjectWriterContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/ObjectWriterContext.cs @@ -171,7 +171,7 @@ internal XamlType ServiceProvider_ResolveXamlType(string qName) internal AmbientPropertyValue ServiceProvider_GetFirstAmbientValue(IEnumerable ceilingTypes, XamlMember[] properties) { - List valueList = FindAmbientValues(ceilingTypes, /*searchLiveStackOnly*/false, /*types*/null, properties, true); + List valueList = FindAmbientValues(ceilingTypes, searchLiveStackOnly: false, types: null, properties, true); return (valueList.Count == 0) ? null : valueList[0]; } @@ -183,7 +183,7 @@ internal object ServiceProvider_GetFirstAmbientValue(XamlType[] types) internal IEnumerable ServiceProvider_GetAllAmbientValues(IEnumerable ceilingTypes, XamlMember[] properties) { - List valueList = FindAmbientValues(ceilingTypes, /*searchLiveStackOnly*/false, /*types*/null, properties, /*stopAfterFirst*/ false); + List valueList = FindAmbientValues(ceilingTypes, searchLiveStackOnly: false, types: null, properties, stopAfterFirst: false); return valueList; } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlObjectWriter.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlObjectWriter.cs index 1128436f8c7..beb9a5328fe 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlObjectWriter.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlObjectWriter.cs @@ -131,7 +131,7 @@ private XamlRuntime CreateRuntime(XamlObjectWriterSettings settings, XamlSchemaC } if (result == null) { - result = new ClrObjectRuntime(runtimeSettings, true /*isWriter*/); + result = new ClrObjectRuntime(runtimeSettings, isWriter: true); } result.LineInfo = this; return result; @@ -606,7 +606,7 @@ public override void WriteStartMember(XamlMember property) // Duplicate Property Setting Check. // - Logic_DuplicatePropertyCheck(_context, property, false /*onParent*/); + Logic_DuplicatePropertyCheck(_context, property, onParent: false); // If we haven't created the object yet then consider creating it now. // We need an object instance to set property values on. @@ -1531,7 +1531,7 @@ private void Logic_ApplyCurrentPreconstructionPropertyValues(ObjectWriterContext } else { - Logic_ApplyPropertyValue(ctx, prop, value, false /*onParent*/); + Logic_ApplyPropertyValue(ctx, prop, value, onParent: false); } } } @@ -2011,7 +2011,7 @@ private void Logic_DoAssignmentToParentProperty(ObjectWriterContext ctx) if (!ctx.CurrentIsObjectFromMember) { - Logic_ApplyPropertyValue(ctx, parentProperty, value, true /*onParent*/); + Logic_ApplyPropertyValue(ctx, parentProperty, value, onParent: true); // registered a named object if (parentProperty == parentType.GetAliasedProperty(XamlLanguage.Name)) diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlTextReader.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlTextReader.cs index 6343201d7a8..5c22dd1c859 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlTextReader.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/InfosetObjects/XamlTextReader.cs @@ -111,7 +111,7 @@ private void Initialize(XmlReader givenXmlReader, XamlSchemaContext schemaContex _endOfStreamNode = new InternalNode(InternalNodeType.EndOfStream); _context = (XamlParserContext)XamlContext.CreateContext(UsageMode.Parser, schemaContext, - _mergedSettings.LocalAssembly, false /*ignoreCanConvert*/); + _mergedSettings.LocalAssembly, ignoreCanConvert: false); XamlScanner xamlScanner = new XamlScanner(_context, myXmlReader, _mergedSettings); XamlPullParser parser = new XamlPullParser(_context, xamlScanner, _mergedSettings); diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs index 22bd1dd8334..182254cc9f7 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs @@ -324,14 +324,14 @@ private void ResolvePropertyName(string longName) if (propName.IsDotted) { - prop = _context.GetDottedProperty(tagType, tagNamespace, propName, false /*tagIsRoot*/); + prop = _context.GetDottedProperty(tagType, tagNamespace, propName, tagIsRoot: false); } // Regular property p else { string ns = _context.GetAttributeNamespace(propName, Namespace); declaringType = _context.CurrentType; - prop = _context.GetNoDotAttributeProperty(declaringType, propName, Namespace, ns, false /*tagIsRoot*/); + prop = _context.GetNoDotAttributeProperty(declaringType, propName, Namespace, ns, tagIsRoot: false); } _tokenProperty = prop; } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlAttribute.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlAttribute.cs index 168b7b4eede..cdeec47b0f0 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlAttribute.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlAttribute.cs @@ -154,7 +154,7 @@ private XamlMember GetXamlAttributeProperty(XamlParserContext context, XamlPrope if (propName.IsDotted) { XamlType attachedOwnerType = new XamlType(string.Empty, propName.OwnerName, null, context.SchemaContext); - unknownProperty = new XamlMember(propName.Name, attachedOwnerType, true /*isAttachable*/); + unknownProperty = new XamlMember(propName.Name, attachedOwnerType, isAttachable: true); } else { diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/DynamicMethodRuntime.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/DynamicMethodRuntime.cs index e7e454fbe40..13fb90c5f7d 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/DynamicMethodRuntime.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/DynamicMethodRuntime.cs @@ -126,7 +126,7 @@ private Dictionary DelegateCreators internal DynamicMethodRuntime(XamlRuntimeSettings settings, XamlSchemaContext schemaContext, XamlAccessLevel accessLevel) - : base(settings, true /*isWriter*/) + : base(settings, isWriter: true) { Debug.Assert(schemaContext != null); Debug.Assert(accessLevel != null); @@ -134,7 +134,7 @@ internal DynamicMethodRuntime(XamlRuntimeSettings settings, XamlSchemaContext sc _localAssembly = Assembly.Load(accessLevel.AssemblyAccessToAssemblyName); if (accessLevel.PrivateAccessToTypeName != null) { - _localType = _localAssembly.GetType(accessLevel.PrivateAccessToTypeName, true /*throwOnError*/); + _localType = _localAssembly.GetType(accessLevel.PrivateAccessToTypeName, throwOnError: true); } } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/PartialTrustTolerantRuntime.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/PartialTrustTolerantRuntime.cs index f61067056cc..61374b0a7d9 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/PartialTrustTolerantRuntime.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Runtime/PartialTrustTolerantRuntime.cs @@ -39,7 +39,7 @@ class PartialTrustTolerantRuntime : XamlRuntime public PartialTrustTolerantRuntime(XamlRuntimeSettings runtimeSettings, XamlAccessLevel accessLevel, XamlSchemaContext schemaContext) { - _transparentRuntime = new ClrObjectRuntime(runtimeSettings, true /*isWriter*/); + _transparentRuntime = new ClrObjectRuntime(runtimeSettings, isWriter: true); _accessLevel = accessLevel; _schemaContext = schemaContext; } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/CollectionReflector.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/CollectionReflector.cs index 0d2f900ad73..433e2fc90e4 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/CollectionReflector.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/CollectionReflector.cs @@ -66,11 +66,11 @@ internal static XamlCollectionKind LookupCollectionKind(Type type, out MethodInf } // If the type doesn't match any of the interfaces, check for Add methods - if (TryGetDictionaryAdder(type, false /*mayBeIDictionary*/, out addMethod)) + if (TryGetDictionaryAdder(type, mayBeIDictionary: false, out addMethod)) { return XamlCollectionKind.Dictionary; } - if (TryGetCollectionAdder(type, false /*mayBeICollection*/, out addMethod)) + if (TryGetCollectionAdder(type, mayBeICollection: false, out addMethod)) { return XamlCollectionKind.Collection; } @@ -84,14 +84,14 @@ internal static MethodInfo LookupAddMethod(Type type, XamlCollectionKind collect switch (collectionKind) { case XamlCollectionKind.Collection: - bool isCollection = TryGetCollectionAdder(type, true /*mayBeICollection*/, out result); + bool isCollection = TryGetCollectionAdder(type, mayBeICollection: true, out result); if (isCollection && result == null) { throw new XamlSchemaException(SR.Format(SR.AmbiguousCollectionItemType, type)); } break; case XamlCollectionKind.Dictionary: - bool isDictionary = TryGetDictionaryAdder(type, true /*mayBeIDictionary*/, out result); + bool isDictionary = TryGetDictionaryAdder(type, mayBeIDictionary: true, out result); if (isDictionary && result == null) { throw new XamlSchemaException(SR.Format(SR.AmbiguousDictionaryItemType, type)); diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/Reflector.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/Reflector.cs index adfb67d47a5..9561dfd504d 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/Reflector.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/Reflector.cs @@ -68,7 +68,7 @@ public string GetAttributeString(Type attributeType, out bool checkedInherited) // Passes inherit=true for reasons explained in comment on XamlType.TryGetAttributeString checkedInherited = true; - object[] attributes = CustomAttributeProvider.GetCustomAttributes(attributeType, true /*inherit*/); + object[] attributes = CustomAttributeProvider.GetCustomAttributes(attributeType, inherit: true); if (attributes.Length == 0) { return null; diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs index 87fc3f327aa..0edb9d63981 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs @@ -756,7 +756,7 @@ private List LookupStaticAdders(string name) string adderName = KnownStrings.Add + name + KnownStrings.Handler; MemberInfo[] adders = UnderlyingType.GetMember(adderName, MemberTypes.Method, AttachableProperties_BF); List preferredAdders, otherAdders; - PrioritizeAccessors(adders, true /*isEvent*/, false /*isGetter*/, out preferredAdders, out otherAdders); + PrioritizeAccessors(adders, isEvent: true, isGetter: false, out preferredAdders, out otherAdders); return preferredAdders ?? otherAdders; } @@ -764,7 +764,7 @@ private List LookupStaticGetters(string name) { MemberInfo[] getters = UnderlyingType.GetMember(KnownStrings.Get + name, MemberTypes.Method, AttachableProperties_BF); List preferredGetters, otherGetters; - PrioritizeAccessors(getters, false /*isEvent*/, true /*isGetter*/, out preferredGetters, out otherGetters); + PrioritizeAccessors(getters, isEvent: false, isGetter: true, out preferredGetters, out otherGetters); return preferredGetters ?? otherGetters; } @@ -772,7 +772,7 @@ private List LookupStaticSetters(string name) { MemberInfo[] setters = UnderlyingType.GetMember(KnownStrings.Set + name, MemberTypes.Method, AttachableProperties_BF); List preferredSetters, otherSetters; - PrioritizeAccessors(setters, false /*isEvent*/, false /*isGetter*/, out preferredSetters, out otherSetters); + PrioritizeAccessors(setters, isEvent: false, isGetter: false, out preferredSetters, out otherSetters); return preferredSetters ?? otherSetters; } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/XmlNamespace.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/XmlNamespace.cs index 0c5dd480ced..4b43f19d739 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/XmlNamespace.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/XmlNamespace.cs @@ -75,7 +75,7 @@ public override XamlProperty GetDirectiveProperty(string name) if (directive == null) { directive = new UnknownProperty(name, - null, /*declaringType - xml directives don't have one. */ + declaringType: null, /* xml directives don't have a declaring type. */ XmlDirectives.Uri); } return directive; diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlMember.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlMember.cs index b616aada3b1..612b9978e8b 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlMember.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlMember.cs @@ -48,7 +48,7 @@ public XamlMember(PropertyInfo propertyInfo, XamlSchemaContext schemaContext) } public XamlMember(PropertyInfo propertyInfo, XamlSchemaContext schemaContext, XamlMemberInvoker invoker) - : this(propertyInfo, schemaContext, invoker, new MemberReflector(false /*isEvent*/)) + : this(propertyInfo, schemaContext, invoker, new MemberReflector(isEvent: false)) { } @@ -71,7 +71,7 @@ public XamlMember(EventInfo eventInfo, XamlSchemaContext schemaContext) } public XamlMember(EventInfo eventInfo, XamlSchemaContext schemaContext, XamlMemberInvoker invoker) - :this(eventInfo, schemaContext, invoker, new MemberReflector(true /*isEvent*/)) + :this(eventInfo, schemaContext, invoker, new MemberReflector(isEvent: true)) { } @@ -96,7 +96,7 @@ public XamlMember(string attachablePropertyName, MethodInfo getter, MethodInfo s public XamlMember(string attachablePropertyName, MethodInfo getter, MethodInfo setter, XamlSchemaContext schemaContext, XamlMemberInvoker invoker) - :this(attachablePropertyName, getter, setter, schemaContext, invoker, new MemberReflector(getter, setter, false /*isEvent*/)) + :this(attachablePropertyName, getter, setter, schemaContext, invoker, new MemberReflector(getter, setter, isEvent: false)) { } @@ -129,7 +129,7 @@ public XamlMember(string attachableEventName, MethodInfo adder, XamlSchemaContex public XamlMember(string attachableEventName, MethodInfo adder, XamlSchemaContext schemaContext, XamlMemberInvoker invoker) - : this(attachableEventName, adder, schemaContext, invoker, new MemberReflector(null, adder, true /*isEvent*/)) + : this(attachableEventName, adder, schemaContext, invoker, new MemberReflector(null, adder, isEvent: true)) { } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs index e0090fd48e7..ed1c9909036 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs @@ -534,7 +534,7 @@ public static MemberMarkupInfo ForProperty( static MemberMarkupInfo ForSequence(object source, XamlMember property, SerializerContext context, bool isAttachable) { - var itemsInfo = ForSequenceItems(source, isAttachable ? null : property, property.Type, context, false /*allowReadOnly*/); + var itemsInfo = ForSequenceItems(source, isAttachable ? null : property, property.Type, context, allowReadOnly: false); if (itemsInfo != null && itemsInfo.Children.Count != 0) { return new MemberMarkupInfo @@ -1202,7 +1202,7 @@ void AddItemsProperty(object value, SerializerContext context, XamlType xamlType } else if (xamlType.IsCollection) { - propertyInfo = MemberMarkupInfo.ForSequenceItems(value, null, xamlType, context, true /*allowReadOnly*/); + propertyInfo = MemberMarkupInfo.ForSequenceItems(value, null, xamlType, context, allowReadOnly: true); } if (propertyInfo != null && propertyInfo.Children.Count != 0) @@ -2490,7 +2490,7 @@ public SerializerContext(XamlSchemaContext schemaContext, XamlObjectReaderSettin prefixToNamespaceMap = new Dictionary(); ReferenceTable = new ReferenceTable(null); this.schemaContext = schemaContext; - runtime = new ClrObjectRuntime(null, false /*isWriter*/); + runtime = new ClrObjectRuntime(null, isWriter: false); this.settings = settings; } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs index 09ca154acf1..bb041ab14b0 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs @@ -337,7 +337,7 @@ public XamlMember GetMember(string name) XamlMember result; if (!_reflector.Members.TryGetValue(name, out result) && !_reflector.Members.IsComplete) { - result = LookupMember(name, false /*skipReadOnlyCheck*/); + result = LookupMember(name, skipReadOnlyCheck: false); result = _reflector.Members.TryAdd(name, result); } return result; @@ -758,7 +758,7 @@ protected virtual XamlMember LookupContentProperty() { return null; } - return GetPropertyOrUnknown(contentPropertyName, false /*skipReadOnlyCheck*/); + return GetPropertyOrUnknown(contentPropertyName, skipReadOnlyCheck: false); } if (BaseType != null) { @@ -1433,7 +1433,7 @@ private XamlMember GetPropertyOrUnknown(string propertyName, bool skipReadOnlyCh XamlMember result = skipReadOnlyCheck ? LookupMember(propertyName, true) : GetMember(propertyName); if (result == null) { - result = new XamlMember(propertyName, this /*declaringType*/, false /*isAttachable*/); + result = new XamlMember(propertyName, declaringType: this, isAttachable: false); } return result; }