Skip to content

Commit a3901c0

Browse files
Remove SecurityCriticalDataForMultipleGetAndSet (#6342)
1 parent 2ea94a4 commit a3901c0

File tree

3 files changed

+11
-80
lines changed

3 files changed

+11
-80
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
<Compile Include="$(WpfSharedDir)\RefAssemblyAttrs.cs" />
3737
<Compile Include="$(WpfSharedDir)\MS\Internal\FriendAccessAllowedAttribute.cs" />
3838
<Compile Include="$(WpfSharedDir)\MS\Internal\AppDomainShutdownMonitor.cs" />
39-
<Compile Include="$(WpfSharedDir)\MS\Internal\SecurityCriticalDataForMultipleGetAndSet.cs" />
4039
<Compile Include="$(WpfSharedDir)\MS\Internal\SecurityHelper.cs" />
4140
<Compile Include="$(WpfSharedDir)\MS\Internal\SafeSecurityHelper.cs" />
4241
<Compile Include="$(WpfSharedDir)\MS\Internal\SafeSecurityHelperAvalon.cs" />

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/PresentationSource.cs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,14 @@ protected void RootChanged(Visual oldRoot, Visual newRoot)
448448
// Always clear the RootSourceProperty on the old root.
449449
if (oldRoot != null)
450450
{
451-
oldSource = CriticalGetPresentationSourceFromElement(oldRoot, RootSourceProperty);
451+
oldSource = (PresentationSource)oldRoot.GetValue(RootSourceProperty);
452452
oldRoot.ClearValue(RootSourceProperty);
453453
}
454454

455455
// Always set the SourceProperty on the new root.
456456
if (newRoot != null)
457457
{
458-
newRoot.SetValue(RootSourceProperty, new SecurityCriticalDataForMultipleGetAndSet<PresentationSource>(this));
458+
newRoot.SetValue(RootSourceProperty, this);
459459
}
460460

461461
UIElement oldRootUIElement = oldRoot as UIElement;
@@ -493,7 +493,7 @@ protected void RootChanged(Visual oldRoot, Visual newRoot)
493493
// same context as this presentation source.
494494
if (element.Dispatcher == Dispatcher)
495495
{
496-
PresentationSource testSource = CriticalGetPresentationSourceFromElement(element,CachedSourceProperty);
496+
PresentationSource testSource = (PresentationSource)element.GetValue(CachedSourceProperty);
497497
// 1) If we are removing the rootvisual, then fire on any node whos old
498498
// PresetationSource was the oldSource.
499499
// 2) If we are attaching a rootvisual then fire on any node whos old
@@ -669,29 +669,11 @@ internal static WeakReferenceList CriticalCurrentSources
669669
}
670670
}
671671

672-
private static PresentationSource CriticalGetPresentationSourceFromElement(DependencyObject dObject,DependencyProperty dp)
673-
{
674-
PresentationSource testSource;
675-
SecurityCriticalDataForMultipleGetAndSet<PresentationSource> tempCriticalDataWrapper =
676-
(SecurityCriticalDataForMultipleGetAndSet < PresentationSource > )
677-
dObject.GetValue(dp);
678-
if (tempCriticalDataWrapper == null || tempCriticalDataWrapper.Value == null)
679-
{
680-
testSource = null;
681-
}
682-
else
683-
{
684-
testSource = tempCriticalDataWrapper.Value;
685-
}
686-
return testSource;
687-
}
688-
689672
private static void AddElementToWatchList(DependencyObject element)
690673
{
691674
if(_watchers.Add(element))
692675
{
693-
element.SetValue(CachedSourceProperty,new
694-
SecurityCriticalDataForMultipleGetAndSet<PresentationSource>(PresentationSource.FindSource(element)));
676+
element.SetValue(CachedSourceProperty, PresentationSource.FindSource(element));
695677
element.SetValue(GetsSourceChangedEventProperty, true);
696678
}
697679
}
@@ -727,7 +709,7 @@ private static PresentationSource FindSource(DependencyObject o, bool enable2DTo
727709
DependencyObject v = InputElement.GetRootVisual(o, enable2DTo3DTransition);
728710
if (v != null)
729711
{
730-
source = CriticalGetPresentationSourceFromElement(v, RootSourceProperty);
712+
source = (PresentationSource)v.GetValue(RootSourceProperty);
731713
}
732714
return source;
733715
}
@@ -739,10 +721,10 @@ private static bool UpdateSourceOfElement(DependencyObject doTarget,
739721
bool calledOut = false;
740722

741723
PresentationSource realSource = FindSource(doTarget);
742-
PresentationSource cachedSource = CriticalGetPresentationSourceFromElement(doTarget, CachedSourceProperty);
724+
PresentationSource cachedSource = (PresentationSource)doTarget.GetValue(CachedSourceProperty);
743725
if (cachedSource != realSource)
744726
{
745-
doTarget.SetValue(CachedSourceProperty, new SecurityCriticalDataForMultipleGetAndSet<PresentationSource>(realSource));
727+
doTarget.SetValue(CachedSourceProperty, realSource);
746728

747729
SourceChangedEventArgs args = new SourceChangedEventArgs(cachedSource, realSource);
748730

@@ -783,16 +765,16 @@ private static bool UpdateSourceOfElement(DependencyObject doTarget,
783765
// element in a tree to the source it is displayed in). Use the public
784766
// API FromVisual to get the source that a visual is displayed in.
785767
private static readonly DependencyProperty RootSourceProperty
786-
= DependencyProperty.RegisterAttached("RootSource", typeof(SecurityCriticalDataForMultipleGetAndSet<PresentationSource>), typeof(PresentationSource),
787-
new PropertyMetadata((SecurityCriticalDataForMultipleGetAndSet<PresentationSource>)null));
768+
= DependencyProperty.RegisterAttached("RootSource", typeof(PresentationSource), typeof(PresentationSource),
769+
new PropertyMetadata((PresentationSource)null));
788770

789771
// We use a private DP for the CachedSource (stored on the elements
790772
// that we are watching, so that we can send a change notification).
791773
// Use the public API FromVisual to get the source that a visual is
792774
// displayed in.
793775
private static readonly DependencyProperty CachedSourceProperty
794-
= DependencyProperty.RegisterAttached("CachedSource", typeof(SecurityCriticalDataForMultipleGetAndSet<PresentationSource>), typeof(PresentationSource),
795-
new PropertyMetadata((SecurityCriticalDataForMultipleGetAndSet<PresentationSource>)null));
776+
= DependencyProperty.RegisterAttached("CachedSource", typeof(PresentationSource), typeof(PresentationSource),
777+
new PropertyMetadata((PresentationSource)null));
796778

797779
// We use a private DP to mark elements that we are watchin.
798780
private static readonly DependencyProperty GetsSourceChangedEventProperty = DependencyProperty.RegisterAttached("IsBeingWatched", typeof(bool), typeof(PresentationSource), new PropertyMetadata((bool)false));

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

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)