Remove RunClassConstructor proxy from SecurityHelper (#9893)

This commit is contained in:
h3xds1nz 2024-10-19 15:38:32 +02:00 коммит произвёл GitHub
Родитель fc61e57ca9
Коммит bc5e56c1d2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
8 изменённых файлов: 24 добавлений и 44 удалений

Просмотреть файл

@ -16,6 +16,7 @@ using System.Windows.Media;
using MS.Internal;
using System.Globalization;
using XamlReaderHelper = System.Windows.Markup.XamlReaderHelper;
using System.Runtime.CompilerServices;
namespace System.Windows.Baml2006
{
@ -1377,7 +1378,7 @@ namespace System.Windows.Baml2006
// Force load the Statics by walking up the hierarchy and running class constructors
while (null != currentType)
{
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
currentType = currentType.BaseType;
}

Просмотреть файл

@ -2,13 +2,11 @@
// 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.Xaml;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Collections.Generic;
using System.Xaml;
using System.Runtime.CompilerServices;
namespace System.Windows.Markup
{
@ -114,7 +112,7 @@ namespace System.Windows.Markup
// Force load the Statics by walking up the hierarchy and running class constructors
while (null != currentType)
{
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
currentType = currentType.BaseType;
}

Просмотреть файл

@ -6,9 +6,8 @@
// Contents: Value serializer for the RoutedEvent class
//
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.CompilerServices;
namespace System.Windows.Markup
{
@ -45,7 +44,7 @@ namespace System.Windows.Markup
// Force load the Statics by walking up the hierarchy and running class constructors
while (currentType != null && !initializedTypes.ContainsKey(currentType))
{
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
initializedTypes[currentType] = currentType;
currentType = currentType.BaseType;
}

Просмотреть файл

@ -19,7 +19,6 @@ using System.Diagnostics;
using System.Reflection;
using MS.Utility;
using System.Security;
using System.Text;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
@ -34,6 +33,7 @@ using System.Xaml;
using System.Xaml.Permissions;
using System.Windows.Navigation;
using MS.Internal.Xaml.Context;
using System.Runtime.CompilerServices;
namespace System.Windows.Markup
{
@ -943,7 +943,7 @@ namespace System.Windows.Markup
// In some cases, the application constructor is not run prior to loading,
// causing the loader not to recognize URIs beginning with "pack:" or "application:".
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(typeof(System.Windows.Application));
RuntimeHelpers.RunClassConstructor(typeof(Application).TypeHandle);
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXamlBaml | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WClientParseXamlBegin, parserContext.BaseUri);

Просмотреть файл

@ -10,29 +10,21 @@
using System;
using System.Xml;
using System.IO;
using MS.Utility;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.ComponentModel;
using System.Collections.Specialized;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Reflection;
using MS.Utility;
#if !PBTCOMPILER
using System.Windows;
using System.Windows.Markup;
using System.Windows.Resources;
using System.Windows.Threading;
using SecurityHelper=MS.Internal.PresentationFramework.SecurityHelper;
using MS.Internal; // CriticalExceptions
#else
using System.Runtime.CompilerServices;
#endif
// Disabling 1634 and 1691:
@ -2010,7 +2002,7 @@ namespace System.Windows.Markup
// Force load the Statics by walking up the hierarchy and running class constructors
while (null != currentType)
{
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
currentType = GetCachedBaseType(currentType);
}

Просмотреть файл

@ -36,6 +36,7 @@ using MS.Internal.Interop;
using MS.Internal.PresentationFramework; // SafeSecurityHelper
using System.Windows.Baml2006;
using System.Xaml.Permissions;
using System.Runtime.CompilerServices;
// Disable pragma warnings to enable PREsharp pragmas
#pragma warning disable 1634, 1691
@ -819,7 +820,7 @@ namespace System.Windows
Type knownTypeHelper = assembly.GetType("Microsoft.Windows.Themes.KnownTypeHelper");
if (knownTypeHelper != null)
{
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(knownTypeHelper);
RuntimeHelpers.RunClassConstructor(knownTypeHelper.TypeHandle);
}
}
#pragma warning restore 6502

Просмотреть файл

@ -118,15 +118,6 @@ internal static class SecurityHelper
}
#endif
#if WINDOWS_BASE
internal static void RunClassConstructor(Type t)
{
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(t.TypeHandle);
}
#endif // WINDOWS_BASE
#if DRT
/// <remarks> The LinkDemand on Marshal.SizeOf() was removed in v4. </remarks>
internal static int SizeOf(Type t)

Просмотреть файл

@ -2,19 +2,17 @@
// 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;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Globalization;
using System.ComponentModel;
using System.Windows.Markup;// For ValueSerializerAttribute
using System.Windows.Threading; // For DispatcherObject
using MS.Utility;
using MS.Internal.WindowsBase;
using System.Reflection; // for IsInstanceOfType
using MS.Internal;
using System.Threading;
using System.Collections;
using System.Diagnostics;
using System.ComponentModel;
using System.Windows.Markup; // For ValueSerializerAttribute
using MS.Internal.WindowsBase;
using System.Windows.Threading; // For DispatcherObject
using System.Collections.Generic;
using System.Runtime.CompilerServices;
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
@ -977,7 +975,7 @@ namespace System.Windows
while (ownerType != null)
{
// Ensure static constructor of type has run
SecurityHelper.RunClassConstructor(ownerType);
RuntimeHelpers.RunClassConstructor(ownerType.TypeHandle);
// Locate property
FromNameKey key = new(name, ownerType);