Skip to content
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

[Cleanup] Use named arguments in System.Xaml #10061

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ internal XamlType ServiceProvider_ResolveXamlType(string qName)

internal AmbientPropertyValue ServiceProvider_GetFirstAmbientValue(IEnumerable<XamlType> ceilingTypes, XamlMember[] properties)
{
List<AmbientPropertyValue> valueList = FindAmbientValues(ceilingTypes, /*searchLiveStackOnly*/false, /*types*/null, properties, true);
List<AmbientPropertyValue> valueList = FindAmbientValues(ceilingTypes, searchLiveStackOnly: false, types: null, properties, true);
return (valueList.Count == 0) ? null : valueList[0];
}

Expand All @@ -180,7 +180,7 @@ internal object ServiceProvider_GetFirstAmbientValue(XamlType[] types)

internal IEnumerable<AmbientPropertyValue> ServiceProvider_GetAllAmbientValues(IEnumerable<XamlType> ceilingTypes, XamlMember[] properties)
{
List<AmbientPropertyValue> valueList = FindAmbientValues(ceilingTypes, /*searchLiveStackOnly*/false, /*types*/null, properties, /*stopAfterFirst*/ false);
List<AmbientPropertyValue> valueList = FindAmbientValues(ceilingTypes, searchLiveStackOnly: false, types: null, properties, stopAfterFirst: false);
return valueList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private XamlRuntime CreateRuntime(XamlObjectWriterSettings settings, XamlSchemaC
}
if (result is null)
{
result = new ClrObjectRuntime(runtimeSettings, true /*isWriter*/);
result = new ClrObjectRuntime(runtimeSettings, isWriter: true);
}
result.LineInfo = this;
return result;
Expand Down Expand Up @@ -604,7 +604,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.
Expand Down Expand Up @@ -1529,7 +1529,7 @@ private void Logic_ApplyCurrentPreconstructionPropertyValues(ObjectWriterContext
}
else
{
Logic_ApplyPropertyValue(ctx, prop, value, false /*onParent*/);
Logic_ApplyPropertyValue(ctx, prop, value, onParent: false);
}
}
}
Expand Down Expand Up @@ -2009,7 +2009,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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ private Dictionary<Type, DelegateCreator> DelegateCreators

internal DynamicMethodRuntime(XamlRuntimeSettings settings, XamlSchemaContext schemaContext,
XamlAccessLevel accessLevel)
: base(settings, true /*isWriter*/)
: base(settings, isWriter: true)
{
Debug.Assert(schemaContext is not null);
Debug.Assert(accessLevel is not null);
_schemaContext = schemaContext;
_localAssembly = Assembly.Load(accessLevel.AssemblyAccessToAssemblyName);
if (accessLevel.PrivateAccessToTypeName is not null)
{
_localType = _localAssembly.GetType(accessLevel.PrivateAccessToTypeName, true /*throwOnError*/);
_localType = _localAssembly.GetType(accessLevel.PrivateAccessToTypeName, throwOnError: true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,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;
}
Expand All @@ -83,14 +83,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 is 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 is null)
{
throw new XamlSchemaException(SR.Format(SR.AmbiguousDictionaryItemType, type));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,23 +754,23 @@ private List<MethodInfo> LookupStaticAdders(string name)
string adderName = KnownStrings.Add + name + KnownStrings.Handler;
MemberInfo[] adders = UnderlyingType.GetMember(adderName, MemberTypes.Method, AttachableProperties_BF);
List<MethodInfo> 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;
}

private List<MethodInfo> LookupStaticGetters(string name)
{
MemberInfo[] getters = UnderlyingType.GetMember(KnownStrings.Get + name, MemberTypes.Method, AttachableProperties_BF);
List<MethodInfo> 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;
}

private List<MethodInfo> LookupStaticSetters(string name)
{
MemberInfo[] setters = UnderlyingType.GetMember(KnownStrings.Set + name, MemberTypes.Method, AttachableProperties_BF);
List<MethodInfo> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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))
{
}

Expand All @@ -68,7 +68,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))
{
}

Expand All @@ -93,7 +93,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))
{
}

Expand Down Expand Up @@ -126,7 +126,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))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,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 is not null && itemsInfo.Children.Count != 0)
{
return new MemberMarkupInfo
Expand Down Expand Up @@ -1197,7 +1197,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 is not null && propertyInfo.Children.Count != 0)
Expand Down Expand Up @@ -2485,7 +2485,7 @@ public SerializerContext(XamlSchemaContext schemaContext, XamlObjectReaderSettin
prefixToNamespaceMap = new Dictionary<string, string>();
ReferenceTable = new ReferenceTable(null);
this.schemaContext = schemaContext;
runtime = new ClrObjectRuntime(null, false /*isWriter*/);
runtime = new ClrObjectRuntime(null, isWriter: false);
this.settings = settings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,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;
Expand Down Expand Up @@ -755,7 +755,7 @@ protected virtual XamlMember LookupContentProperty()
{
return null;
}
return GetPropertyOrUnknown(contentPropertyName, false /*skipReadOnlyCheck*/);
return GetPropertyOrUnknown(contentPropertyName, skipReadOnlyCheck: false);
}
if (BaseType is not null)
{
Expand Down Expand Up @@ -1430,7 +1430,7 @@ private XamlMember GetPropertyOrUnknown(string propertyName, bool skipReadOnlyCh
XamlMember result = skipReadOnlyCheck ? LookupMember(propertyName, true) : GetMember(propertyName);
if (result is null)
{
result = new XamlMember(propertyName, this /*declaringType*/, false /*isAttachable*/);
result = new XamlMember(propertyName, declaringType: this, isAttachable: false);
}
return result;
}
Expand Down