8000 Remove RunClassConstructor proxy from SecurityHelper (#9893) · dotnet/wpf@bc5e56c · GitHub
[go: up one dir, main page]

Skip to content

Commit bc5e56c

Browse files
authored
Remove RunClassConstructor proxy from SecurityHelper (#9893)
1 parent fc61e57 commit bc5e56c

File tree

8 files changed

+22
-42
lines changed

8 files changed

+22
-42
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/Baml2006/Baml2006Reader.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using MS.Internal;
1717
using System.Globalization;
1818
using XamlReaderHelper = System.Windows.Markup.XamlReaderHelper;
19+
using System.Runtime.CompilerServices;
1920

2021
namespace System.Windows.Baml2006
2122
{
@@ -1377,7 +1378,7 @@ private void Process_Property()
13771378
// Force load the Statics by walking up the hierarchy and running class constructors
13781379
while (null != currentType)
13791380
{
1380-
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
1381+
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
13811382
currentType = currentType.BaseType;
13821383
}
13831384

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/RoutedEventConverter.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
5+
using System.Xaml;
66
using System.ComponentModel;
77
using System.Globalization;
8-
9-
using System.Windows;
108
using System.Collections.Generic;
11-
using System.Xaml;
9+
using System.Runtime.CompilerServices;
1210

1311
namespace System.Windows.Markup
1412
{
@@ -114,7 +112,7 @@ public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext,
114112
// Force load the Statics by walking up the hierarchy and running class constructors
115113
while (null != currentType)
116114
{
117-
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
115+
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
118116
currentType = currentType.BaseType;
119117
}
120118

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/RoutedEventValueSerializer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
// Contents: Value serializer for the RoutedEvent class
77
//
88

9-
using System;
109
using System.Collections.Generic;
11-
using System.Text;
10+
using System.Runtime.CompilerServices;
1211

1312
namespace System.Windows.Markup
1413
{
@@ -45,7 +44,7 @@ static void ForceTypeConstructors(Type currentType)
4544
// Force load the Statics by walking up the hierarchy and running class constructors
4645
while (currentType != null && !initializedTypes.ContainsKey(currentType))
4746
{
48-
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
47+
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
4948
initializedTypes[currentType] = currentType;
5049
currentType = currentType.BaseType;
5150
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using System.Reflection;
2020

2121
using MS.Utility;
22-
using System.Security;
2322
using System.Text;
2423
using System.ComponentModel.Design.Serialization;
2524
using System.Globalization;
@@ -34,6 +33,7 @@
3433
using System.Xaml.Permissions;
3534
using System.Windows.Navigation;
3635
using MS.Internal.Xaml.Context;
36+
using System.Runtime.CompilerServices;
3737

3838
namespace System.Windows.Markup
3939
{
@@ -943,7 +943,7 @@ internal static object Load(
943943

944944
// In some cases, the application constructor is not run prior to loading,
945945
// causing the loader not to recognize URIs beginning with "pack:" or "application:".
946-
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(typeof(System.Windows.Application));
946+
RuntimeHelpers.RunClassConstructor(typeof(Application).TypeHandle);
947947

948948
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXamlBaml | F438 EventTrace.Keyword.KeywordPerf, EventTrace.Event.WClientParseXamlBegin, parserContext.BaseUri);
949949

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,21 @@
1010
using System;
1111
using System.Xml;
1212
using System.IO;
13+
using MS.Utility;
1314
using System.Text;
1415
using System.Collections;
1516
using System.Collections.Generic;
1617
using System.Globalization;
1718
using System.ComponentModel;
1819
using System.Collections.Specialized;
20+
using System.Runtime.CompilerServices;
1921
using System.Diagnostics;
2022
using System.Reflection;
21-
using MS.Utility;
2223

2324
#if !PBTCOMPILER
2425

25-
using System.Windows;
26-
using System.Windows.Markup;
27-
using System.Windows.Resources;
28-
using System.Windows.Threading;
29-
using SecurityHelper=MS.Internal.PresentationFramework.SecurityHelper;
3026
using MS.Internal; // CriticalExceptions
3127

32-
#else
33-
34-
using System.Runtime.CompilerServices;
35-
3628
#endif
3729

3830
// Disabling 1634 and 1691:
@@ -2010,7 +2002,7 @@ internal RoutedEvent RoutedEventFromName(
20102002
// Force load the Statics by walking up the hierarchy and running class constructors
20112003
while (null != currentType)
20122004
{
2013-
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType);
2005+
RuntimeHelpers.RunClassConstructor(currentType.TypeHandle);
20142006
currentType = GetCachedBaseType(currentType);
20152007
}
20162008

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using MS.Internal.PresentationFramework; // SafeSecurityHelper
3737
using System.Windows.Baml2006;
3838
using System.Xaml.Permissions;
39+
using System.Runtime.CompilerServices;
3940

4041
// Disable pragma warnings to enable PREsharp pragmas
4142
#pragma warning disable 1634, 1691
@@ -819,7 +820,7 @@ private void LoadExternalAssembly(bool classic, bool generic, out Assembly assem
819820
Type knownTypeHelper = assembly.GetType("Microsoft.Windows.Themes.KnownTypeHelper");
820821
if (knownTypeHelper != null)
821822
{
822-
MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(knownTypeHelper);
823+
RuntimeHelpers.RunClassConstructor(knownTypeHelper.TypeHandle);
823824
}
824825
}
825826
#pragma warning restore 6502

src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ internal static int MapUrlToZoneWrapper(Uri uri)
118118
}
119119
#endif
120120

121-
122-
#if WINDOWS_BASE
123-
internal static void RunClassConstructor(Type t)
124-
{
125-
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(t.TypeHandle);
126-
}
127-
128-
#endif // WINDOWS_BASE
129-
130121
#if DRT
131122
/// <remarks> The LinkDemand on Marshal.SizeOf() was removed in v4. </remarks>
132123
internal static int SizeOf(Type t)

src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyProperty.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
5+
using MS.Utility;
6+
using MS.Internal;
7+
using System.Threading;
68
using System.Collections;
7-
using System.Collections.Generic;
89
using System.Diagnostics;
9-
using System.Threading;
10-
using System.Globalization;
1110
using System.ComponentModel;
12-
using System.Windows.Markup;// For ValueSerializerAttribute
13-
using System.Windows.Threading; // For DispatcherObject
14-
using MS.Utility;
11+
using System.Windows.Markup; // For ValueSerializerAttribute
1512
using MS.Internal.WindowsBase;
16-
using System.Reflection; // for IsInstanceOfType
17-
using MS.Internal;
13+
using System.Windows.Threading; // For DispatcherObject
14+
using System.Collections.Generic;
15+
using System.Runtime.CompilerServices;
1816

1917
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
2018

@@ -977,7 +975,7 @@ internal static DependencyProperty FromName(string name, Type ownerType)
977975
while (ownerType != null)
978976
{
979977
// Ensure static constructor of type has run
980-
SecurityHelper.RunClassConstructor(ownerType);
978+
RuntimeHelpers.RunClassConstructor(ownerType.TypeHandle);
981979

982980
// Locate property
983981
FromNameKey key = new(name, ownerType);

0 commit comments

Comments
 (0)
0