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 6057278ab35..21af3d22cf9 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 @@ -205,22 +205,6 @@ internal IEnumerable ServiceProvider_GetAllAmbientValues(I return valueList; } - private static void CheckAmbient(XamlMember xamlMember) - { - if (!xamlMember.IsAmbient) - { - throw new ArgumentException(SR.Get(SRID.NotAmbientProperty, xamlMember.DeclaringType.Name, xamlMember.Name), nameof(xamlMember)); - } - } - - private static void CheckAmbient(XamlType xamlType) - { - if (!xamlType.IsAmbient) - { - throw new ArgumentException(SR.Get(SRID.NotAmbientType, xamlType.Name), nameof(xamlType)); - } - } - internal XamlObjectWriterSettings ServiceProvider_GetSettings() { if (_settings == null) @@ -326,8 +310,15 @@ private List FindAmbientValues(IEnumerable ceili XamlMember[] properties, bool stopAfterFirst) { - ArrayHelper.ForAll(properties, CheckAmbient); - List ceilingTypes = ArrayHelper.ToList(ceilingTypesEnumerable); + foreach (XamlMember xamlMember in properties) + { + if (!xamlMember.IsAmbient) + { + throw new ArgumentException(SR.Get(SRID.NotAmbientProperty, xamlMember.DeclaringType.Name, xamlMember.Name), nameof(properties)); + } + } + + List ceilingTypes = ceilingTypesEnumerable != null ? new List(ceilingTypesEnumerable) : null; List retList = new List(); @@ -436,13 +427,18 @@ private List FindAmbientValues(IEnumerable ceili private List FindAmbientValues(XamlType[] types, bool stopAfterFirst) { - ArrayHelper.ForAll(types, CheckAmbient); + foreach (XamlType xamlType in types) + { + if (!xamlType.IsAmbient) + { + throw new ArgumentException(SR.Get(SRID.NotAmbientType, xamlType.Name), nameof(types)); + } + } List retList = new List(); // Start the search for ambient properties with the parent frame. ObjectWriterFrame frame = _stack.PreviousFrame; - ObjectWriterFrame lowerFrame = _stack.CurrentFrame; while (frame.Depth >= 1) { @@ -463,7 +459,6 @@ private List FindAmbientValues(XamlType[] types, bool stopAfterFirst) } } - lowerFrame = frame; frame = (ObjectWriterFrame)frame.Previous; Debug.Assert(frame != null); } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/XamlContext.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/XamlContext.cs index 431fa56ef5b..1f62a6cdfae 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/XamlContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/XamlContext.cs @@ -268,8 +268,12 @@ internal XamlType GetXamlType(XamlTypeName typeName, bool returnUnknownTypesOnFa XamlType[] typeArgs = null; if (typeName.HasTypeArgs) { - typeArgs = ArrayHelper.ConvertArrayType( - typeName.TypeArguments, GetXamlTypeOrUnknown); + List typeNames = typeName.TypeArgumentsList; + typeArgs = new XamlType[typeNames.Count]; + for (int i = 0; i < typeArgs.Length; i++) + { + typeArgs[i] = GetXamlTypeOrUnknown(typeNames[i]); + } } xamlType = new XamlType(typeName.Namespace, typeName.Name, typeArgs, SchemaContext); } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/ArrayHelper.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/ArrayHelper.cs deleted file mode 100644 index 7ca0c95091e..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/ArrayHelper.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; - -namespace System.Xaml -{ - internal static class ArrayHelper - { - internal static S[] ConvertArrayType(ICollection src, Func f) - { - if (src == null) - { - return null; - } - int len = src.Count, n = 0; - S[] dest = new S[len]; - foreach (R r in src) - { - dest[n++] = f(r); - } - return dest; - } - - internal static void ForAll(R[] src, Action f) - { - foreach (R r in src) - f(r); - } - - internal static List ToList(IEnumerable src) - { - return (src != null) - ? new List(src) - : null; - } - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlTypeName.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlTypeName.cs index 3aa8be55c17..2081c71bb50 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlTypeName.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlTypeName.cs @@ -66,6 +66,8 @@ public IList TypeArguments } } + internal List TypeArgumentsList => _typeArguments; + public override string ToString() { return ToString(null);