From a1aa355cf9863b5474037eb2a88d0e7a361fc06f Mon Sep 17 00:00:00 2001 From: ThomasGoulet73 Date: Fri, 4 Oct 2024 14:58:39 -0400 Subject: [PATCH] Remove SecurityCriticalDataForSet --- .../AppModel/SiteOfOriginContainer.cs | 39 +--- .../MS/internal/Shaping/UshortList2.cs | 10 +- .../TextFormatting/FullTextBreakpoint.cs | 26 +-- .../internal/TextFormatting/FullTextLine.cs | 44 ++--- .../TextFormatting/TextFormatterImp.cs | 2 +- .../MS/internal/TextFormatting/TextMetrics.cs | 4 +- .../TextFormatting/TextPenaltyModule.cs | 18 +- .../System/Windows/Input/AccessKeyManager.cs | 8 +- .../Windows/Input/Command/RoutedCommand.cs | 8 +- .../Windows/Input/InputProcessorProfiles.cs | 26 +-- .../Stylus/Common/RawStylusInputReport.cs | 6 +- .../Pointer/PointerInteractionEngine.cs | 24 +-- .../System/Windows/InterOp/HwndSource.cs | 34 ++-- .../System/Windows/InterOp/HwndTarget.cs | 6 +- .../System/Windows/Media/ColorContext.cs | 6 +- .../System/Windows/Media/CompositionTarget.cs | 36 ++-- .../Windows/Media/Imaging/WriteableBitmap.cs | 14 +- .../System/Windows/Media/PixelFormat.cs | 10 +- .../Media/textformatting/TextBreakpoint.cs | 2 +- .../textformatting/TextFormatterContext.cs | 42 ++-- .../Media/textformatting/TextLineBreak.cs | 24 +-- .../textformatting/TextParagraphCache.cs | 18 +- .../Windows/Navigation/BaseUriHelper.cs | 8 +- .../MS/Internal/AppModel/AssemblyFilter.cs | 18 +- .../MS/Internal/AppModel/BamlStream.cs | 6 +- .../MS/Internal/AppModel/Journaling.cs | 16 +- .../MS/Internal/AppModel/OleCmdHelper.cs | 120 ++++++------ .../RequestStatusBarUpdateEventArgs.cs | 10 +- .../MS/Internal/AppModel/ResourcePart.cs | 10 +- .../MS/Internal/IO/Packaging/ByteStream.cs | 16 +- .../MS/Internal/PtsHost/BaseParaClient.cs | 8 +- .../MS/Internal/PtsHost/CellParaClient.cs | 10 +- .../Internal/PtsHost/ContainerParaClient.cs | 36 ++-- .../MS/Internal/PtsHost/FigureParaClient.cs | 36 ++-- .../MS/Internal/PtsHost/FloaterParaClient.cs | 34 ++-- .../MS/Internal/PtsHost/ListParaClient.cs | 4 +- .../MS/Internal/PtsHost/PageBreakRecord.cs | 10 +- .../MS/Internal/PtsHost/PtsContext.cs | 46 ++--- .../MS/Internal/PtsHost/PtsHost.cs | 10 +- .../MS/Internal/PtsHost/PtsPage.cs | 56 +++--- .../MS/Internal/PtsHost/SubpageParaClient.cs | 34 ++-- .../MS/Internal/PtsHost/TableParaClient.cs | 2 +- .../MS/Internal/PtsHost/TextParaClient.cs | 114 +++++------ .../Internal/PtsHost/UIElementParaClient.cs | 2 +- .../Microsoft/Win32/CommonItemDialog.cs | 44 ++--- .../System/Windows/Application.cs | 6 +- .../Windows/Controls/Primitives/Popup.cs | 62 +++--- .../System/Windows/Controls/WebBrowser.cs | 22 +-- .../System/Windows/Documents/Hyperlink.cs | 22 +-- .../Windows/Documents/NLGSpellerInterop.cs | 2 +- .../System/Windows/Documents/TextStore.cs | 16 +- .../Windows/Documents/WinEventHandler.cs | 18 +- .../System/Windows/Interop/ActiveXHost.cs | 6 +- .../Windows/Interop/BrowserInteropHelper.cs | 32 +-- .../System/Windows/Interop/HwndHost.cs | 12 +- .../System/Windows/Markup/ParserContext.cs | 8 +- .../System/Windows/Window.cs | 20 +- .../Documents/Application/Document.cs | 12 +- .../Documents/Application/PackageDocument.cs | 6 +- .../RestrictedTransactionalPackage.cs | 4 +- .../Documents/Application/RightsController.cs | 18 +- .../Documents/Application/RightsDocument.cs | 18 +- .../RightsManagementSuppressedStream.cs | 6 +- .../Documents/Application/StreamDocument.cs | 27 ++- .../Documents/Application/StreamProxy.cs | 58 +++--- .../Application/TransactionalPackage.cs | 64 +++--- .../MS/Internal/Documents/DigitalSignature.cs | 60 +++--- .../Documents/DigitalSignatureProvider.cs | 42 ++-- .../DocumentApplicationDocumentViewer.cs | 14 +- .../Documents/DocumentSignatureManager.cs | 20 +- .../Documents/RightsManagementLicense.cs | 30 +-- .../Documents/RightsManagementManager.cs | 16 +- .../Documents/RightsManagementProvider.cs | 183 ++++++++---------- .../Documents/RightsManagementUser.cs | 8 +- .../MS/Internal/SecurityCriticalDataForSet.cs | 54 ------ .../src/Shared/MS/Utility/TraceProvider.cs | 18 +- .../src/Shared/MS/Win32/HwndWrapper.cs | 6 +- .../src/Shared/MS/Win32/NativeMethodsCLR.cs | 32 +-- .../src/System.Xaml/System.Xaml.csproj | 3 - .../UIAutomationTypes.csproj | 1 - .../src/WindowsBase/WindowsBase.csproj | 1 - 81 files changed, 938 insertions(+), 1046 deletions(-) delete mode 100644 src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityCriticalDataForSet.cs diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs index 121e3b03f23..99a55992f45 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs @@ -47,12 +47,8 @@ internal static Uri SiteOfOrigin { get { - Uri siteOfOrigin = SiteOfOriginForClickOnceApp; - if (siteOfOrigin == null) - { - // Calling FixFileUri because BaseDirectory will be a c:\\ style path - siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(System.AppDomain.CurrentDomain.BaseDirectory)); - } + // Calling FixFileUri because BaseDirectory will be a c:\\ style path + Uri siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(System.AppDomain.CurrentDomain.BaseDirectory)); #if DEBUG if (_traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( @@ -64,40 +60,16 @@ internal static Uri SiteOfOrigin return siteOfOrigin; } } - - // we separated this from the rest of the code because this code is used for media permission - // tests in partial trust but we want to do this without hitting the code path for regular exe's - // as in the code above. This will get hit for click once apps, xbaps, xaml and xps - internal static Uri SiteOfOriginForClickOnceApp - { - get - { - // The ClickOnce API, ApplicationDeployment.IsNetworkDeployed, determines whether the app is network-deployed - // by getting the ApplicationDeployment.CurrentDeployment property and catch the exception it can throw. - // The exception is a first chance exception and caught, but it often confuses developers, - // and can also have a perf impact. So we change to cache the value of SiteofOrigin in Dev10 to avoid the - // exception being thrown too many times. - // An alternative is to cache the value of ApplicationDeployment.IsNetworkDeployed. - if (_siteOfOriginForClickOnceApp == null) - { - _siteOfOriginForClickOnceApp = new SecurityCriticalDataForSet(null); - } - - Invariant.Assert(_siteOfOriginForClickOnceApp != null); - - return _siteOfOriginForClickOnceApp.Value.Value; - } - } internal static Uri BrowserSource { get { - return _browserSource.Value; + return _browserSource; } set { - _browserSource.Value = value; + _browserSource = value; } } @@ -244,8 +216,7 @@ protected override PackagePart GetPartCore(Uri uri) #region Private Members - private static SecurityCriticalDataForSet _browserSource; - private static SecurityCriticalDataForSet? _siteOfOriginForClickOnceApp; + private static Uri _browserSource; #endregion Private Members diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/UshortList2.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/UshortList2.cs index 538f6df1e26..e221e1c7bfc 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/UshortList2.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/UshortList2.cs @@ -277,13 +277,13 @@ internal unsafe class UnsafeUshortArray : UshortBuffer { private ushort* _array; - private SecurityCriticalDataForSet _arrayLength; + private int _arrayLength; internal UnsafeUshortArray(CheckedUShortPointer array, int arrayLength) { _array = array.Probe(0, arrayLength); - _arrayLength.Value = arrayLength; + _arrayLength = arrayLength; } @@ -291,19 +291,19 @@ public override ushort this[int index] { get { - Invariant.Assert(index >= 0 && index < _arrayLength.Value); + Invariant.Assert(index >= 0 && index < _arrayLength); return _array[index]; } set { - Invariant.Assert(index >= 0 && index < _arrayLength.Value); + Invariant.Assert(index >= 0 && index < _arrayLength); _array[index] = value; } } public override int Length { - get { return _arrayLength.Value; } + get { return _arrayLength; } } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextBreakpoint.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextBreakpoint.cs index 6af0c11e1bf..b7951378d98 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextBreakpoint.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextBreakpoint.cs @@ -37,8 +37,8 @@ namespace MS.Internal.TextFormatting internal sealed class FullTextBreakpoint : TextBreakpoint { private TextMetrics _metrics; // full text metrics - private SecurityCriticalDataForSet _ploline; // native object representing this break - private SecurityCriticalDataForSet _penaltyResource; // unsafe handle to the internal factors used to determines penalty of the break. By default, the lifetime of this resource is managed by _ploline. + private IntPtr _ploline; // native object representing this break + private IntPtr _penaltyResource; // unsafe handle to the internal factors used to determines penalty of the break. By default, the lifetime of this resource is managed by _ploline. private bool _isDisposed; // flag indicates whether this object is disposed private bool _isLineTruncated; // flag indicates whether the line produced at this breakpoint is truncated. @@ -85,7 +85,7 @@ out int bestFitIndex IntPtr previousBreakRecord = IntPtr.Zero; if (settings.PreviousLineBreak != null) - previousBreakRecord = settings.PreviousLineBreak.BreakRecord.Value; + previousBreakRecord = settings.PreviousLineBreak.BreakRecord; // need not consider marker as tab since marker does not affect line metrics and it wasnt drawn. fullText.SetTabs(context); @@ -95,7 +95,7 @@ out int bestFitIndex LsErr lserr = context.CreateBreaks( fullText.GetBreakpointInternalCp(firstCharIndex), previousBreakRecord, - paragraphCache.Ploparabreak.Value, // para breaking session + paragraphCache.Ploparabreak, // para breaking session penaltyRestriction, ref lsbreaks, out bestFitIndex @@ -179,10 +179,10 @@ int breakIndex &lsbreaks.plslinfoArray[breakIndex] ); - _ploline = new SecurityCriticalDataForSet(lsbreaks.pplolineArray[breakIndex]); + _ploline = lsbreaks.pplolineArray[breakIndex]; // keep the line penalty handle - _penaltyResource = new SecurityCriticalDataForSet(lsbreaks.plinepenaltyArray[breakIndex]); + _penaltyResource = lsbreaks.plinepenaltyArray[breakIndex]; if (lsbreaks.plslinfoArray[breakIndex].fForcedBreak != 0) _isLineTruncated = true; @@ -213,11 +213,11 @@ private FullTextBreakpoint() /// protected override void Dispose(bool disposing) { - if(_ploline.Value != IntPtr.Zero) + if(_ploline != IntPtr.Zero) { - UnsafeNativeMethods.LoDisposeLine(_ploline.Value, !disposing); - _ploline.Value = IntPtr.Zero; - _penaltyResource.Value = IntPtr.Zero; + UnsafeNativeMethods.LoDisposeLine(_ploline, !disposing); + _ploline = IntPtr.Zero; + _penaltyResource = IntPtr.Zero; _isDisposed = true; GC.KeepAlive(this); } @@ -237,7 +237,7 @@ public override TextLineBreak GetTextLineBreak() { throw new ObjectDisposedException(SR.TextBreakpointHasBeenDisposed); } - return _metrics.GetTextLineBreak(_ploline.Value); + return _metrics.GetTextLineBreak(_ploline); } @@ -249,14 +249,14 @@ public override TextLineBreak GetTextLineBreak() /// We would make a correspondent call to notify our unmanaged wrapper to release them from duty of managing this /// resource. /// - internal override SecurityCriticalDataForSet GetTextPenaltyResource() + internal override IntPtr GetTextPenaltyResource() { if (_isDisposed) { throw new ObjectDisposedException(SR.TextBreakpointHasBeenDisposed); } - LsErr lserr = UnsafeNativeMethods.LoRelievePenaltyResource(_ploline.Value); + LsErr lserr = UnsafeNativeMethods.LoRelievePenaltyResource(_ploline); if (lserr != LsErr.None) { TextFormatterContext.ThrowExceptionFromLsError(SR.Format(SR.RelievePenaltyResourceFailure, lserr), lserr); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextLine.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextLine.cs index 66c76a84158..0dc426f6ca2 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextLine.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextLine.cs @@ -49,8 +49,8 @@ internal class FullTextLine : TextLine private int _depthQueryMax; // maximum depth of reversals used in querying private int _paragraphWidth; // paragraph width private int _textMinWidthAtTrailing; // smallest text width excluding trailing whitespaces - private SecurityCriticalDataForSet _ploline; // actual LS line - private SecurityCriticalDataForSet _ploc; // actual LS context + private IntPtr _ploline; // actual LS line + private IntPtr _ploc; // actual LS context private Overhang _overhang; // overhang metrics private StatusFlags _statusFlags; // status flags of the line @@ -156,11 +156,11 @@ public override void Dispose() /// private void DisposeInternal(bool finalizing) { - if (_ploline.Value != System.IntPtr.Zero) + if (_ploline != System.IntPtr.Zero) { - UnsafeNativeMethods.LoDisposeLine(_ploline.Value, finalizing); + UnsafeNativeMethods.LoDisposeLine(_ploline, finalizing); - _ploline.Value = System.IntPtr.Zero; + _ploline = System.IntPtr.Zero; GC.KeepAlive(this); } } @@ -178,7 +178,7 @@ private FullTextLine(TextFormattingMode textFormattingMode, bool justify, double } _metrics = new TextMetrics(); _metrics._pixelsPerDip = pixelsPerDip; - _ploline = new SecurityCriticalDataForSet(IntPtr.Zero); + _ploline = IntPtr.Zero; } @@ -300,7 +300,7 @@ out lineWidths } } - _ploline.Value = ploline; + _ploline = ploline; // get the exception in context before it is released Exception callbackException = context.CallbackException; @@ -592,7 +592,7 @@ MatrixTransform antiInversion { Rect boundingBox = Rect.Empty; - if (_ploline.Value != System.IntPtr.Zero) + if (_ploline != System.IntPtr.Zero) { TextFormatterContext context; LsErr lserr = LsErr.None; @@ -603,7 +603,7 @@ MatrixTransform antiInversion { context = _metrics._formatter.AcquireContext( drawingState, - _ploc.Value + _ploc ); // set the collector and send the line to LS to draw @@ -614,7 +614,7 @@ MatrixTransform antiInversion LSPOINT lsRefOrigin = new LSPOINT(0, _metrics._baselineOffset); lserr = UnsafeNativeMethods.LoDisplayLine( - _ploline.Value, + _ploline, ref lsRefOrigin, 1, // 0 - opaque, 1 - transparent ref rect @@ -864,7 +864,7 @@ private CharacterHit CharacterHitFromDistance(int hitTestDistance) // assuming the first cp of the line CharacterHit characterHit = new CharacterHit(_cpFirst, 0); - if(_ploline.Value == IntPtr.Zero) + if(_ploline == IntPtr.Zero) { // Returning the first cp for the empty line return characterHit; @@ -999,7 +999,7 @@ private int DistanceFromCharacterHit(CharacterHit characterHit) { int hitTestDistance = 0; - if (_ploline.Value == IntPtr.Zero) + if (_ploline == IntPtr.Zero) { // Returning start of the line for empty line return hitTestDistance; @@ -1147,7 +1147,7 @@ CharacterHit characterHit TextFormatterImp.VerifyCaretCharacterHit(characterHit, _cpFirst, _metrics._cchLength); - if (_ploline.Value == System.IntPtr.Zero) + if (_ploline == System.IntPtr.Zero) { return characterHit; } @@ -1240,7 +1240,7 @@ CaretDirection direction TextFormatterImp.VerifyCaretCharacterHit(characterHit, _cpFirst, _metrics._cchLength); - if (_ploline.Value == IntPtr.Zero) + if (_ploline == IntPtr.Zero) { return characterHit; } @@ -1517,7 +1517,7 @@ int textLength textLength = (_cpFirst + _metrics._cchLength - firstTextSourceCharacterIndex); } - if (_ploline.Value == IntPtr.Zero) + if (_ploline == IntPtr.Zero) { return CreateDegenerateBounds(); } @@ -2129,11 +2129,11 @@ public override IEnumerable GetIndexedGlyphRuns() IEnumerable result = null; - if (_ploline.Value != System.IntPtr.Zero) + if (_ploline != System.IntPtr.Zero) { TextFormatterContext context = _metrics._formatter.AcquireContext( new DrawingState(null, new Point(0, 0), null, this), - _ploc.Value + _ploc ); // @@ -2143,7 +2143,7 @@ public override IEnumerable GetIndexedGlyphRuns() LSPOINT point = new LSPOINT(0, 0); lserr = UnsafeNativeMethods.LoEnumLine( - _ploline.Value, // line + _ploline, // line false, // reverse enumeration false, // geometry needed ref point // starting point @@ -2452,7 +2452,7 @@ private void QueryLinePointPcp( out LsTextCell lsTextCell ) { - Debug.Assert(_ploline.Value != IntPtr.Zero); + Debug.Assert(_ploline != IntPtr.Zero); LsErr lserr = LsErr.None; lsTextCell = new LsTextCell(); @@ -2462,7 +2462,7 @@ out LsTextCell lsTextCell { LSPOINT pt = new LSPOINT((int)ptQuery.X, (int)ptQuery.Y); lserr = UnsafeNativeMethods.LoQueryLinePointPcp( - _ploline.Value, + _ploline, ref pt, subLineInfo.Length, (System.IntPtr)plsqsubl, @@ -2505,7 +2505,7 @@ private void QueryLineCpPpoint( out LsTextCell lsTextCell ) { - Debug.Assert(_ploline.Value != IntPtr.Zero); + Debug.Assert(_ploline != IntPtr.Zero); LsErr lserr = LsErr.None; @@ -2519,7 +2519,7 @@ out LsTextCell lsTextCell fixed(LsQSubInfo* plsqsubl = subLineInfo) { lserr = UnsafeNativeMethods.LoQueryLineCpPpoint( - _ploline.Value, + _ploline, lscpValidQuery, subLineInfo.Length, (System.IntPtr)plsqsubl, diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs index 0cd1a1ee3d3..5c67fea74e3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs @@ -541,7 +541,7 @@ IntPtr ploc if(context.Owner == null) break; } - else if (ploc == context.Ploc.Value) + else if (ploc == context.Ploc) { // LS requires that we use the exact same context for line // destruction or hittesting (part of the reason is that LS diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextMetrics.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextMetrics.cs index ee70a789e2e..fa07f434e7a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextMetrics.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextMetrics.cs @@ -318,10 +318,10 @@ internal TextLineBreak GetTextLineBreak(IntPtr ploline) { return new TextLineBreak( _lastRun.TextModifierScope, - new SecurityCriticalDataForSet(pbreakrec) + pbreakrec ); } - return (pbreakrec != IntPtr.Zero) ? new TextLineBreak(null, new SecurityCriticalDataForSet(pbreakrec)) : null; + return (pbreakrec != IntPtr.Zero) ? new TextLineBreak(null, pbreakrec) : null; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextPenaltyModule.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextPenaltyModule.cs index 0068e4e78b0..0f651903097 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextPenaltyModule.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextPenaltyModule.cs @@ -32,23 +32,23 @@ namespace MS.Internal.TextFormatting /// internal sealed class TextPenaltyModule : IDisposable { - private SecurityCriticalDataForSet _ploPenaltyModule; // Pointer to LS penalty module - private bool _isDisposed; + private IntPtr _ploPenaltyModule; // Pointer to LS penalty module + private bool _isDisposed; /// /// This constructor is called by PInvoke when returning the critical handle /// - internal TextPenaltyModule(SecurityCriticalDataForSet ploc) + internal TextPenaltyModule(IntPtr ploc) { IntPtr ploPenaltyModule; - LsErr lserr = UnsafeNativeMethods.LoAcquirePenaltyModule(ploc.Value, out ploPenaltyModule); + LsErr lserr = UnsafeNativeMethods.LoAcquirePenaltyModule(ploc, out ploPenaltyModule); if (lserr != LsErr.None) { TextFormatterContext.ThrowExceptionFromLsError(SR.Format(SR.AcquirePenaltyModuleFailure, lserr), lserr); } - _ploPenaltyModule.Value = ploPenaltyModule; + _ploPenaltyModule = ploPenaltyModule; } @@ -73,10 +73,10 @@ public void Dispose() private void Dispose(bool disposing) { - if (_ploPenaltyModule.Value != IntPtr.Zero) + if (_ploPenaltyModule != IntPtr.Zero) { - UnsafeNativeMethods.LoDisposePenaltyModule(_ploPenaltyModule.Value); - _ploPenaltyModule.Value = IntPtr.Zero; + UnsafeNativeMethods.LoDisposePenaltyModule(_ploPenaltyModule); + _ploPenaltyModule = IntPtr.Zero; _isDisposed = true; GC.KeepAlive(this); } @@ -96,7 +96,7 @@ internal IntPtr DangerousGetHandle() } IntPtr penaltyModuleInternalHandle; - LsErr lserr = UnsafeNativeMethods.LoGetPenaltyModuleInternalHandle(_ploPenaltyModule.Value, out penaltyModuleInternalHandle); + LsErr lserr = UnsafeNativeMethods.LoGetPenaltyModuleInternalHandle(_ploPenaltyModule, out penaltyModuleInternalHandle); if (lserr != LsErr.None) TextFormatterContext.ThrowExceptionFromLsError(SR.Format(SR.GetPenaltyModuleHandleFailure, lserr), lserr); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/AccessKeyManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/AccessKeyManager.cs index c2e97d813f4..c367da0aca4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/AccessKeyManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/AccessKeyManager.cs @@ -848,12 +848,12 @@ internal AccessKeyEventArgs(string key, bool isMultiple, bool userInitiated) { _key = key; _isMultiple = isMultiple; - _userInitiated = new SecurityCriticalDataForSet(userInitiated); + _userInitiated = userInitiated; } internal void ClearUserInitiated() { - _userInitiated.Value = false; + _userInitiated = false; } /// /// The key that was pressed which invoked this access key @@ -875,12 +875,12 @@ public bool IsMultiple internal bool UserInitiated { - get { return _userInitiated.Value; } + get { return _userInitiated; } } private string _key; private bool _isMultiple; - private SecurityCriticalDataForSet_userInitiated; + private bool _userInitiated; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs index aa33ac0f254..4be6c5092f7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs @@ -444,17 +444,17 @@ private void WritePrivateFlag(PrivateFlags bit, bool value) { if (value) { - _flags.Value |= bit; + _flags |= bit; } else { - _flags.Value &= ~bit; + _flags &= ~bit; } } private bool ReadPrivateFlag(PrivateFlags bit) { - return (_flags.Value & bit) != 0; + return (_flags & bit) != 0; } #endregion PrivateMethods @@ -463,7 +463,7 @@ private bool ReadPrivateFlag(PrivateFlags bit) private string _name; - private MS.Internal.SecurityCriticalDataForSet _flags; + private PrivateFlags _flags; private enum PrivateFlags : byte { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfiles.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfiles.cs index 6e68a2b5df4..7c3dafa71cb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfiles.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfiles.cs @@ -47,7 +47,7 @@ internal class InputProcessorProfiles internal InputProcessorProfiles() { // _ipp is a ValueType, hence no need for new. - _ipp.Value = null; + _ipp = null; _cookie = UnsafeNativeMethods.TF_INVALID_COOKIE; } @@ -66,11 +66,11 @@ internal bool Initialize(object o) { Debug.Assert(Thread.CurrentThread.GetApartmentState() == ApartmentState.STA, "Initialize called on MTA thread!"); - Debug.Assert(_ipp.Value == null, "Initialize called twice"); + Debug.Assert(_ipp == null, "Initialize called twice"); - _ipp.Value = InputProcessorProfilesLoader.Load(); + _ipp = InputProcessorProfilesLoader.Load(); - if (_ipp.Value == null) + if (_ipp == null) { return false; } @@ -84,11 +84,11 @@ internal bool Initialize(object o) /// internal void Uninitialize() { - Debug.Assert(_ipp.Value != null, "Uninitialize called without initializing"); + Debug.Assert(_ipp != null, "Uninitialize called without initializing"); UnadviseNotifySink(); - Marshal.ReleaseComObject(_ipp.Value); - _ipp.Value = null; + Marshal.ReleaseComObject(_ipp); + _ipp = null; } #endregion Internal Methods @@ -106,9 +106,9 @@ internal short CurrentInputLanguage { set { - if (_ipp.Value != null) + if (_ipp != null) { - if (_ipp.Value.ChangeCurrentLanguage(value) != 0) + if (_ipp.ChangeCurrentLanguage(value) != 0) { // // Under WinXP or W2K3, ITfInputProcessorProfiles::ChangeCurrentLanguage() fails @@ -151,7 +151,7 @@ internal ArrayList InputLanguageList // ITfInputProcessorProfiles::GetLanguageList returns the pointer that was allocated by // CoTaskMemAlloc(). - _ipp.Value.GetLanguageList(out langids, out nCount); + _ipp.GetLanguageList(out langids, out nCount); ArrayList arrayLang = new ArrayList(); @@ -184,7 +184,7 @@ private void AdviseNotifySink(object o) { Debug.Assert(_cookie == UnsafeNativeMethods.TF_INVALID_COOKIE, "Cookie is already set."); - UnsafeNativeMethods.ITfSource source = _ipp.Value as UnsafeNativeMethods.ITfSource; + UnsafeNativeMethods.ITfSource source = _ipp as UnsafeNativeMethods.ITfSource; // workaround because I can't pass a ref to a readonly constant Guid guid = UnsafeNativeMethods.IID_ITfLanguageProfileNotifySink; @@ -199,7 +199,7 @@ private void UnadviseNotifySink() { Debug.Assert(_cookie != UnsafeNativeMethods.TF_INVALID_COOKIE, "Cookie is not set."); - UnsafeNativeMethods.ITfSource source = _ipp.Value as UnsafeNativeMethods.ITfSource; + UnsafeNativeMethods.ITfSource source = _ipp as UnsafeNativeMethods.ITfSource; source.UnadviseSink(_cookie); @@ -213,7 +213,7 @@ private void UnadviseNotifySink() //------------------------------------------------------ // The reference to ITfInputProcessorProfile. - private SecurityCriticalDataForSet _ipp; + private UnsafeNativeMethods.ITfInputProcessorProfiles _ipp; // The cookie for the advised sink. private int _cookie; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInputReport.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInputReport.cs index afd8f8bb0fa..d515d8f5508 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInputReport.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInputReport.cs @@ -63,7 +63,7 @@ internal class RawStylusInputReport : InputReport /// /// The raw input used for stylus plugins /// - SecurityCriticalDataForSet _rawStylusInput; + RawStylusInput _rawStylusInput; /// /// Set from StylusDevice.Synchronize. @@ -82,9 +82,9 @@ internal class RawStylusInputReport : InputReport internal RawStylusInput RawStylusInput { - get { return _rawStylusInput.Value; } + get { return _rawStylusInput; } - set { _rawStylusInput.Value = value; } + set { _rawStylusInput = value; } } internal bool Synchronized diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Pointer/PointerInteractionEngine.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Pointer/PointerInteractionEngine.cs index 4c82dd20721..d270bda3264 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Pointer/PointerInteractionEngine.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Pointer/PointerInteractionEngine.cs @@ -99,7 +99,7 @@ private enum HoverState /// /// Holds the reference to the interaction context /// - private SecurityCriticalDataForSet _interactionContext = new SecurityCriticalDataForSet(IntPtr.Zero); + private IntPtr _interactionContext = IntPtr.Zero; /// /// The stylus device that owns this interaction engine. @@ -177,33 +177,33 @@ internal PointerInteractionEngine(PointerStylusDevice stylusDevice, List(interactionContext); + _interactionContext = interactionContext; if (configuration == null) { configuration = DefaultConfiguration; } - if (_interactionContext.Value != IntPtr.Zero) + if (_interactionContext != IntPtr.Zero) { // We do not want to filter specific pointers - UnsafeNativeMethods.SetPropertyInteractionContext(_interactionContext.Value, + UnsafeNativeMethods.SetPropertyInteractionContext(_interactionContext, UnsafeNativeMethods.INTERACTION_CONTEXT_PROPERTY.INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, Convert.ToUInt32(false)); // Use screen measurements here as this makes certain math easier for us - UnsafeNativeMethods.SetPropertyInteractionContext(_interactionContext.Value, + UnsafeNativeMethods.SetPropertyInteractionContext(_interactionContext, UnsafeNativeMethods.INTERACTION_CONTEXT_PROPERTY.INTERACTION_CONTEXT_PROPERTY_MEASUREMENT_UNITS, (UInt32)UnsafeNativeMethods.InteractionMeasurementUnits.Screen); // Configure the context - UnsafeNativeMethods.SetInteractionConfigurationInteractionContext(_interactionContext.Value, (uint)configuration.Count, configuration.ToArray()); + UnsafeNativeMethods.SetInteractionConfigurationInteractionContext(_interactionContext, (uint)configuration.Count, configuration.ToArray()); // Store the delegate so it can be accessed over time _callbackDelegate = Callback; // Register for interaction notifications - UnsafeNativeMethods.RegisterOutputCallbackInteractionContext(_interactionContext.Value, _callbackDelegate); + UnsafeNativeMethods.RegisterOutputCallbackInteractionContext(_interactionContext, _callbackDelegate); } } @@ -222,10 +222,10 @@ protected virtual void Dispose(bool disposing) if (!_disposed) { // We must destroy the interaction context when done - if (_interactionContext.Value != IntPtr.Zero) + if (_interactionContext != IntPtr.Zero) { - UnsafeNativeMethods.DestroyInteractionContext(_interactionContext.Value); - _interactionContext.Value = IntPtr.Zero; + UnsafeNativeMethods.DestroyInteractionContext(_interactionContext); + _interactionContext = IntPtr.Zero; } _disposed = true; @@ -257,7 +257,7 @@ internal void Update(RawStylusInputReport rsir) try { // Queue up the latest message for processing - UnsafeNativeMethods.BufferPointerPacketsInteractionContext(_interactionContext.Value, 1, new UnsafeNativeMethods.POINTER_INFO[] { _stylusDevice.CurrentPointerInfo }); + UnsafeNativeMethods.BufferPointerPacketsInteractionContext(_interactionContext, 1, new UnsafeNativeMethods.POINTER_INFO[] { _stylusDevice.CurrentPointerInfo }); // Hover processing should occur directly from message receipt. // Do this prior to the IC engine processing so HoverEnter/Leave has priority. @@ -267,7 +267,7 @@ internal void Update(RawStylusInputReport rsir) DetectFlick(rsir); // Fire processing of the queued messages - UnsafeNativeMethods.ProcessBufferedPacketsInteractionContext(_interactionContext.Value); + UnsafeNativeMethods.ProcessBufferedPacketsInteractionContext(_interactionContext); } catch { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs index c0e200cc4af..9e0aa578c40 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs @@ -556,7 +556,7 @@ public override Visual RootVisual { if (_isDisposed) return null; - return (_rootVisual.Value); + return (_rootVisual); } set { @@ -570,29 +570,29 @@ private Visual RootVisualInternal { set { - if (_rootVisual.Value != value) + if (_rootVisual != value) { - Visual oldRoot = _rootVisual.Value; + Visual oldRoot = _rootVisual; if(value != null) { - _rootVisual.Value = value; + _rootVisual = value; - if(_rootVisual.Value is UIElement) + if(_rootVisual is UIElement) { - ((UIElement)(_rootVisual.Value)).LayoutUpdated += new EventHandler(OnLayoutUpdated); + ((UIElement)(_rootVisual)).LayoutUpdated += new EventHandler(OnLayoutUpdated); } if (_hwndTarget != null && _hwndTarget.IsDisposed == false) { - _hwndTarget.RootVisual = _rootVisual.Value; + _hwndTarget.RootVisual = _rootVisual; } UIElement.PropagateResumeLayout(null, value); } else { - _rootVisual.Value = null; + _rootVisual = null; if (_hwndTarget != null && !_hwndTarget.IsDisposed) { _hwndTarget.RootVisual = null; @@ -609,7 +609,7 @@ private Visual RootVisualInternal UIElement.PropagateSuspendLayout(oldRoot); } - RootChanged(oldRoot, _rootVisual.Value); + RootChanged(oldRoot, _rootVisual); if (IsLayoutActive() == true) { @@ -633,7 +633,7 @@ private Visual RootVisualInternal // have been torn down. We just need to protect against that. if(_keyboard != null) { - _keyboard.Value.OnRootChanged(oldRoot, _rootVisual.Value); + _keyboard.Value.OnRootChanged(oldRoot, _rootVisual); } } @@ -794,7 +794,7 @@ internal override void OnLeaveMenuMode() /// private void OnLayoutUpdated(object obj, EventArgs args) { - UIElement root = _rootVisual.Value as UIElement; + UIElement root = _rootVisual as UIElement; if(root != null) { @@ -910,7 +910,7 @@ private NativeMethods.RECT AdjustWindowSize(Size newSize) // nearest int. Otherwise round the size up to the next int. private void RoundDeviceSize(ref Point size) { - UIElement root = _rootVisual.Value as UIElement; + UIElement root = _rootVisual as UIElement; if (root != null && root.SnapsToDevicePixels) { size = new Point(DoubleUtil.DoubleToInt(size.X), DoubleUtil.DoubleToInt(size.Y)); @@ -1022,7 +1022,7 @@ public SizeToContent SizeToContent private bool IsLayoutActive() { - if ((_rootVisual.Value is UIElement) && _hwndTarget!= null && _hwndTarget.IsDisposed == false) + if ((_rootVisual is UIElement) && _hwndTarget!= null && _hwndTarget.IsDisposed == false) { return true; } @@ -1040,7 +1040,7 @@ private void SetLayoutSize() Debug.Assert(_hwndTarget.IsDisposed == false, "HwndTarget is disposed"); UIElement rootUIElement = null; - rootUIElement = _rootVisual.Value as UIElement; + rootUIElement = _rootVisual as UIElement; if (rootUIElement == null) return; // InvalidateMeasure() call is necessary in the following scenario @@ -1203,7 +1203,7 @@ private IntPtr LayoutFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr l // during which almost anything could have happened that might // invalidate our checks. UIElement rootUIElement=null; - rootUIElement = _rootVisual.Value as UIElement; + rootUIElement = _rootVisual as UIElement; if (IsUsable && rootUIElement != null) { switch (message) @@ -1981,7 +1981,7 @@ protected virtual bool TabIntoCore(TraversalRequest request) ArgumentNullException.ThrowIfNull(request); - UIElement root =_rootVisual.Value as UIElement; + UIElement root =_rootVisual as UIElement; if(root != null) { // atanask: @@ -2822,7 +2822,7 @@ public void Dispose() private HwndTarget _hwndTarget; - private SecurityCriticalDataForSet _rootVisual; + private Visual _rootVisual; private Tuple _hooks; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs index e19a20280f2..800cb572e61 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs @@ -115,7 +115,7 @@ public class HwndTarget : CompositionTarget private MatrixTransform _worldTransform; - private SecurityCriticalDataForSet _renderModePreference = new SecurityCriticalDataForSet(RenderMode.Default); + private RenderMode _renderModePreference = RenderMode.Default; private NativeMethods.HWND _hWnd; @@ -660,7 +660,7 @@ public RenderMode RenderMode { get { - return _renderModePreference.Value; + return _renderModePreference; } // Note: We think it is safe to expose this in partial trust, but doing so would suggest @@ -674,7 +674,7 @@ public RenderMode RenderMode throw new System.ComponentModel.InvalidEnumArgumentException("value", (int)value, typeof(RenderMode)); } - _renderModePreference.Value = value; + _renderModePreference = value; InvalidateRenderMode(); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs index baa632cba8c..cf52afaac81 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs @@ -262,7 +262,7 @@ public Uri ProfileUri // If the user didn't give us the uri value, then the uri has // to be a file path because we got it from GetStandardColorSpaceProfile // - if (_isProfileUriNotFromUser.Value) + if (_isProfileUriNotFromUser) { Invariant.Assert(uri.IsFile); } @@ -511,7 +511,7 @@ private void Initialize(Uri profileUri, bool isStandardProfileUriNotFromUser) } _profileUri = new SecurityCriticalData(profileUri); - _isProfileUriNotFromUser = new SecurityCriticalDataForSet(isStandardProfileUriNotFromUser); + _isProfileUriNotFromUser = isStandardProfileUriNotFromUser; Stream profileStream = null; @@ -807,7 +807,7 @@ private void FromRawBytes(byte[] data, int dataLength, bool dontThrowException) private SecurityCriticalData _profileUri; - private SecurityCriticalDataForSet _isProfileUriNotFromUser; + private bool _isProfileUriNotFromUser; private AbbreviatedPROFILEHEADER _profileHeader; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CompositionTarget.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CompositionTarget.cs index 8e3ad335b80..88261e5ae6b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CompositionTarget.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CompositionTarget.cs @@ -94,9 +94,9 @@ internal virtual void CreateUCEResources(DUCE.Channel channel, DUCE.Channel outO /// internal virtual void ReleaseUCEResources(DUCE.Channel channel, DUCE.Channel outOfBandChannel) { - if (_rootVisual.Value != null) + if (_rootVisual != null) { - ((DUCE.IResource)(_rootVisual.Value)).ReleaseOnChannel(channel); + ((DUCE.IResource)(_rootVisual)).ReleaseOnChannel(channel); } // @@ -174,13 +174,13 @@ public virtual Visual RootVisual get { VerifyAPIReadOnly(); - return (_rootVisual.Value); + return (_rootVisual); } set { VerifyAPIReadWrite(); - if (_rootVisual.Value != value) + if (_rootVisual != value) { SetRootVisual(value); @@ -244,14 +244,14 @@ internal object StateChangedCallback(object arg) // render if one has not already been scheduled. // - if (_rootVisual.Value != null) + if (_rootVisual != null) { // // When replacing the root visual, we need to re-realize all // content in the new tree // Visual.PropagateFlags( - _rootVisual.Value, + _rootVisual, VisualFlags.IsSubtreeDirtyForPrecompute, VisualProxyFlags.IsSubtreeDirtyForRender ); @@ -297,7 +297,7 @@ void ICompositionTarget.Render(bool inResize, DUCE.Channel channel) _frameRateTimer.Begin(); #endif - if (_rootVisual.Value != null) + if (_rootVisual != null) { bool etwTracingEnabled = false; @@ -311,7 +311,7 @@ void ICompositionTarget.Render(bool inResize, DUCE.Channel channel) _precomputeRateTimer.Begin(); #endif // precompute is channel agnostic - _rootVisual.Value.Precompute(); + _rootVisual.Precompute(); #if MEDIA_PERFORMANCE_COUNTERS _precomputeRateTimer.End(); @@ -416,7 +416,7 @@ private void Compile(DUCE.Channel channel) { MediaContext mctx = MediaContext.From(Dispatcher); - Invariant.Assert(_rootVisual.Value!=null); + Invariant.Assert(_rootVisual!=null); // 1) Check if we have a cached render context. // 2) Initialize the render context. @@ -454,7 +454,7 @@ private void Compile(DUCE.Channel channel) if (mctx.IsConnected) { - _rootVisual.Value.Render(rc, 0); + _rootVisual.Render(rc, 0); } // ------------------------------------------------------------------------------------ @@ -486,22 +486,22 @@ private void SetRootVisual(Visual visual) DUCE.ChannelSet channelSet = MediaContext.From(Dispatcher).GetChannels(); DUCE.Channel channel = channelSet.Channel; - if (_rootVisual.Value != null && _contentRoot.IsOnChannel(channel)) + if (_rootVisual != null && _contentRoot.IsOnChannel(channel)) { ClearRootNode(channel); - ((DUCE.IResource)_rootVisual.Value).ReleaseOnChannel(channel); + ((DUCE.IResource)_rootVisual).ReleaseOnChannel(channel); - _rootVisual.Value.IsRootElement = false; + _rootVisual.IsRootElement = false; } - _rootVisual.Value = visual; + _rootVisual = visual; - if (_rootVisual.Value != null) + if (_rootVisual != null) { - _rootVisual.Value.IsRootElement = true; + _rootVisual.IsRootElement = true; - _rootVisual.Value.SetFlagsOnAllChannels( + _rootVisual.SetFlagsOnAllChannels( true, VisualProxyFlags.IsSubtreeDirtyForRender); } @@ -557,7 +557,7 @@ internal void VerifyAPIReadWrite() #region Private Fields private bool _isDisposed; - private SecurityCriticalDataForSet _rootVisual; + private Visual _rootVisual; private RenderContext _cachedRenderContext; private Matrix _worldTransform = Matrix.Identity; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs index bd9425109c5..27a50dd75eb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs @@ -298,7 +298,7 @@ ref tempBackBufferPointer ref lockBufferStride )); Invariant.Assert(lockBufferStride <= Int32.MaxValue); - _backBufferStride.Value = (int)lockBufferStride; + _backBufferStride = (int)lockBufferStride; } // If we were subscribed to the CommittingBatch event, unsubscribe @@ -780,8 +780,8 @@ out _pDoubleBufferedBitmap try { Int32Rect rcFull = new Int32Rect(0, 0, _pixelWidth, _pixelHeight); - int bufferSize = checked(_backBufferStride.Value * source.PixelHeight); - source.CriticalCopyPixels(rcFull, _backBuffer, bufferSize, _backBufferStride.Value); + int bufferSize = checked(_backBufferStride * source.PixelHeight); + source.CriticalCopyPixels(rcFull, _backBuffer, bufferSize, _backBufferStride); AddDirtyRect(rcFull); } finally @@ -914,7 +914,7 @@ bool backwardsCompat // unsafe { - uint destOffset = (uint)(destinationY * _backBufferStride.Value) + destXbyteOffset; + uint destOffset = (uint)(destinationY * _backBufferStride) + destXbyteOffset; byte* pDest = (byte*)_backBuffer.ToPointer(); pDest += destOffset; uint outputBufferSize = _backBufferSize - destOffset; @@ -930,7 +930,7 @@ bool backwardsCompat MILUtilities.MILCopyPixelBuffer( pDest, outputBufferSize, - (uint) _backBufferStride.Value, + (uint) _backBufferStride, destBufferBitOffset, pSource, inputBufferSize, @@ -1406,11 +1406,11 @@ public int BackBufferStride { ReadPreamble(); - return _backBufferStride.Value; + return _backBufferStride; } } - private SecurityCriticalDataForSet _backBufferStride; + private int _backBufferStride; #endregion // Properties diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs index 55b7b4d9fac..c6cbd8c88df 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs @@ -197,7 +197,7 @@ internal PixelFormat(Guid guidPixelFormat) _flags = GetPixelFormatFlagsFromEnum(_format) | GetPixelFormatFlagsFromGuid(guidPixelFormat); _bitsPerPixel = GetBitsPerPixelFromEnum(_format); - _guidFormat = new SecurityCriticalDataForSet (guidPixelFormat); + _guidFormat = guidPixelFormat; } internal PixelFormat(PixelFormatEnum format) @@ -206,7 +206,7 @@ internal PixelFormat(PixelFormatEnum format) _flags = GetPixelFormatFlagsFromEnum(format); _bitsPerPixel = GetBitsPerPixelFromEnum(format); - _guidFormat = new SecurityCriticalDataForSet (PixelFormat.GetGuidFromFormat(format)); + _guidFormat = PixelFormat.GetGuidFromFormat(format); } /// @@ -342,7 +342,7 @@ internal PixelFormat(string pixelFormatString) _flags = GetPixelFormatFlagsFromEnum(format); _bitsPerPixel = GetBitsPerPixelFromEnum(format); - _guidFormat = new SecurityCriticalDataForSet (PixelFormat.GetGuidFromFormat(format)); + _guidFormat = PixelFormat.GetGuidFromFormat(format); } static private Guid GetGuidFromFormat(PixelFormatEnum format) @@ -667,7 +667,7 @@ internal Guid Guid { get { - return _guidFormat.Value; + return _guidFormat; } } @@ -1088,7 +1088,7 @@ static private UInt32 GetBitsPerPixelFromEnum(PixelFormatEnum pixelFormatEnum) private UInt32 _bitsPerPixel; [NonSerialized] - private SecurityCriticalDataForSet _guidFormat; + private Guid _guidFormat; [NonSerialized] private static readonly Guid WICPixelFormatPhotonFirst = new Guid(0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1d); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextBreakpoint.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextBreakpoint.cs index fab6c63d730..9aaae8b2970 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextBreakpoint.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextBreakpoint.cs @@ -70,7 +70,7 @@ protected virtual void Dispose(bool disposing) /// We would make a correspondent call to notify our unmanaged wrapper to release them from duty of managing this /// resource. /// - internal abstract SecurityCriticalDataForSet GetTextPenaltyResource(); + internal abstract IntPtr GetTextPenaltyResource(); /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextFormatterContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextFormatterContext.cs index e48e23c3342..40f18bd650e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextFormatterContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextFormatterContext.cs @@ -45,7 +45,7 @@ public class TextFormatterContext internal class TextFormatterContext #endif { - private SecurityCriticalDataForSet _ploc; // Line Services context + private IntPtr _ploc; // Line Services context private LineServicesCallbacks _callbacks; // object to hold all delegates for callback private State _state; // internal state flags private BreakStrategies _breaking; // context's breaking strategy @@ -54,14 +54,14 @@ internal class TextFormatterContext public TextFormatterContext() { - _ploc = new SecurityCriticalDataForSet(IntPtr.Zero); + _ploc = IntPtr.Zero; Init(); } private void Init() { - if(_ploc.Value == System.IntPtr.Zero) + if(_ploc == System.IntPtr.Zero) { // Initializing context LsErr lserr = LsErr.None; @@ -151,7 +151,7 @@ out ploc SetSpecialCharacters(ref contextInfo); } - _ploc.Value = ploc; + _ploc = ploc; GC.KeepAlive(contextInfo); // There is a trick here to pass in this resolution as in twips @@ -187,7 +187,7 @@ ref devRes // Device resolutions /// internal TextPenaltyModule GetTextPenaltyModule() { - Invariant.Assert(_ploc.Value != System.IntPtr.Zero); + Invariant.Assert(_ploc != System.IntPtr.Zero); return new TextPenaltyModule(_ploc); } @@ -263,10 +263,10 @@ internal ICollection IndexedGlyphRuns /// internal void Destroy() { - if(_ploc.Value != System.IntPtr.Zero) + if(_ploc != System.IntPtr.Zero) { - UnsafeNativeMethods.LoDestroyContext(_ploc.Value); - _ploc.Value = IntPtr.Zero; + UnsafeNativeMethods.LoDestroyContext(_ploc); + _ploc = IntPtr.Zero; } } @@ -278,8 +278,8 @@ internal void SetBreaking(BreakStrategies breaking) { if (_state == State.Uninitialized || breaking != _breaking) { - Invariant.Assert(_ploc.Value != System.IntPtr.Zero); - LsErr lserr = UnsafeNativeMethods.LoSetBreaking(_ploc.Value, (int) breaking); + Invariant.Assert(_ploc != System.IntPtr.Zero); + LsErr lserr = UnsafeNativeMethods.LoSetBreaking(_ploc, (int) breaking); if (lserr != LsErr.None) { @@ -308,10 +308,10 @@ internal LsErr CreateLine( out LsLineWidths lineWidths ) { - Invariant.Assert(_ploc.Value != System.IntPtr.Zero); + Invariant.Assert(_ploc != System.IntPtr.Zero); return UnsafeNativeMethods.LoCreateLine( - _ploc.Value, + _ploc, cpFirst, lineLength, maxWidth, @@ -334,10 +334,10 @@ internal LsErr CreateBreaks( out int bestFitIndex ) { - Invariant.Assert(_ploc.Value != System.IntPtr.Zero); + Invariant.Assert(_ploc != System.IntPtr.Zero); return UnsafeNativeMethods.LoCreateBreaks( - _ploc.Value, + _ploc, cpFirst, previousLineBreakRecord, ploparabreak, @@ -356,10 +356,10 @@ internal LsErr CreateParaBreakingSession( ref bool penalizedAsJustified ) { - Invariant.Assert(_ploc.Value != System.IntPtr.Zero); + Invariant.Assert(_ploc != System.IntPtr.Zero); return UnsafeNativeMethods.LoCreateParaBreakingSession( - _ploc.Value, + _ploc, cpFirst, maxWidth, previousLineBreakRecord, @@ -375,9 +375,9 @@ internal void SetDoc( ref LsDevRes deviceInfo ) { - Invariant.Assert(_ploc.Value != System.IntPtr.Zero); + Invariant.Assert(_ploc != System.IntPtr.Zero); LsErr lserr = UnsafeNativeMethods.LoSetDoc( - _ploc.Value, + _ploc, isDisplay ? 1 : 0, isReferencePresentationEqual ? 1 : 0, ref deviceInfo @@ -395,9 +395,9 @@ internal unsafe void SetTabs( int tabStopCount ) { - Invariant.Assert(_ploc.Value != System.IntPtr.Zero); + Invariant.Assert(_ploc != System.IntPtr.Zero); LsErr lserr = UnsafeNativeMethods.LoSetTabs( - _ploc.Value, + _ploc, incrementalTab, tabStopCount, tabStops @@ -503,7 +503,7 @@ private enum State : byte /// /// Actual LS unmanaged context /// - internal SecurityCriticalDataForSet Ploc + internal IntPtr Ploc { get { return _ploc; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextLineBreak.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextLineBreak.cs index d9b6098b5ff..a2ecbb8a65b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextLineBreak.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextLineBreak.cs @@ -33,8 +33,8 @@ namespace System.Windows.Media.TextFormatting /// public sealed class TextLineBreak : IDisposable { - private TextModifierScope _currentScope; - private SecurityCriticalDataForSet _breakRecord; + private TextModifierScope _currentScope; + private IntPtr _breakRecord; #region Constructors @@ -42,14 +42,14 @@ public sealed class TextLineBreak : IDisposable /// Internallly construct the line break /// internal TextLineBreak( - TextModifierScope currentScope, - SecurityCriticalDataForSet breakRecord + TextModifierScope currentScope, + IntPtr breakRecord ) { _currentScope = currentScope; _breakRecord = breakRecord; - if (breakRecord.Value == IntPtr.Zero) + if (breakRecord == IntPtr.Zero) { // this object does not hold unmanaged resource, // remove it from the finalizer queue. @@ -86,9 +86,9 @@ public TextLineBreak Clone() { IntPtr pbreakrec = IntPtr.Zero; - if (_breakRecord.Value != IntPtr.Zero) + if (_breakRecord != IntPtr.Zero) { - LsErr lserr = UnsafeNativeMethods.LoCloneBreakRecord(_breakRecord.Value, out pbreakrec); + LsErr lserr = UnsafeNativeMethods.LoCloneBreakRecord(_breakRecord, out pbreakrec); if (lserr != LsErr.None) { @@ -96,7 +96,7 @@ public TextLineBreak Clone() } } - return new TextLineBreak(_currentScope, new SecurityCriticalDataForSet(pbreakrec)); + return new TextLineBreak(_currentScope, pbreakrec); } @@ -107,11 +107,11 @@ public TextLineBreak Clone() /// private void DisposeInternal(bool finalizing) { - if (_breakRecord.Value != IntPtr.Zero) + if (_breakRecord != IntPtr.Zero) { - UnsafeNativeMethods.LoDisposeBreakRecord(_breakRecord.Value, finalizing); + UnsafeNativeMethods.LoDisposeBreakRecord(_breakRecord, finalizing); - _breakRecord.Value = IntPtr.Zero; + _breakRecord = IntPtr.Zero; GC.KeepAlive(this); } } @@ -129,7 +129,7 @@ internal TextModifierScope TextModifierScope /// /// Unmanaged pointer to LS break records structure /// - internal SecurityCriticalDataForSet BreakRecord + internal IntPtr BreakRecord { get { return _breakRecord; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs index ee52f63279f..9fda4dbab17 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs @@ -39,10 +39,10 @@ public sealed class TextParagraphCache : IDisposable internal sealed class TextParagraphCache : IDisposable #endif { - private FullTextState _fullText; // full text state of the whole paragraph - private SecurityCriticalDataForSet _ploparabreak; // unmanaged LS resource for parabreak session - private int _finiteFormatWidth; // finite formatting ideal width - private bool _penalizedAsJustified; // flag indicating whether the paragraph should be penalized as fully-justified one + private FullTextState _fullText; // full text state of the whole paragraph + private IntPtr _ploparabreak; // unmanaged LS resource for parabreak session + private int _finiteFormatWidth; // finite formatting ideal width + private bool _penalizedAsJustified; // flag indicating whether the paragraph should be penalized as fully-justified one /// @@ -98,7 +98,7 @@ ref _penalizedAsJustified } } - _ploparabreak.Value = ploparabreakValue; + _ploparabreak = ploparabreakValue; // keep context alive till here GC.KeepAlive(context); @@ -161,11 +161,11 @@ out bestFitIndex /// private void Dispose(bool disposing) { - if(_ploparabreak.Value != IntPtr.Zero) + if(_ploparabreak != IntPtr.Zero) { - UnsafeNativeMethods.LoDisposeParaBreakingSession(_ploparabreak.Value, !disposing); + UnsafeNativeMethods.LoDisposeParaBreakingSession(_ploparabreak, !disposing); - _ploparabreak.Value = IntPtr.Zero; + _ploparabreak = IntPtr.Zero; GC.KeepAlive(this); } } @@ -201,7 +201,7 @@ internal FullTextState FullText /// /// Unmanaged LS parabreak session object /// - internal SecurityCriticalDataForSet Ploparabreak + internal IntPtr Ploparabreak { get { return _ploparabreak; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs index 5294f7946b1..b3c7b7903fb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs @@ -42,7 +42,7 @@ public static class BaseUriHelper private const string APPBASE = "application://"; private static readonly Uri _packAppBaseUri = PackUriHelper.Create(new Uri(APPBASE)); - private static SecurityCriticalDataForSet _baseUri; + private static Uri _baseUri; // Cached result of calling // PackUriHelper.GetPackageUri(BaseUriHelper.PackAppBaseUri).GetComponents( @@ -53,7 +53,7 @@ public static class BaseUriHelper static BaseUriHelper() { - _baseUri = new SecurityCriticalDataForSet(_packAppBaseUri); + _baseUri = _packAppBaseUri; // Add an instance of the ResourceContainer to PreloadedPackages so that PackWebRequestFactory can find it // and mark it as thread-safe so PackWebResponse won't protect returned streams with a synchronizing wrapper PreloadedPackages.AddPackage(PackUriHelper.GetPackageUri(SiteOfOriginBaseUri), new SiteOfOriginContainer(), true); @@ -406,13 +406,13 @@ static internal Uri BaseUri { get { - return _baseUri.Value; + return _baseUri; } set { // This setter should only be called from Framework through // BindUriHelper.set_BaseUri. - _baseUri.Value = value; + _baseUri = value; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AssemblyFilter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AssemblyFilter.cs index 9611ca46dc7..32c57d08da6 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AssemblyFilter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AssemblyFilter.cs @@ -31,8 +31,8 @@ internal class AssemblyFilter { static AssemblyFilter() { - _disallowedListExtracted = new SecurityCriticalDataForSet(false); - _assemblyList = new SecurityCriticalDataForSet>(new System.Collections.Generic.List()); + _disallowedListExtracted = false; + _assemblyList = new System.Collections.Generic.List(); } internal void FilterCallback(Object sender, AssemblyLoadEventArgs args) @@ -58,13 +58,13 @@ private bool AssemblyOnDisallowedList(String assemblyToCheck) { bool retVal = false; // if the list disallowed list is not populated populate it once - if (_disallowedListExtracted.Value == false) + if (_disallowedListExtracted == false) { // hit the registry one time and read ExtractDisallowedRegistryList(); - _disallowedListExtracted.Value = true; + _disallowedListExtracted = true; } - if (_assemblyList.Value.Contains(assemblyToCheck)) + if (_assemblyList.Contains(assemblyToCheck)) { retVal = true; } @@ -91,18 +91,18 @@ private void ExtractDisallowedRegistryList() // if there exists a value and it is 1 add to hash table if ((keyValue != null) && (int)(keyValue) == 1) { - if (!_assemblyList.Value.Contains(assemblyName)) + if (!_assemblyList.Contains(assemblyName)) { - _assemblyList.Value.Add(assemblyName.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim()); + _assemblyList.Add(assemblyName.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim()); } } } } } - static SecurityCriticalDataForSet> _assemblyList; + static System.Collections.Generic.List _assemblyList; - static SecurityCriticalDataForSet _disallowedListExtracted; + static bool _disallowedListExtracted; static readonly object _lock = new object(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/BamlStream.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/BamlStream.cs index 34a588ad54d..ef13fd71c18 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/BamlStream.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/BamlStream.cs @@ -34,7 +34,7 @@ internal class BamlStream : Stream, IStreamInfo internal BamlStream(Stream stream, Assembly assembly) { - _assembly.Value = assembly; + _assembly = assembly; _stream = stream; } #endregion @@ -52,7 +52,7 @@ internal BamlStream(Stream stream, Assembly assembly) // Assembly IStreamInfo.Assembly { - get { return _assembly.Value; } + get { return _assembly; } } #endregion @@ -273,7 +273,7 @@ byte value #region Private Members - private SecurityCriticalDataForSet _assembly; + private Assembly _assembly; private Stream _stream = null; #endregion Private Members diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/Journaling.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/Journaling.cs index 7f3c19fddfb..4a4ba6a8427 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/Journaling.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/Journaling.cs @@ -625,7 +625,7 @@ internal JournalEntryPageFunctionType(JournalEntryGroupState jeGroupState, PageF : base(jeGroupState, pageFunction) { string typeName = pageFunction.GetType().AssemblyQualifiedName; - this._typeName = new SecurityCriticalDataForSet(typeName); + this._typeName = typeName; } @@ -636,7 +636,7 @@ internal JournalEntryPageFunctionType(JournalEntryGroupState jeGroupState, PageF protected JournalEntryPageFunctionType(SerializationInfo info, StreamingContext context) : base(info, context) { - _typeName = new SecurityCriticalDataForSet(info.GetString("_typeName")); + _typeName = info.GetString("_typeName"); } // @@ -645,7 +645,7 @@ protected JournalEntryPageFunctionType(SerializationInfo info, StreamingContext public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("_typeName", _typeName.Value); + info.AddValue("_typeName", _typeName); } #endregion @@ -656,7 +656,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont internal override void SaveState(object contentObject) { - Debug.Assert(contentObject.GetType().AssemblyQualifiedName == this._typeName.Value, + Debug.Assert(contentObject.GetType().AssemblyQualifiedName == this._typeName, "The type of a PageFunction a journal entry is associated with cannot change."); base.SaveState(contentObject); // Save controls state (JournalDataStreams). } @@ -671,7 +671,7 @@ internal override PageFunctionBase ResumePageFunction() { PageFunctionBase pageFunction; - Invariant.Assert(this._typeName.Value != null, "JournalEntry does not contain the Type for the PageFunction to be created"); + Invariant.Assert(this._typeName != null, "JournalEntry does not contain the Type for the PageFunction to be created"); //First try Type.GetType from the saved typename, then try Activator.CreateInstanceFrom //Type.GetType - Since the typename is fullyqualified @@ -679,14 +679,14 @@ internal override PageFunctionBase ResumePageFunction() //If the assembly was not a strongly named one nor is present in the APPBASE, this will //fail. - Type pfType = Type.GetType(this._typeName.Value); + Type pfType = Type.GetType(this._typeName); try { pageFunction = (PageFunctionBase)Activator.CreateInstance(pfType); } catch (Exception ex) { - throw new Exception(SR.Format(SR.FailedResumePageFunction, this._typeName.Value), ex); + throw new Exception(SR.Format(SR.FailedResumePageFunction, this._typeName), ex); } InitializeComponent(pageFunction); @@ -726,7 +726,7 @@ private void InitializeComponent(PageFunctionBase pageFunction) #region Private fields /// AssemblyQualifiedName of the PageFunction Type - private SecurityCriticalDataForSet _typeName; + private string _typeName; #endregion } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs index 5c5d433a192..d6405e60464 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs @@ -164,103 +164,103 @@ private IDictionary GetOleCmdMappingTable(Guid guidCmdGroup) if (guidCmdGroup.Equals(CGID_ApplicationCommands)) { EnsureApplicationCommandsTable(); - mappingTable = _applicationCommandsMappingTable.Value; + mappingTable = _applicationCommandsMappingTable; } else if (guidCmdGroup.Equals(Guid.Empty)) { EnsureOleCmdMappingTable(); - mappingTable = _oleCmdMappingTable.Value; + mappingTable = _oleCmdMappingTable; } else if (guidCmdGroup.Equals(CGID_EditingCommands)) { EnsureEditingCommandsTable(); - mappingTable = _editingCommandsMappingTable.Value; + mappingTable = _editingCommandsMappingTable; } return mappingTable; } private void EnsureOleCmdMappingTable() { - if (_oleCmdMappingTable.Value == null) + if (_oleCmdMappingTable == null) { - _oleCmdMappingTable.Value = new SortedList(10); + _oleCmdMappingTable = new SortedList(10); //Add applevel commands here - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_SAVE, new CommandWithArgument(ApplicationCommands.Save)); - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_SAVEAS, new CommandWithArgument(ApplicationCommands.SaveAs)); - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_PRINT, new CommandWithArgument(ApplicationCommands.Print)); - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_CUT, new CommandWithArgument(ApplicationCommands.Cut)); - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_COPY, new CommandWithArgument(ApplicationCommands.Copy)); - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_PASTE, new CommandWithArgument(ApplicationCommands.Paste)); - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_PROPERTIES, new CommandWithArgument(ApplicationCommands.Properties)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_SAVE, new CommandWithArgument(ApplicationCommands.Save)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_SAVEAS, new CommandWithArgument(ApplicationCommands.SaveAs)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_PRINT, new CommandWithArgument(ApplicationCommands.Print)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_CUT, new CommandWithArgument(ApplicationCommands.Cut)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_COPY, new CommandWithArgument(ApplicationCommands.Copy)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_PASTE, new CommandWithArgument(ApplicationCommands.Paste)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_PROPERTIES, new CommandWithArgument(ApplicationCommands.Properties)); //Set the Enabled property of Stop and Refresh commands correctly - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_REFRESH, new CommandWithArgument(NavigationCommands.Refresh)); - _oleCmdMappingTable.Value.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_STOP, new CommandWithArgument(NavigationCommands.BrowseStop)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_REFRESH, new CommandWithArgument(NavigationCommands.Refresh)); + _oleCmdMappingTable.Add((uint)UnsafeNativeMethods.OLECMDID.OLECMDID_STOP, new CommandWithArgument(NavigationCommands.BrowseStop)); } } private void EnsureApplicationCommandsTable() { - if (_applicationCommandsMappingTable.Value == null) + if (_applicationCommandsMappingTable == null) { /* we want to possible add 26 entries, so the capacity should be * 26/0.72 = 19 for default of 1.0 load factor*/ - _applicationCommandsMappingTable.Value = new Hashtable(19); + _applicationCommandsMappingTable = new Hashtable(19); //Add applevel commands here // Note: The keys are added as uint type so that the default container comparer works // when we try to look up a command by a uint cmdid. - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Cut, new CommandWithArgument(ApplicationCommands.Cut)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Copy, new CommandWithArgument(ApplicationCommands.Copy)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Paste, new CommandWithArgument(ApplicationCommands.Paste)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_SelectAll, new CommandWithArgument(ApplicationCommands.SelectAll)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Find, new CommandWithArgument(ApplicationCommands.Find)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Cut, new CommandWithArgument(ApplicationCommands.Cut)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Copy, new CommandWithArgument(ApplicationCommands.Copy)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Paste, new CommandWithArgument(ApplicationCommands.Paste)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_SelectAll, new CommandWithArgument(ApplicationCommands.SelectAll)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Find, new CommandWithArgument(ApplicationCommands.Find)); // Add standard navigation commands - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Refresh, new CommandWithArgument(NavigationCommands.Refresh)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Stop, new CommandWithArgument(NavigationCommands.BrowseStop)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Refresh, new CommandWithArgument(NavigationCommands.Refresh)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Stop, new CommandWithArgument(NavigationCommands.BrowseStop)); // add document viewer commands - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Digitalsignatures_SignDocument, new CommandWithArgument(DocumentApplicationDocumentViewer.Sign)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Digitalsignatures_RequestSignature, new CommandWithArgument(DocumentApplicationDocumentViewer.RequestSigners)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Digitalsignatures_ViewSignature, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowSignatureSummary)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Permission_Set, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowRMPublishingUI)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Permission_View, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowRMPermissions)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.Edit_Permission_Restrict, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowRMCredentialManager)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_In, new CommandWithArgument(NavigationCommands.IncreaseZoom)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_Out, new CommandWithArgument(NavigationCommands.DecreaseZoom)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_400, new CommandWithArgument(NavigationCommands.Zoom, 400)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_250, new CommandWithArgument(NavigationCommands.Zoom, 250)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_150, new CommandWithArgument(NavigationCommands.Zoom, 150)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_100, new CommandWithArgument(NavigationCommands.Zoom, 100)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_75, new CommandWithArgument(NavigationCommands.Zoom, 75)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_50, new CommandWithArgument(NavigationCommands.Zoom, 50)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_25, new CommandWithArgument(NavigationCommands.Zoom, 25)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_PageWidth, new CommandWithArgument(DocumentViewer.FitToWidthCommand)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_WholePage, new CommandWithArgument(DocumentViewer.FitToHeightCommand)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_TwoPages, new CommandWithArgument(DocumentViewer.FitToMaxPagesAcrossCommand, 2)); - _applicationCommandsMappingTable.Value.Add((uint)AppCommands.View_Zoom_Thumbnails, new CommandWithArgument(DocumentViewer.ViewThumbnailsCommand)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Digitalsignatures_SignDocument, new CommandWithArgument(DocumentApplicationDocumentViewer.Sign)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Digitalsignatures_RequestSignature, new CommandWithArgument(DocumentApplicationDocumentViewer.RequestSigners)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Digitalsignatures_ViewSignature, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowSignatureSummary)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Permission_Set, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowRMPublishingUI)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Permission_View, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowRMPermissions)); + _applicationCommandsMappingTable.Add((uint)AppCommands.Edit_Permission_Restrict, new CommandWithArgument(DocumentApplicationDocumentViewer.ShowRMCredentialManager)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_In, new CommandWithArgument(NavigationCommands.IncreaseZoom)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_Out, new CommandWithArgument(NavigationCommands.DecreaseZoom)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_400, new CommandWithArgument(NavigationCommands.Zoom, 400)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_250, new CommandWithArgument(NavigationCommands.Zoom, 250)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_150, new CommandWithArgument(NavigationCommands.Zoom, 150)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_100, new CommandWithArgument(NavigationCommands.Zoom, 100)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_75, new CommandWithArgument(NavigationCommands.Zoom, 75)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_50, new CommandWithArgument(NavigationCommands.Zoom, 50)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_25, new CommandWithArgument(NavigationCommands.Zoom, 25)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_PageWidth, new CommandWithArgument(DocumentViewer.FitToWidthCommand)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_WholePage, new CommandWithArgument(DocumentViewer.FitToHeightCommand)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_TwoPages, new CommandWithArgument(DocumentViewer.FitToMaxPagesAcrossCommand, 2)); + _applicationCommandsMappingTable.Add((uint)AppCommands.View_Zoom_Thumbnails, new CommandWithArgument(DocumentViewer.ViewThumbnailsCommand)); } } private void EnsureEditingCommandsTable() { - if (_editingCommandsMappingTable.Value == null) + if (_editingCommandsMappingTable == null) { - _editingCommandsMappingTable.Value = new SortedList(2); + _editingCommandsMappingTable = new SortedList(2); // Note: The keys are added as uint type so that the default container comparer works // when we try to look up a command by a uint cmdid. - _editingCommandsMappingTable.Value.Add((uint)EditingCommandIds.Backspace, + _editingCommandsMappingTable.Add((uint)EditingCommandIds.Backspace, new CommandWithArgument(System.Windows.Documents.EditingCommands.Backspace)); - _editingCommandsMappingTable.Value.Add((uint)EditingCommandIds.Delete, + _editingCommandsMappingTable.Add((uint)EditingCommandIds.Delete, new CommandWithArgument(System.Windows.Documents.EditingCommands.Delete)); } } - private SecurityCriticalDataForSet _oleCmdMappingTable; - private SecurityCriticalDataForSet _applicationCommandsMappingTable; - private SecurityCriticalDataForSet _editingCommandsMappingTable; + private SortedList _oleCmdMappingTable; + private Hashtable _applicationCommandsMappingTable; + private SortedList _editingCommandsMappingTable; } #endregion OleCmdHelper class @@ -280,7 +280,7 @@ public CommandWithArgument(RoutedCommand command) : this(command, null) public CommandWithArgument(RoutedCommand command, object argument) { - _command = new SecurityCriticalDataForSet(command); + _command = command; _argument = argument; } @@ -293,19 +293,19 @@ public bool Execute(IInputElement target, object argument) // ISecureCommand is used to enforce user-initiated invocation. Cut, Copy and Paste // are marked as such. See ApplicationCommands.GetRequiredPermissions. - if (_command.Value is ISecureCommand) + if (_command is ISecureCommand) { bool unused; - if (_command.Value.CriticalCanExecute(argument, target, /* trusted: */ true, out unused)) + if (_command.CriticalCanExecute(argument, target, /* trusted: */ true, out unused)) { - _command.Value.ExecuteCore(argument, target, /* userInitiated: */ true); + _command.ExecuteCore(argument, target, /* userInitiated: */ true); return true; } return false; } - if (_command.Value.CanExecute(argument, target)) + if (_command.CanExecute(argument, target)) { - _command.Value.Execute(argument, target); + _command.Execute(argument, target); return true; } return false; @@ -321,25 +321,25 @@ public bool QueryEnabled(IInputElement target, object argument) // ISecureCommand is used to enforce user-initiated invocation. Cut, Copy and Paste // are marked as such. See ApplicationCommands.GetRequiredPermissions. - if (_command.Value is ISecureCommand) + if (_command is ISecureCommand) { bool unused; - return _command.Value.CriticalCanExecute(argument, target, /* trusted: */ true, out unused); + return _command.CriticalCanExecute(argument, target, /* trusted: */ true, out unused); } - return _command.Value.CanExecute(argument, target); + return _command.CanExecute(argument, target); } public RoutedCommand Command { get { - return _command.Value; + return _command; } } private object _argument; - private SecurityCriticalDataForSet _command; + private RoutedCommand _command; } #endregion diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/RequestStatusBarUpdateEventArgs.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/RequestStatusBarUpdateEventArgs.cs index 5e6c86cc7d8..2817f06ee4c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/RequestStatusBarUpdateEventArgs.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/RequestStatusBarUpdateEventArgs.cs @@ -15,7 +15,7 @@ internal sealed class RequestSetStatusBarEventArgs : RoutedEventArgs /// /// Text that will be set on the status bar. /// - private SecurityCriticalDataForSet _text; + private string _text; /// /// Creates a RequestSetStatusBarEventArgs based on a specified string. @@ -24,7 +24,7 @@ internal sealed class RequestSetStatusBarEventArgs : RoutedEventArgs internal RequestSetStatusBarEventArgs(string text) : base() { - _text.Value = text; + _text = text; base.RoutedEvent = System.Windows.Documents.Hyperlink.RequestSetStatusBarEvent; } @@ -36,9 +36,9 @@ internal RequestSetStatusBarEventArgs(Uri targetUri) : base() { if (targetUri == null) - _text.Value = String.Empty; + _text = String.Empty; else - _text.Value = BindUriHelper.UriToString(targetUri); + _text = BindUriHelper.UriToString(targetUri); base.RoutedEvent = System.Windows.Documents.Hyperlink.RequestSetStatusBarEvent; } @@ -50,7 +50,7 @@ internal string Text { get { - return _text.Value; + return _text; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs index d7cd72c2c07..15643f72106 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs @@ -49,7 +49,7 @@ public ResourcePart(Package container, Uri uri, string name, ResourceManagerWrap throw new ArgumentNullException("rmWrapper"); } - _rmWrapper.Value = rmWrapper; + _rmWrapper = rmWrapper; _name = name; } @@ -74,7 +74,7 @@ protected override Stream GetStreamCore(FileMode mode, FileAccess access) { // Start looking for resources using the current ui culture. // The resource manager will fall back to invariant culture automatically. - stream = _rmWrapper.Value.GetStream(_name); + stream = _rmWrapper.GetStream(_name); if (stream == null) { @@ -90,7 +90,7 @@ protected override Stream GetStreamCore(FileMode mode, FileAccess access) if (MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(curContent)) { - BamlStream bamlStream = new BamlStream(stream, _rmWrapper.Value.Assembly); + BamlStream bamlStream = new BamlStream(stream, _rmWrapper.Assembly); stream = bamlStream; } @@ -143,7 +143,7 @@ private Stream EnsureResourceLocationSet() string newName = Path.ChangeExtension(_name, ResourceContainer.BamlExt); // Get resource from resource manager wrapper. - stream = _rmWrapper.Value.GetStream(newName); + stream = _rmWrapper.GetStream(newName); if (stream != null) { // Remember that we have .baml for next time GetStreamCore is called. @@ -182,7 +182,7 @@ private Stream EnsureResourceLocationSet() #region Private Members - private SecurityCriticalDataForSet _rmWrapper; + private ResourceManagerWrapper _rmWrapper; private bool _ensureResourceIsCalled = false; private string _name; private readonly Object _globalLock = new Object(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/ByteStream.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/ByteStream.cs index 80a324832e0..41efa353359 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/ByteStream.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/ByteStream.cs @@ -41,7 +41,7 @@ internal ByteStream(object underlyingStream, FileAccess openAccess) SecuritySuppressedIStream stream = underlyingStream as SecuritySuppressedIStream; Debug.Assert(stream != null); - _securitySuppressedIStream = new SecurityCriticalDataForSet(stream); + _securitySuppressedIStream = stream; _access = openAccess; // we only work for reading. @@ -108,7 +108,7 @@ public override long Length // call Stat to get length back. STATFLAG_NONAME means string buffer // is not populated. - _securitySuppressedIStream.Value.Stat(out streamStat, NativeMethods.STATFLAG_NONAME); + _securitySuppressedIStream.Stat(out streamStat, NativeMethods.STATFLAG_NONAME); _isLengthInitialized = true; _length = streamStat.cbSize; @@ -131,7 +131,7 @@ public override long Position long seekPos = 0; - _securitySuppressedIStream.Value.Seek(0, + _securitySuppressedIStream.Seek(0, NativeMethods.STREAM_SEEK_CUR, out seekPos); @@ -149,7 +149,7 @@ public override long Position long seekPos = 0; - _securitySuppressedIStream.Value.Seek(value, + _securitySuppressedIStream.Seek(value, NativeMethods.STREAM_SEEK_SET, out seekPos); @@ -222,7 +222,7 @@ public override long Seek(long offset, SeekOrigin origin) typeof(SeekOrigin)); } - _securitySuppressedIStream.Value.Seek(offset, translatedSeekOrigin, out seekPos); + _securitySuppressedIStream.Seek(offset, translatedSeekOrigin, out seekPos); return seekPos; } @@ -287,7 +287,7 @@ public override int Read(byte[] buffer, int offset, int count) // offset == 0 is the normal case if (0 == offset) { - _securitySuppressedIStream.Value.Read(buffer, count, out read); + _securitySuppressedIStream.Read(buffer, count, out read); } // offset involved. Must be positive else if (0 < offset) @@ -296,7 +296,7 @@ public override int Read(byte[] buffer, int offset, int count) // the specified offset. byte[] localBuffer = new byte[count]; - _securitySuppressedIStream.Value.Read(localBuffer, count, out read); + _securitySuppressedIStream.Read(localBuffer, count, out read); if (read > 0) { @@ -385,7 +385,7 @@ private bool StreamDisposed // This class does not control the life cycle of _securitySupressedIStream // thus it should not dispose it when this class gets disposed // the client code of this class should be the one that dispose _securitySupressedIStream - SecurityCriticalDataForSet _securitySuppressedIStream; + SecuritySuppressedIStream _securitySuppressedIStream; FileAccess _access; long _length = 0; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/BaseParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/BaseParaClient.cs index 61c807c7647..56907252393 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/BaseParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/BaseParaClient.cs @@ -44,7 +44,7 @@ internal abstract class BaseParaClient : UnmanagedHandle // ------------------------------------------------------------------ protected BaseParaClient(BaseParagraph paragraph) : base(paragraph.PtsContext) { - _paraHandle = new SecurityCriticalDataForSet(IntPtr.Zero); + _paraHandle = IntPtr.Zero; _paragraph = paragraph; } @@ -70,8 +70,8 @@ protected BaseParaClient(BaseParagraph paragraph) : base(paragraph.PtsContext) internal void Arrange(IntPtr pfspara, PTS.FSRECT rcPara, int dvrTopSpace, uint fswdirParent) { // Make sure that paragraph handle (PFSPARA) is set. It is required to query paragraph content. - Debug.Assert(_paraHandle.Value == IntPtr.Zero || _paraHandle.Value == pfspara); - _paraHandle.Value = pfspara; + Debug.Assert(_paraHandle == IntPtr.Zero || _paraHandle == pfspara); + _paraHandle = pfspara; // Set paragraph rectangle (relative to the page) _rect = rcPara; @@ -258,7 +258,7 @@ protected virtual void OnArrange() // ------------------------------------------------------------------ // PTS paragraph handle. // ------------------------------------------------------------------ - protected SecurityCriticalDataForSet _paraHandle; + protected IntPtr _paraHandle; // ------------------------------------------------------------------ // Rectangle occupied by this portion of the paragraph (relative diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs index 4b643148c46..523bf4a4b6f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/CellParaClient.cs @@ -120,9 +120,9 @@ internal void Arrange(int du, int dv, PTS.FSRECT rcTable, FlowDirection tableFlo OnArrange(); - if(_paraHandle.Value != IntPtr.Zero) + if(_paraHandle != IntPtr.Zero) { - PTS.Validate(PTS.FsClearUpdateInfoInSubpage(PtsContext.Context, _paraHandle.Value), PtsContext); + PTS.Validate(PTS.FsClearUpdateInfoInSubpage(PtsContext.Context, _paraHandle), PtsContext); } } @@ -205,7 +205,7 @@ internal void FormatCellFinite(Size subpageSize, IntPtr breakRecordIn, bool isEm mcs.Dispose(); pmcsclientOut = IntPtr.Zero; } - _paraHandle.Value = pfspara; + _paraHandle = pfspara; } /// @@ -256,7 +256,7 @@ internal void FormatCellBottomless(uint fswdir, double width, out PTS.FSFMTRBL f pmcsclientOut = IntPtr.Zero; } - _paraHandle.Value = pfspara; + _paraHandle = pfspara; } @@ -280,7 +280,7 @@ internal void UpdateBottomlessCell(uint fswdir, double width, out PTS.FSFMTRBL f fspap = new PTS.FSPAP(); CellParagraph.GetParaProperties(ref fspap); - CellParagraph.UpdateBottomlessPara(_paraHandle.Value, this, + CellParagraph.UpdateBottomlessPara(_paraHandle, this, PTS.FromBoolean(false), fswdir, 0, TextDpi.ToTextDpi(width), diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ContainerParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ContainerParaClient.cs index 0d43492f3fc..1b9ea84e11e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ContainerParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ContainerParaClient.cs @@ -50,7 +50,7 @@ protected override void OnArrange() // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // Adjust rectangle and offset to take into account MBPs MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); @@ -73,7 +73,7 @@ protected override void OnArrange() { // Get list of paragraphs PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); PtsHelper.ArrangeParaList(PtsContext, subtrackDetails.fsrc, arrayParaDesc, fswdirSubtrack); } @@ -92,7 +92,7 @@ internal override IInputElement InputHitTest(PTS.FSPOINT pt) // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // Hittest subtrack content. @@ -102,7 +102,7 @@ internal override IInputElement InputHitTest(PTS.FSPOINT pt) { // Get list of paragraphs PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); // Render list of paragraphs ie = PtsHelper.InputHitTestParaList(PtsContext, pt, ref subtrackDetails.fsrc, arrayParaDesc); @@ -145,7 +145,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // There might be possibility to get empty sub-track, skip the sub-track // in such case. @@ -154,7 +154,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng // Get list of paragraphs // No changes to offset, since there are no subpages generated, only lists of paragraphs PTS.FSPARADESCRIPTION[] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); // Render list of paragraphs rectangles = PtsHelper.GetRectanglesInParaList(PtsContext, e, start, length, arrayParaDesc); @@ -180,7 +180,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // Draw border and background info. @@ -200,7 +200,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Get list of paragraphs PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); // Render list of paragraphs PtsHelper.UpdateParaListVisuals(PtsContext, _visual.Children, fskupdInherited, arrayParaDesc); @@ -221,14 +221,14 @@ internal override void UpdateViewport(ref PTS.FSRECT viewport) { // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // There might be possibility to get empty sub-track, skip the sub-track in such case. if (subtrackDetails.cParas != 0) { // Get list of paragraphs PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); // Render list of paragraphs PtsHelper.UpdateViewportParaList(PtsContext, arrayParaDesc, ref viewport); @@ -243,14 +243,14 @@ internal override ParagraphResult CreateParagraphResult() /* // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // If there is just one paragraph, do not create container. Return just this paragraph. if (subtrackDetails.cParas == 1) { // Get list of paragraphs PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(_paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(_paraHandle, ref subtrackDetails, out arrayParaDesc); BaseParaClient paraClient = PtsContext.HandleToObject(arrayParaDesc[0].pfsparaclient) as BaseParaClient; PTS.ValidateHandle(paraClient); @@ -274,7 +274,7 @@ internal override TextContentRange GetTextContentRange() Invariant.Assert(elementOwner != null, "Expecting TextElement as owner of ContainerParagraph."); // Query paragraph details - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // If container is empty, return range for the entire element. // If the beginning and the end of content of the paragraph is @@ -286,7 +286,7 @@ internal override TextContentRange GetTextContentRange() } else { - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); // Merge TextContentRanges for all paragraphs textContentRange = new TextContentRange(); @@ -328,7 +328,7 @@ internal ReadOnlyCollection GetChildrenParagraphResults(out boo #endif // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // hasTextContent is set to true if any of the children paragraphs has text content, not just attached objects hasTextContent = false; @@ -340,7 +340,7 @@ internal ReadOnlyCollection GetChildrenParagraphResults(out boo // Get list of paragraphs PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); List paragraphResults = new List(arrayParaDesc.Length); for (int i = 0; i < arrayParaDesc.Length; i++) @@ -378,7 +378,7 @@ internal void SetChunkInfo(bool isFirstChunk, bool isLastChunk) internal override int GetFirstTextLineBaseline() { PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); if (subtrackDetails.cParas == 0) { @@ -387,7 +387,7 @@ internal override int GetFirstTextLineBaseline() // Get list of paragraphs PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); BaseParaClient paraClient = PtsContext.HandleToObject(arrayParaDesc[0].pfsparaclient) as BaseParaClient; PTS.ValidateHandle(paraClient); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/FigureParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/FigureParaClient.cs index 0fdd1943700..a7284e9dd0b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/FigureParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/FigureParaClient.cs @@ -69,7 +69,7 @@ protected override void OnArrange() // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); _pageContext.AddFloatingParaClient(this); @@ -118,7 +118,7 @@ protected override void OnArrange() { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length; index++) @@ -142,7 +142,7 @@ internal override void UpdateViewport(ref PTS.FSRECT viewport) { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); PTS.FSRECT viewportSubpage = new PTS.FSRECT(); @@ -168,7 +168,7 @@ internal override void UpdateViewport(ref PTS.FSRECT viewport) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); emptySubpage = (arrayColumnDesc.Length == 0); if (!emptySubpage) @@ -234,7 +234,7 @@ internal override IInputElement InputHitTest(PTS.FSPOINT pt) { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); if(Rect.Contains(pt)) { @@ -258,7 +258,7 @@ internal override IInputElement InputHitTest(PTS.FSPOINT pt) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length && ie == null; index++) @@ -298,7 +298,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Check subpage content for element. Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -317,7 +317,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length; index++) @@ -352,7 +352,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Obtain all mbp info MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); @@ -418,7 +418,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); emptySubpage = (arrayColumnDesc.Length == 0); if (!emptySubpage) @@ -498,7 +498,7 @@ internal override TextContentRange GetTextContentRange() // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -519,7 +519,7 @@ internal override TextContentRange GetTextContentRange() { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); Invariant.Assert(arrayColumnDesc.Length == 1); // Arrange each track @@ -559,7 +559,7 @@ private ReadOnlyCollection GetChildrenParagraphResults(out bool // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // hasTextContent is set to true if any of the children paragraphs has text content, not just attached objects hasTextContent = false; @@ -608,7 +608,7 @@ private ReadOnlyCollection GetChildrenParagraphResults(out bool // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); Debug.Assert(arrayColumnDesc.Length == 1); // Get track details @@ -658,7 +658,7 @@ internal ReadOnlyCollection GetColumnResults(out bool hasTextConte // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -688,7 +688,7 @@ internal ReadOnlyCollection GetColumnResults(out bool hasTextConte { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Figures are held at one column; just add the first one columnResults = new List(1); @@ -763,9 +763,9 @@ internal Geometry GetTightBoundingGeometryFromTextPositions(ReadOnlyCollection GetRectangles(ContentElement e, int start, int leng { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Check subpage content for element. Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -321,7 +321,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length; index++) @@ -358,7 +358,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Obtain all mbd info MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); @@ -424,7 +424,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); emptySubpage = (arrayColumnDesc.Length == 0); if (!emptySubpage) @@ -504,7 +504,7 @@ internal override TextContentRange GetTextContentRange() // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -525,7 +525,7 @@ internal override TextContentRange GetTextContentRange() { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length; index++) @@ -566,7 +566,7 @@ private ReadOnlyCollection GetChildrenParagraphResults(out bool // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // hasTextContent is set to true if any of the children paragraphs has text content, not just attached objects hasTextContent = false; @@ -616,7 +616,7 @@ private ReadOnlyCollection GetChildrenParagraphResults(out bool // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); Debug.Assert(arrayColumnDesc.Length == 1); // Get track details @@ -666,7 +666,7 @@ internal ReadOnlyCollection GetColumnResults(out bool hasTextConte // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -696,7 +696,7 @@ internal ReadOnlyCollection GetColumnResults(out bool hasTextConte { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Floaters are held at one column; just add the first one columnResults = new List(1); @@ -773,7 +773,7 @@ internal IntPtr SubpageHandle { // getter removed (unused internal API). If needed, recall from history. - set { _paraHandle.Value = value; } + set { _paraHandle = value; } } // ------------------------------------------------------------------ diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListParaClient.cs index 827a9a5e848..0918cb11658 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListParaClient.cs @@ -48,7 +48,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; - PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); + PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle, out subtrackDetails)); // Draw border and background info. MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); @@ -70,7 +70,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) if (subtrackDetails.cParas != 0) { PTS.FSPARADESCRIPTION [] arrayParaDesc; - PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); + PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle, ref subtrackDetails, out arrayParaDesc); using(DrawingContext ctx = _visual.RenderOpen()) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PageBreakRecord.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PageBreakRecord.cs index f3c5adfe8b6..f9ec8642c32 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PageBreakRecord.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PageBreakRecord.cs @@ -33,10 +33,10 @@ internal sealed class PageBreakRecord : IDisposable /// Current PTS Context. /// PTS page break record. /// Page number. - internal PageBreakRecord(PtsContext ptsContext, SecurityCriticalDataForSet br, int pageNumber) + internal PageBreakRecord(PtsContext ptsContext, IntPtr br, int pageNumber) { Invariant.Assert(ptsContext != null, "Invalid PtsContext object."); - Invariant.Assert(br.Value != IntPtr.Zero, "Invalid break record object."); + Invariant.Assert(br != IntPtr.Zero, "Invalid break record object."); _br = br; _pageNumber = pageNumber; @@ -94,7 +94,7 @@ public void Dispose() /// internal IntPtr BreakRecord { - get { return _br.Value; } + get { return _br; } } /// @@ -151,7 +151,7 @@ private void Dispose(bool disposing) } // Cleanup the state. - _br.Value = IntPtr.Zero; + _br = IntPtr.Zero; _ptsContext = null; } } @@ -169,7 +169,7 @@ private void Dispose(bool disposing) /// /// PTS page break record. /// - private SecurityCriticalDataForSet _br; + private IntPtr _br; /// /// Page number of the page starting at the break position. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsContext.cs index 91b1e27a52e..d1337a305e4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsContext.cs @@ -282,13 +282,13 @@ internal void Leave() /// When page is created, add it to the list. /// /// PTS Page object that was just created. - internal void OnPageCreated(SecurityCriticalDataForSet ptsPage) + internal void OnPageCreated(IntPtr ptsPage) { - Invariant.Assert(ptsPage.Value != IntPtr.Zero, "Invalid page object."); + Invariant.Assert(ptsPage != IntPtr.Zero, "Invalid page object."); Invariant.Assert(!this.Disposed, "PtsContext is already disposed."); - Invariant.Assert(!_pages.Contains(ptsPage.Value), "Page already exists."); + Invariant.Assert(!_pages.Contains(ptsPage), "Page already exists."); - _pages.Add(ptsPage.Value); + _pages.Add(ptsPage); } /// @@ -297,9 +297,9 @@ internal void OnPageCreated(SecurityCriticalDataForSet ptsPage) /// Pointer to PTS Page object that should be destroyed. /// Whether dispose is caused by explicit call to Dispose. /// Whether needs to enter PtsContext or not (during layout it is not needed). - internal void OnPageDisposed(SecurityCriticalDataForSet ptsPage, bool disposing, bool enterContext) + internal void OnPageDisposed(IntPtr ptsPage, bool disposing, bool enterContext) { - Invariant.Assert(ptsPage.Value != IntPtr.Zero, "Invalid page object."); + Invariant.Assert(ptsPage != IntPtr.Zero, "Invalid page object."); // If explicitly disposing (not called during finalization), synchronously // destroy the page. @@ -323,13 +323,13 @@ internal void OnPageDisposed(SecurityCriticalDataForSet ptsPage, bool di /// When PageBreakRecord is created, add it to the list. /// /// PTS Page BR object that was just created. - internal void OnPageBreakRecordCreated(SecurityCriticalDataForSet br) + internal void OnPageBreakRecordCreated(IntPtr br) { - Invariant.Assert(br.Value != IntPtr.Zero, "Invalid break record object."); + Invariant.Assert(br != IntPtr.Zero, "Invalid break record object."); Invariant.Assert(!this.Disposed, "PtsContext is already disposed."); - Invariant.Assert(!_pageBreakRecords.Contains(br.Value), "Break record already exists."); + Invariant.Assert(!_pageBreakRecords.Contains(br), "Break record already exists."); - _pageBreakRecords.Add(br.Value); + _pageBreakRecords.Add(br); } /// @@ -337,9 +337,9 @@ internal void OnPageBreakRecordCreated(SecurityCriticalDataForSet br) /// /// Pointer to PTS Page BR object that should be destroyed. /// Whether dispose is caused by explicit call to Dispose. - internal void OnPageBreakRecordDisposed(SecurityCriticalDataForSet br, bool disposing) + internal void OnPageBreakRecordDisposed(IntPtr br, bool disposing) { - Invariant.Assert(br.Value != IntPtr.Zero, "Invalid break record object."); + Invariant.Assert(br != IntPtr.Zero, "Invalid break record object."); // If explicitly disposing (not called during finalization), synchronously // destroy the page break record. @@ -462,7 +462,7 @@ private void Resize() /// Pointer to PTS Page object that should be destroyed. private object OnDestroyPage(object args) { - SecurityCriticalDataForSet ptsPage = (SecurityCriticalDataForSet)args; + IntPtr ptsPage = (IntPtr)args; OnDestroyPage(ptsPage, true); return null; } @@ -472,16 +472,16 @@ private object OnDestroyPage(object args) /// /// Pointer to PTS Page object that should be destroyed. /// Whether needs to enter PTS Context. - private void OnDestroyPage(SecurityCriticalDataForSet ptsPage, bool enterContext) + private void OnDestroyPage(IntPtr ptsPage, bool enterContext) { - Invariant.Assert(ptsPage.Value != IntPtr.Zero, "Invalid page object."); + Invariant.Assert(ptsPage != IntPtr.Zero, "Invalid page object."); // Dispatcher may invoke this operation when PtsContext is already explicitly // disposed. if (!this.Disposed) { Invariant.Assert(_pages != null, "Collection of pages does not exist."); - Invariant.Assert(_pages.Contains(ptsPage.Value), "Page does not exist."); + Invariant.Assert(_pages.Contains(ptsPage), "Page does not exist."); // Destroy given page. // It is necessary to enter PTS Context when executing any PTS methods. @@ -491,7 +491,7 @@ private void OnDestroyPage(SecurityCriticalDataForSet ptsPage, bool ente { Enter(); } - PTS.Validate(PTS.FsDestroyPage(_ptsHost.Context, ptsPage.Value)); + PTS.Validate(PTS.FsDestroyPage(_ptsHost.Context, ptsPage)); } finally { @@ -499,7 +499,7 @@ private void OnDestroyPage(SecurityCriticalDataForSet ptsPage, bool ente { Leave(); } - _pages.Remove(ptsPage.Value); + _pages.Remove(ptsPage); } } } @@ -510,27 +510,27 @@ private void OnDestroyPage(SecurityCriticalDataForSet ptsPage, bool ente /// Pointer to PTS Page BreakRecord object that should be destroyed. private object OnDestroyBreakRecord(object args) { - SecurityCriticalDataForSet br = (SecurityCriticalDataForSet)args; - Invariant.Assert(br.Value != IntPtr.Zero, "Invalid break record object."); + IntPtr br = (IntPtr)args; + Invariant.Assert(br != IntPtr.Zero, "Invalid break record object."); // Dispatcher may invoke this operation when PtsContext is already explicitly // disposed. if (!this.Disposed) { Invariant.Assert(_pageBreakRecords != null, "Collection of break records does not exist."); - Invariant.Assert(_pageBreakRecords.Contains(br.Value), "Break record does not exist."); + Invariant.Assert(_pageBreakRecords.Contains(br), "Break record does not exist."); // Destroy given page break record. // It is necessary to enter PTS Context when executing any PTS methods. try { Enter(); - PTS.Validate(PTS.FsDestroyPageBreakRecord(_ptsHost.Context, br.Value)); + PTS.Validate(PTS.FsDestroyPageBreakRecord(_ptsHost.Context, br)); } finally { Leave(); - _pageBreakRecords.Remove(br.Value); + _pageBreakRecords.Remove(br); } } return null; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsHost.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsHost.cs index d31c88d2218..38e13c11d05 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsHost.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsHost.cs @@ -48,7 +48,7 @@ internal sealed class PtsHost /// internal PtsHost() { - _context = new SecurityCriticalDataForSet(IntPtr.Zero); + _context = IntPtr.Zero; } // ------------------------------------------------------------------ @@ -75,10 +75,10 @@ private PtsContext PtsContext // ------------------------------------------------------------------ internal IntPtr Context { - get { Invariant.Assert(_context.Value != IntPtr.Zero); return _context.Value; } - set { Invariant.Assert(_context.Value == IntPtr.Zero); _context.Value = value; } + get { Invariant.Assert(_context != IntPtr.Zero); return _context; } + set { Invariant.Assert(_context == IntPtr.Zero); _context = value; } } - private SecurityCriticalDataForSet _context; + private IntPtr _context; // ------------------------------------------------------------------ // Container paragraph id. @@ -1575,7 +1575,7 @@ out iLineVariantBest rgfslinevariant[breakIndex].dvrAscent = dvrAscent; rgfslinevariant[breakIndex].dvrDescent = dvrDescent; rgfslinevariant[breakIndex].fReformatNeighborsAsLastLine = PTS.False; - rgfslinevariant[breakIndex].ptsLinePenaltyInfo = textBreakpoint.GetTextPenaltyResource().Value; + rgfslinevariant[breakIndex].ptsLinePenaltyInfo = textBreakpoint.GetTextPenaltyResource(); } nLineVariantsActual = textBreakpoints.Count; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsPage.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsPage.cs index 56fccdb47dd..859c9d64ea7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsPage.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/PtsPage.cs @@ -52,7 +52,7 @@ internal PtsPage(Section section) : this() // ------------------------------------------------------------------ private PtsPage() { - _ptsPage = new SecurityCriticalDataForSet(IntPtr.Zero); + _ptsPage = IntPtr.Zero; } // ------------------------------------------------------------------ @@ -303,13 +303,13 @@ internal void CreateBottomlessPage() if (fserr != PTS.fserrNone) { // Formatting failed and ptsPage may be set to a partially formatted page. Set value to IntPtr.Zero - _ptsPage.Value = IntPtr.Zero; + _ptsPage = IntPtr.Zero; PTS.ValidateAndTrace(fserr, PtsContext); } else { // Formatting succeeded. Set page value - _ptsPage.Value = ptsPage; + _ptsPage = ptsPage; } if (TracePageFormatting.IsEnabled) @@ -351,7 +351,7 @@ internal void UpdateBottomlessPage() } PTS.FSFMTRBL formattingResult; - int fserr = PTS.FsUpdateBottomlessPage(PtsContext.Context, _ptsPage.Value, _section.Handle, out formattingResult); + int fserr = PTS.FsUpdateBottomlessPage(PtsContext.Context, _ptsPage, _section.Handle, out formattingResult); if (fserr != PTS.fserrNone) { // Do inplace cleanup. @@ -405,20 +405,20 @@ internal void CreateFinitePage(PageBreakRecord breakRecord) if (fserr != PTS.fserrNone) { // Formatting failed and ptsPage may be set to a partially formatted page. Set value to IntPtr.Zero - _ptsPage.Value = IntPtr.Zero; + _ptsPage = IntPtr.Zero; brOut = IntPtr.Zero; PTS.ValidateAndTrace(fserr, PtsContext); } else { - _ptsPage.Value = ptsPage; + _ptsPage = ptsPage; } if (brOut != IntPtr.Zero) { StructuralCache structuralCache = _section.StructuralCache; if (structuralCache != null) { - _breakRecord = new PageBreakRecord(PtsContext, new SecurityCriticalDataForSet(brOut), (breakRecord != null) ? breakRecord.PageNumber + 1 : 1); + _breakRecord = new PageBreakRecord(PtsContext, brOut, (breakRecord != null) ? breakRecord.PageNumber + 1 : 1); } } @@ -461,7 +461,7 @@ internal void UpdateFinitePage(PageBreakRecord breakRecord) // Create finite page and update layout size information PTS.FSFMTR formattingResult; IntPtr brOut; - int fserr = PTS.FsUpdateFinitePage(PtsContext.Context, _ptsPage.Value, brIn, + int fserr = PTS.FsUpdateFinitePage(PtsContext.Context, _ptsPage, brIn, _section.Handle, out formattingResult, out brOut); if (fserr != PTS.fserrNone) @@ -477,7 +477,7 @@ internal void UpdateFinitePage(PageBreakRecord breakRecord) StructuralCache structuralCache = _section.StructuralCache; if (structuralCache != null) { - _breakRecord = new PageBreakRecord(PtsContext, new SecurityCriticalDataForSet(brOut), (breakRecord != null) ? breakRecord.PageNumber + 1 : 1); + _breakRecord = new PageBreakRecord(PtsContext, brOut, (breakRecord != null) ? breakRecord.PageNumber + 1 : 1); } } @@ -507,7 +507,7 @@ internal void ArrangePage() // Get page details PTS.FSPAGEDETAILS pageDetails; - PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage.Value, out pageDetails)); + PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage, out pageDetails)); // Arrange page content. Page content may be simple or complex - @@ -537,7 +537,7 @@ internal void ArrangePage() { // Retrieve description for each section. PTS.FSSECTIONDESCRIPTION[] arraySectionDesc; - PtsHelper.SectionListFromPage(PtsContext, _ptsPage.Value, ref pageDetails, out arraySectionDesc); + PtsHelper.SectionListFromPage(PtsContext, _ptsPage, ref pageDetails, out arraySectionDesc); // Arrange each section for (int index = 0; index < arraySectionDesc.Length; index++) @@ -557,7 +557,7 @@ internal void UpdateViewport(ref PTS.FSRECT viewport) { // Get page details PTS.FSPAGEDETAILS pageDetails; - PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage.Value, out pageDetails)); + PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage, out pageDetails)); // Arrange page content. Page content may be simple or complex - // depending of set of features used in the content of the page. @@ -582,7 +582,7 @@ internal void UpdateViewport(ref PTS.FSRECT viewport) { // Retrieve description for each section. PTS.FSSECTIONDESCRIPTION[] arraySectionDesc; - PtsHelper.SectionListFromPage(PtsContext, _ptsPage.Value, ref pageDetails, out arraySectionDesc); + PtsHelper.SectionListFromPage(PtsContext, _ptsPage, ref pageDetails, out arraySectionDesc); // Arrange each section for (int index = 0; index < arraySectionDesc.Length; index++) @@ -602,7 +602,7 @@ internal void ClearUpdateInfo() if (!IsEmpty) { // Clear any incremental update state acummulated during update process. - PTS.Validate(PTS.FsClearUpdateInfoInPage(PtsContext.Context, _ptsPage.Value), PtsContext); + PTS.Validate(PTS.FsClearUpdateInfoInPage(PtsContext.Context, _ptsPage), PtsContext); } } @@ -675,7 +675,7 @@ internal ContainerVisual GetPageVisual() //------------------------------------------------------------------- // Handle to PTS page. //------------------------------------------------------------------- - internal IntPtr PageHandle { get { return _ptsPage.Value; } } + internal IntPtr PageHandle { get { return _ptsPage; } } //------------------------------------------------------------------- // Is being used in a plain text box? @@ -725,7 +725,7 @@ private void Dispose(bool disposing) } // Cleanup the state. - _ptsPage.Value = IntPtr.Zero; + _ptsPage = IntPtr.Zero; _breakRecord = null; _visual = null; _backgroundFormatOperation = null; @@ -836,7 +836,7 @@ private PTS.FSRECT GetRect() { // (2) PTS page - use page PTS APIs to get page rectangle. PTS.FSPAGEDETAILS pageDetails; - PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage.Value, out pageDetails)); + PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage, out pageDetails)); // There are 2 different types of PTS page and calculated rectangle depends on it: // (a) simple page (contains only one track) - get rectanglefrom the track. @@ -880,7 +880,7 @@ private PTS.FSBBOX GetBoundingBox() { // (2) PTS page - use page PTS APIs to get bounding box. PTS.FSPAGEDETAILS pageDetails; - PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage.Value, out pageDetails)); + PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage, out pageDetails)); // There are 2 different types of PTS page and bounding box calculation depends on it: // (a) simple page (contains only one track) - get bounding box from the track. @@ -1006,7 +1006,7 @@ private void UpdatePageVisuals(Size arrangeSize) // Get page details PTS.FSPAGEDETAILS pageDetails; - PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage.Value, out pageDetails)); + PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage, out pageDetails)); // If there is no change, visual information is valid if (pageDetails.fskupd == PTS.FSKUPDATE.fskupdNoChange) { return; } @@ -1069,7 +1069,7 @@ private void UpdatePageVisuals(Size arrangeSize) { // Retrieve description for each section. PTS.FSSECTIONDESCRIPTION [] arraySectionDesc; - PtsHelper.SectionListFromPage(PtsContext, _ptsPage.Value, ref pageDetails, out arraySectionDesc); + PtsHelper.SectionListFromPage(PtsContext, _ptsPage, ref pageDetails, out arraySectionDesc); emptyPage = (arraySectionDesc.Length == 0); if (!emptyPage) @@ -1205,7 +1205,7 @@ private IInputElement InputHitTestPage(PTS.FSPOINT pt) { // Get page details PTS.FSPAGEDETAILS pageDetails; - PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage.Value, out pageDetails)); + PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage, out pageDetails)); // Hittest page content. Page content may be simple or complex - // depending of set of features used in the content of the page. @@ -1233,7 +1233,7 @@ private IInputElement InputHitTestPage(PTS.FSPOINT pt) { // Retrieve description for each section. PTS.FSSECTIONDESCRIPTION [] arraySectionDesc; - PtsHelper.SectionListFromPage(PtsContext, _ptsPage.Value, ref pageDetails, out arraySectionDesc); + PtsHelper.SectionListFromPage(PtsContext, _ptsPage, ref pageDetails, out arraySectionDesc); // Hittest each section for (int index = 0; index < arraySectionDesc.Length && ie == null; index++) @@ -1264,7 +1264,7 @@ private List GetRectanglesInPage(ContentElement e, int start, int length) // Get page details PTS.FSPAGEDETAILS pageDetails; - PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage.Value, out pageDetails)); + PTS.Validate(PTS.FsQueryPageDetails(PtsContext.Context, _ptsPage, out pageDetails)); // Check for page content - if simple, contains only one track and we call the helper to // find the element within that track. If complex, we must traverse sections within the content. @@ -1287,7 +1287,7 @@ private List GetRectanglesInPage(ContentElement e, int start, int length) { // Retrieve description for each section. PTS.FSSECTIONDESCRIPTION[] arraySectionDesc; - PtsHelper.SectionListFromPage(PtsContext, _ptsPage.Value, ref pageDetails, out arraySectionDesc); + PtsHelper.SectionListFromPage(PtsContext, _ptsPage, ref pageDetails, out arraySectionDesc); // Check each section for element for (int index = 0; index < arraySectionDesc.Length; index++) @@ -1440,10 +1440,10 @@ private List GetRectanglesInSection( // ------------------------------------------------------------------ private void DestroyPage() { - if (_ptsPage.Value != IntPtr.Zero) + if (_ptsPage != IntPtr.Zero) { PtsContext.OnPageDisposed(_ptsPage, true, false); - _ptsPage.Value = IntPtr.Zero; + _ptsPage = IntPtr.Zero; } } @@ -1461,7 +1461,7 @@ private bool IsEmpty { get { - return (_ptsPage.Value == IntPtr.Zero); + return (_ptsPage == IntPtr.Zero); } } @@ -1514,7 +1514,7 @@ private bool IsEmpty // ------------------------------------------------------------------ // PTS page object. // ------------------------------------------------------------------ - private SecurityCriticalDataForSet _ptsPage; + private IntPtr _ptsPage; // ------------------------------------------------------------------ // Is it finite page? diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/SubpageParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/SubpageParaClient.cs index be107ade5de..6bfe8ee9848 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/SubpageParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/SubpageParaClient.cs @@ -49,10 +49,10 @@ public override void Dispose() { _visual = null; - if (_paraHandle.Value != IntPtr.Zero) + if (_paraHandle != IntPtr.Zero) { - PTS.Validate(PTS.FsDestroySubpage(PtsContext.Context, _paraHandle.Value)); - _paraHandle.Value = IntPtr.Zero; + PTS.Validate(PTS.FsDestroySubpage(PtsContext.Context, _paraHandle)); + _paraHandle = IntPtr.Zero; } base.Dispose(); @@ -71,7 +71,7 @@ protected override void OnArrange() // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); @@ -131,7 +131,7 @@ protected override void OnArrange() { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length; index++) @@ -176,7 +176,7 @@ internal override IInputElement InputHitTest(PTS.FSPOINT pt) // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Hittest subpage content. Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -194,7 +194,7 @@ internal override IInputElement InputHitTest(PTS.FSPOINT pt) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length && ie == null; index++) @@ -233,7 +233,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Check subpage content. Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -252,7 +252,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length; index++) @@ -285,7 +285,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Draw border and background info. MbpInfo mbpInfo = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); @@ -351,7 +351,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); emptySubpage = (arrayColumnDesc.Length == 0); if (!emptySubpage) @@ -420,7 +420,7 @@ internal override void UpdateViewport(ref PTS.FSRECT viewport) { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); PTS.FSRECT viewportSubpage = new PTS.FSRECT(); @@ -446,7 +446,7 @@ internal override void UpdateViewport(ref PTS.FSRECT viewport) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); emptySubpage = (arrayColumnDesc.Length == 0); if (!emptySubpage) @@ -478,7 +478,7 @@ internal override TextContentRange GetTextContentRange() // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -499,7 +499,7 @@ internal override TextContentRange GetTextContentRange() { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length; index++) @@ -549,7 +549,7 @@ internal ReadOnlyCollection GetColumnResults(out bool hasTextConte // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; - PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); + PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle, out subpageDetails)); // Subpage content may be simple or complex - // depending of set of features used in the content of the page. @@ -579,7 +579,7 @@ internal ReadOnlyCollection GetColumnResults(out bool hasTextConte { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; - PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); + PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle, ref subpageDetails, out arrayColumnDesc); columnResults = new List(subpageDetails.u.complex.cBasicColumns); for (int i = 0; i < arrayColumnDesc.Length; i++) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TableParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TableParaClient.cs index a6610632717..c65167c753c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TableParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TableParaClient.cs @@ -1379,7 +1379,7 @@ private unsafe bool QueryTableDetails( PTS.Validate(PTS.FsQueryTableObjDetails( PtsContext.Context, - _paraHandle.Value, + _paraHandle, out tableObjDetails)); Debug.Assert(TableParagraph == (TableParagraph)(PtsContext.HandleToObject(tableObjDetails.fsnmTable))); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TextParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TextParaClient.cs index 2cf57328fb2..e8ac5299ede 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TextParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/TextParaClient.cs @@ -60,7 +60,7 @@ internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Query paragraph details and render its content PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); VisualCollection visualChildren = _visual.Children; ContainerVisual lineContainerVisual = _visual; @@ -153,7 +153,7 @@ internal override void UpdateViewport(ref PTS.FSRECT viewport) { // Here's where the magic happens. PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); Invariant.Assert(textDetails.fsktd == PTS.FSKTEXTDETAILS.fsktdFull, "Only 'full' text paragraph type is expected."); if (IsDeferredVisualCreationSupported(ref textDetails.u.full)) @@ -173,7 +173,7 @@ internal override void UpdateViewport(ref PTS.FSRECT viewport) { // Get list of attached objects PTS.FSATTACHEDOBJECTDESCRIPTION [] arrayAttachedObjectDesc; - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, attachedObjectCount, out arrayAttachedObjectDesc); + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, attachedObjectCount, out arrayAttachedObjectDesc); // Arrange attached objects for (int index = 0; index < arrayAttachedObjectDesc.Length; index++) @@ -198,7 +198,7 @@ internal override IInputElement InputHitTest(PTS.FSPOINT pt) // Query paragraph details and hittest its content PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -257,7 +257,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng Debug.Assert(Paragraph.Element as ContentElement != e); PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -269,7 +269,7 @@ internal override List GetRectangles(ContentElement e, int start, int leng if (textDetails.u.full.cAttachedObjects > 0) { PTS.FSATTACHEDOBJECTDESCRIPTION[] arrayAttachedObjectDesc; - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); for (int index = 0; index < arrayAttachedObjectDesc.Length; index++) { @@ -349,7 +349,7 @@ internal ReadOnlyCollection GetLineResults() // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -390,7 +390,7 @@ internal ReadOnlyCollection GetFloaters() // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // Floaters are only supported by full paragraphs if ( textDetails.fsktd == PTS.FSKTEXTDETAILS.fsktdFull @@ -398,7 +398,7 @@ internal ReadOnlyCollection GetFloaters() { // Get list of floaters PTS.FSATTACHEDOBJECTDESCRIPTION [] arrayAttachedObjectDesc; - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); floaters = new List(arrayAttachedObjectDesc.Length); @@ -428,14 +428,14 @@ internal ReadOnlyCollection GetFigures() // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // Floaters are only supported by full paragraphs if ( textDetails.fsktd == PTS.FSKTEXTDETAILS.fsktdFull && textDetails.u.full.cAttachedObjects > 0) { PTS.FSATTACHEDOBJECTDESCRIPTION [] arrayAttachedObjectDesc; - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); figures = new List(arrayAttachedObjectDesc.Length); @@ -465,7 +465,7 @@ internal override TextContentRange GetTextContentRange() int dcpFirst = 0, dcpLast = 0; // Query paragraph details - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); Invariant.Assert(textDetails.fsktd == PTS.FSKTEXTDETAILS.fsktdFull, "Only 'full' text paragraph type is expected."); @@ -496,7 +496,7 @@ internal override TextContentRange GetTextContentRange() if (attachedObjectCount > 0) { // Get list of attached objects - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, attachedObjectCount, out arrayAttachedObjectDesc); + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, attachedObjectCount, out arrayAttachedObjectDesc); } // Figures and floaters cannot break @@ -521,7 +521,7 @@ internal void GetLineDetails(int dcpLine, out int cchContent, out int cchEllipse { // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); int lineWidth = 0; bool firstLine = (dcpLine == 0); @@ -540,7 +540,7 @@ internal void GetLineDetails(int dcpLine, out int cchContent, out int cchEllipse { // (a) full with simple lines PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails.u.full, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails.u.full, out arrayLineDesc); // Get lines information int index; @@ -564,7 +564,7 @@ internal void GetLineDetails(int dcpLine, out int cchContent, out int cchEllipse { // (b) full with composite lines - when figures/floaters are present PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails.u.full, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails.u.full, out arrayLineDesc); // Get lines information int index; @@ -636,7 +636,7 @@ internal override int GetFirstTextLineBaseline() { // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); Invariant.Assert(textDetails.fsktd == PTS.FSKTEXTDETAILS.fsktdFull, "Only 'full' text paragraph type is expected."); @@ -689,7 +689,7 @@ internal Rect GetRectangleFromTextPosition(ITextPointer position) // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -767,7 +767,7 @@ internal Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPo // query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -835,7 +835,7 @@ internal bool IsAtCaretUnitBoundary(ITextPointer position) // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -885,7 +885,7 @@ internal ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDir // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -928,7 +928,7 @@ internal ITextPointer GetBackspaceCaretUnitPosition(ITextPointer position) // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -975,7 +975,7 @@ internal ITextPointer GetTextPositionFromDistance(int dcpLine, double distance) // Query paragraph details int urDistance = TextDpi.ToTextDpi(distance); PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); if(ThisFlowDirection != PageFlowDirection) { @@ -999,7 +999,7 @@ internal ITextPointer GetTextPositionFromDistance(int dcpLine, double distance) { // (a) full with simple lines PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails.u.full, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails.u.full, out arrayLineDesc); // Get lines information int index; @@ -1024,7 +1024,7 @@ internal ITextPointer GetTextPositionFromDistance(int dcpLine, double distance) { // (b) full with composite lines - when figures/floaters are present PTS.FSLINEDESCRIPTIONCOMPOSITE [] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails.u.full, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails.u.full, out arrayLineDesc); // Get lines information int index; @@ -1112,7 +1112,7 @@ internal void GetGlyphRuns(List glyphRuns, ITextPointer start, ITextPo { // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -1178,7 +1178,7 @@ internal override bool IsFirstChunk { // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); Invariant.Assert(textDetails.fsktd == PTS.FSKTEXTDETAILS.fsktdFull, "Only 'full' text paragraph type is expected."); // The first chunk always starts with dcpFirst == 0. return (textDetails.u.full.cLines > 0 && textDetails.u.full.dcpFirst == 0); @@ -1196,7 +1196,7 @@ internal override bool IsLastChunk // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); Invariant.Assert(textDetails.fsktd == PTS.FSKTEXTDETAILS.fsktdFull, "Only 'full' text paragraph type is expected."); if (textDetails.u.full.cLines > 0) @@ -1242,7 +1242,7 @@ protected override void OnArrange() // Query paragraph details PTS.FSTEXTDETAILS textDetails; - PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle.Value, out textDetails)); + PTS.Validate(PTS.FsQueryTextDetails(PtsContext.Context, _paraHandle, out textDetails)); // There are 3 different types of text paragraphs: // (a) full with simple lines @@ -1258,7 +1258,7 @@ protected override void OnArrange() { // (a) full with simple lines PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails.u.full, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails.u.full, out arrayLineDesc); for (int index = 0; index < arrayLineDesc.Length; index++) { @@ -1284,7 +1284,7 @@ protected override void OnArrange() { // (b) full with composite lines - when figures/floaters are present PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails.u.full, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails.u.full, out arrayLineDesc); for (int index = 0; index < arrayLineDesc.Length; index++) { @@ -1320,7 +1320,7 @@ protected override void OnArrange() { // Get list of floaters PTS.FSATTACHEDOBJECTDESCRIPTION [] arrayAttachedObjectDesc; - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, textDetails.u.full.cAttachedObjects, out arrayAttachedObjectDesc); // Arrange floaters @@ -1402,7 +1402,7 @@ private void SyncUpdateDeferredLineVisuals(VisualCollection lineVisuals, ref PTS else if (_lineIndexFirstVisual != -1) { PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); int lineIndexToBeginRemoval = textDetails.cLinesBeforeChange; int cLinesToRemove = textDetails.cLinesChanged - textDetails.dcLinesChanged; @@ -1527,7 +1527,7 @@ private ReadOnlyCollection LineResultsFromSimpleLines(ref PTS.FSTEXT // Get list of complex lines. PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); List lines = new List(arrayLineDesc.Length); @@ -1579,7 +1579,7 @@ private ReadOnlyCollection LineResultsFromCompositeLines(ref PTS.FST // Get list of complex composite lines. PTS.FSLINEDESCRIPTIONCOMPOSITE [] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); List lines = new List(arrayLineDesc.Length); @@ -1648,7 +1648,7 @@ private void RectFromDcpSimpleLines( // Get list of lines PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // First iterate through lines for (int index = 0; index < arrayLineDesc.Length; index++) @@ -1736,7 +1736,7 @@ private void RectFromDcpCompositeLines( // Get list of lines PTS.FSLINEDESCRIPTIONCOMPOSITE [] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // First iterate through lines for (int index = 0; index < arrayLineDesc.Length; index++) @@ -1831,7 +1831,7 @@ private Geometry PathGeometryFromDcpRangeSimpleLines( // get list of lines PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); int lineStart = 0; int lineCount = arrayLineDesc.Length; @@ -1938,7 +1938,7 @@ private Geometry PathGeometryFromDcpRangeCompositeLines( // get list of lines PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); for (int lineIndex = 0; lineIndex < arrayLineDesc.Length; ++lineIndex) { @@ -2335,7 +2335,7 @@ private Geometry PathGeometryFromDcpRangeFloatersAndFigures( { // get list of attached objects PTS.FSATTACHEDOBJECTDESCRIPTION[] arrayAttachedObjectDesc; - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, textDetails.cAttachedObjects, out arrayAttachedObjectDesc); + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, textDetails.cAttachedObjects, out arrayAttachedObjectDesc); for (int index = 0; index < arrayAttachedObjectDesc.Length; ++index) { @@ -2378,7 +2378,7 @@ private bool IsAtCaretUnitBoundaryFromDcpSimpleLines( // Get list of lines PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); bool isAtCaretUnitBoundary = false; @@ -2470,7 +2470,7 @@ private bool IsAtCaretUnitBoundaryFromDcpCompositeLines( // Get list of lines PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); bool isAtCaretUnitBoundary = false; @@ -2596,7 +2596,7 @@ private ITextPointer NextCaretUnitPositionFromDcpSimpleLines( // Get list of lines PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Declare next position and set it to initial position ITextPointer nextCaretPosition = position; @@ -2721,7 +2721,7 @@ private ITextPointer NextCaretUnitPositionFromDcpCompositeLines( // Get list of lines PTS.FSLINEDESCRIPTIONCOMPOSITE [] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Declare next position and set it to initial position ITextPointer nextCaretPosition = position; @@ -2886,7 +2886,7 @@ private ITextPointer BackspaceCaretUnitPositionFromDcpSimpleLines( // Get list of lines PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Declare backspace position and set it to initial position ITextPointer backspaceCaretPosition = position; @@ -2978,7 +2978,7 @@ private ITextPointer BackspaceCaretUnitPositionFromDcpCompositeLines( // Get list of lines PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Declare backspace position and set it to initial position ITextPointer backspaceCaretPosition = position; @@ -3105,7 +3105,7 @@ private void GetGlyphRunsFromSimpleLines( // Get list of lines PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Iterate through all lines for (int index = 0; index < arrayLineDesc.Length; index++) @@ -3158,7 +3158,7 @@ private void GetGlyphRunsFromCompositeLines( // Get list of lines PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // First iterate through lines for (int index = 0; index < arrayLineDesc.Length; index++) @@ -3222,7 +3222,7 @@ private void RenderSimpleLines( // Get list of simple lines. PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Create lines and render them if (!PTS.ToBoolean(textDetails.fUpdateInfoForLinesPresent) || ignoreUpdateInfo) @@ -3393,7 +3393,7 @@ private void UpdateViewportSimpleLines( int cpTextParaStart = Paragraph.ParagraphStartCharacterPosition; PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // If this para is totally contained in the viewport, valid range is all lines. if (ContainedInRectOnV(ref viewport)) @@ -3560,7 +3560,7 @@ private void VerifyVisuals(ref PTS.FSTEXTDETAILSFULL textDetails) Debug.Assert(visualChildren.Count > 0 && textDetails.cLines > 0); PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); for(int index = _lineIndexFirstVisual; index < _lineIndexFirstVisual + visualChildren.Count; index++) { @@ -3593,7 +3593,7 @@ private void RenderCompositeLines( // Get list of composite lines. PTS.FSLINEDESCRIPTIONCOMPOSITE [] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Create lines and render them if (!PTS.ToBoolean(textDetails.fUpdateInfoForLinesPresent) || ignoreUpdateInfo) @@ -3749,7 +3749,7 @@ private void ValidateVisualFloatersAndFigures( // Get list of floaters PTS.FSATTACHEDOBJECTDESCRIPTION [] arrayAttachedObjectDesc; - PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle.Value, cAttachedObjects, + PtsHelper.AttachedObjectListFromParagraph(PtsContext, _paraHandle, cAttachedObjects, out arrayAttachedObjectDesc); // Render floaters. For each floater do following: @@ -3793,7 +3793,7 @@ private IInputElement InputHitTestSimpleLines( // Get list of complex lines. PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Find affected line by looking at vertical offset for (int index = 0; index < arrayLineDesc.Length; index++) @@ -3881,7 +3881,7 @@ private List GetRectanglesInSimpleLines( // Get list of complex lines. PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc; - PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Find affected line by looking at vertical offset for (int index = 0; index < arrayLineDesc.Length; index++) @@ -3973,7 +3973,7 @@ private IInputElement InputHitTestCompositeLines( // Get list of complex lines. PTS.FSLINEDESCRIPTIONCOMPOSITE [] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Find affected composite line by looking at vertical offset for (int index = 0; index < arrayLineDesc.Length; index++) @@ -4058,7 +4058,7 @@ private List GetRectanglesInCompositeLines( // Get list of complex lines. PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc; - PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc); + PtsHelper.LineListCompositeFromTextPara(PtsContext, _paraHandle, ref textDetails, out arrayLineDesc); // Find affected composite line by looking at vertical offset for (int index = 0; index < arrayLineDesc.Length; index++) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/UIElementParaClient.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/UIElementParaClient.cs index 80d098efbe0..f0a54bb7f68 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/UIElementParaClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/UIElementParaClient.cs @@ -61,7 +61,7 @@ protected override void OnArrange() base.OnArrange(); PTS.FSFLOATERDETAILS floaterDetails; - PTS.Validate(PTS.FsQueryFloaterDetails(PtsContext.Context, _paraHandle.Value, out floaterDetails)); + PTS.Validate(PTS.FsQueryFloaterDetails(PtsContext.Context, _paraHandle, out floaterDetails)); // Get paragraph's rectangle. _rect = floaterDetails.fsrcFloater; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs index 3b57c19121c..2c41b4cff29 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs @@ -132,12 +132,12 @@ public string DefaultDirectory get { // Avoid returning a null string - return String.Empty instead. - return _defaultDirectory.Value == null ? String.Empty : _defaultDirectory.Value; + return _defaultDirectory == null ? String.Empty : _defaultDirectory; } set { - _defaultDirectory.Value = value; + _defaultDirectory = value; } } @@ -171,12 +171,12 @@ public string InitialDirectory get { // Avoid returning a null string - return String.Empty instead. - return _initialDirectory.Value == null ? String.Empty : _initialDirectory.Value; + return _initialDirectory == null ? String.Empty : _initialDirectory; } set { - _initialDirectory.Value = value; + _initialDirectory = value; } } @@ -190,12 +190,12 @@ public string RootDirectory get { // Avoid returning a null string - return String.Empty instead. - return _rootDirectory.Value == null ? String.Empty : _rootDirectory.Value; + return _rootDirectory == null ? String.Empty : _rootDirectory; } set { - _rootDirectory.Value = value; + _rootDirectory = value; } } @@ -229,12 +229,12 @@ public string Title get { // Avoid returning a null string - return String.Empty instead. - return _title.Value == null ? String.Empty : _title.Value; + return _title == null ? String.Empty : _title; } set { - _title.Value = value; + _title = value; } } @@ -309,7 +309,7 @@ protected override bool RunDialog(IntPtr hwndOwner) /// internal bool GetOption(FOS option) { - return (_dialogOptions.Value & option) != 0; + return (_dialogOptions & option) != 0; } /// @@ -320,13 +320,13 @@ internal void SetOption(FOS option, bool value) if (value) { // if value is true, bitwise OR the option with _dialogOptions - _dialogOptions.Value |= option; + _dialogOptions |= option; } else { // if value is false, AND the bitwise complement of the // option with _dialogOptions - _dialogOptions.Value &= ~option; + _dialogOptions &= ~option; } } @@ -420,7 +420,7 @@ private protected virtual void PrepareDialog(IFileDialog dialog) dialog.SetTitle(Title); dialog.SetFileName(CriticalItemName); - FOS options = _dialogOptions.Value; + FOS options = _dialogOptions; dialog.SetOptions(options); IList places = CustomPlaces; @@ -535,7 +535,7 @@ private void Initialize() // // Initialize Options Flags // - _dialogOptions.Value = 0; // _dialogOptions is an int containing a set of + _dialogOptions = 0; // _dialogOptions is an int containing a set of // bit flags used to initialize the dialog box. // Within our code, we only use GetOption and SetOption // (change from Windows Forms, which sometimes directly @@ -561,10 +561,10 @@ private void Initialize() // Initialize additional properties // _itemNames = null; - _title.Value = null; - _initialDirectory.Value = null; - _defaultDirectory.Value = null; - _rootDirectory.Value = null; + _title = null; + _initialDirectory = null; + _defaultDirectory = null; + _rootDirectory = null; // Set this to an empty list so callers can simply add to it. They can also replace it wholesale. CustomPlaces = new List(); @@ -772,14 +772,14 @@ void IDisposable.Dispose() // _dialogOptions is a set of bit flags used to control the behavior // of the Win32 dialog box. - private SecurityCriticalDataForSet _dialogOptions; + private FOS _dialogOptions; // These private variables store data for the various public properties // that control the appearance of the file dialog box. - private SecurityCriticalDataForSet _title; // Title bar of the message box - private SecurityCriticalDataForSet _initialDirectory; // Starting directory - private SecurityCriticalDataForSet _defaultDirectory; // Starting directory if no recent - private SecurityCriticalDataForSet _rootDirectory; // Topmost directory + private string _title; // Title bar of the message box + private string _initialDirectory; // Starting directory + private string _defaultDirectory; // Starting directory if no recent + private string _rootDirectory; // Topmost directory // We store the handle of the file dialog inside our class // for a variety of purposes (like getting the title of the dialog diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs index 049e01d51c2..5d22a1791ed 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs @@ -1919,8 +1919,8 @@ private set //This will be cleaned up with the RootBrowserWindow cleanup. internal MimeType MimeType { - get { return _appMimeType.Value; } - set { _appMimeType = new SecurityCriticalDataForSet(value); } + get { return _appMimeType; } + set { _appMimeType = value; } } // this is called from ApplicationProxyInternal, ProgressBarAppHelper, and ContainerActivationHelper. @@ -2526,7 +2526,7 @@ private object RunDispatcher(object ignore) private bool _resourcesInitialized = false; private bool _reloadFluentDictionary = false; - private SecurityCriticalDataForSet _appMimeType; + private MimeType _appMimeType; private IServiceProvider _serviceProvider; private bool _appIsShutdown; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs index b137edda796..1cb7a260ed9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs @@ -141,9 +141,9 @@ private static void OnChildChanged(DependencyObject d, DependencyPropertyChanged // If the Popup is open, change the PopupRoot's child to show the new content. // Also change if the PopupRoot has a non-null child, to enable that // child to participate elsewhere in the visual tree - if ((popup._popupRoot.Value != null) && (popup.IsOpen || popup._popupRoot.Value.Child != null)) + if ((popup._popupRoot != null) && (popup.IsOpen || popup._popupRoot.Child != null)) { - popup._popupRoot.Value.Child = newChild; + popup._popupRoot.Child = newChild; } popup.RemoveLogicalChild(oldChild); @@ -1099,16 +1099,16 @@ private void OnPreviewMouseButton(MouseButtonEventArgs e) if (_cacheValid[(int)CacheBits.CaptureEngaged] && !StaysOpen && !_cacheValid[(int)CacheBits.IsIgnoringMouseEvents]) { - Debug.Assert( Mouse.Captured == _popupRoot.Value, "_cacheValid[(int)CacheBits.CaptureEngaged] == true but Mouse.Captured != _popupRoot"); + Debug.Assert( Mouse.Captured == _popupRoot, "_cacheValid[(int)CacheBits.CaptureEngaged] == true but Mouse.Captured != _popupRoot"); // If we got a mouse press/release and the mouse isn't on the popup (popup root), dismiss. // When captured to subtree, source will be the captured element for events outside the popup. - if (_popupRoot.Value != null && e.OriginalSource == _popupRoot.Value) + if (_popupRoot != null && e.OriginalSource == _popupRoot) { // When we have capture we will get all mouse button up/down messages. // We should close if the press was outside. The MouseButtonEventArgs don't tell whether we get this // message because we have capture or if it was legit, so we have to do a hit test. - if (_popupRoot.Value.InputHitTest(e.GetPosition(_popupRoot.Value)) == null) + if (_popupRoot.InputHitTest(e.GetPosition(_popupRoot)) == null) { // The hit test didn't find any element; that means the click happened outside the popup. SetCurrentValueInternal(IsOpenProperty, BooleanBoxes.FalseBox); @@ -1127,7 +1127,7 @@ private void OnPreviewMouseButton(MouseButtonEventArgs e) private void EstablishPopupCapture(bool isRestoringCapture=false) { - if (!_cacheValid[(int)CacheBits.CaptureEngaged] && (_popupRoot.Value != null) && + if (!_cacheValid[(int)CacheBits.CaptureEngaged] && (_popupRoot != null) && (!StaysOpen)) { IInputElement capturedElement = Mouse.Captured; @@ -1164,7 +1164,7 @@ private void EstablishPopupCapture(bool isRestoringCapture=false) // When the mouse is not already captured, we will consider the following: // In all cases but Modeless, we want the popup and subtree to receive // mouse events and prevent other elements from receiving those messages. - Mouse.Capture(_popupRoot.Value, CaptureMode.SubTree); + Mouse.Capture(_popupRoot, CaptureMode.SubTree); _cacheValid[(int)CacheBits.CaptureEngaged] = true; } } @@ -1178,7 +1178,7 @@ private void ReleasePopupCapture() ParentPopupRootField.ClearValue(this); // Only give up capture if we have it (someone may have taken it from us). - if (Mouse.Captured == _popupRoot.Value) + if (Mouse.Captured == _popupRoot) { if (parentPopupRoot == null) { @@ -1214,7 +1214,7 @@ private static void OnLostMouseCapture(object sender, MouseEventArgs e) // if (!popup.StaysOpen) { - PopupRoot root = popup._popupRoot.Value; + PopupRoot root = popup._popupRoot; // Reestablish capture if an element within us lost capture // (hence we receive the LostCapture routed event) and capture @@ -1318,8 +1318,8 @@ void IAddChild.AddText(string text) // Invalidate resources on the popup root internal override void OnThemeChanged() { - if (_popupRoot.Value != null) - TreeWalkHelper.InvalidateOnResourcesChange(_popupRoot.Value, null, ResourcesChangeInfo.ThemeChangeInfo); + if (_popupRoot != null) + TreeWalkHelper.InvalidateOnResourcesChange(_popupRoot, null, ResourcesChangeInfo.ThemeChangeInfo); } /// @@ -1442,7 +1442,7 @@ private Visual GetTarget() private void SetHitTestable(bool hitTestable) { - _popupRoot.Value.IsHitTestVisible = hitTestable; + _popupRoot.IsHitTestVisible = hitTestable; if (IsTransparent) { @@ -1462,13 +1462,13 @@ private static object AsyncCreateWindow(object arg) private void CreateNewPopupRoot() { - if (_popupRoot.Value == null) + if (_popupRoot == null) { - _popupRoot.Value = new PopupRoot(); - AddLogicalChild(_popupRoot.Value); + _popupRoot = new PopupRoot(); + AddLogicalChild(_popupRoot); // Allow users to set Width/Height properties on the Popup and have them // apply to the content. - _popupRoot.Value.SetupLayoutBindings(this); + _popupRoot.SetupLayoutBindings(this); } } @@ -1527,9 +1527,9 @@ private void CreateWindow(bool asyncCall) } UIElement child = Child; - if (_popupRoot.Value.Child != child) + if (_popupRoot.Child != child) { - _popupRoot.Value.Child = child; + _popupRoot.Child = child; } // When opening, set the placement target registration @@ -1547,7 +1547,7 @@ private void CreateWindow(bool asyncCall) isWindowAlive = _secHelper.IsWindowAlive(); if (isWindowAlive) { - _secHelper.ForceMsaaToUiaBridge(_popupRoot.Value); + _secHelper.ForceMsaaToUiaBridge(_popupRoot); } } else @@ -1572,10 +1572,10 @@ private void SetRootVisualToPopupRoot() // Later when the window is made visible, opacity is set to 1 // This is to prevent the first frame of the popup animations // from displaying - _popupRoot.Value.Opacity = 0.0; + _popupRoot.Opacity = 0.0; } - _secHelper.SetWindowRootVisual(_popupRoot.Value); + _secHelper.SetWindowRootVisual(_popupRoot); } private void BuildWindow(Visual targetVisual) @@ -1647,7 +1647,7 @@ private void ShowWindow() { if (_secHelper.IsWindowAlive()) { - _popupRoot.Value.Opacity = 1.0; + _popupRoot.Opacity = 1.0; SetupAnimations(true); @@ -1694,20 +1694,20 @@ private bool SetupAnimations(bool visible) { PopupAnimation animation = PopupAnimation; - _popupRoot.Value.StopAnimations(); + _popupRoot.StopAnimations(); // Only animate if popup is transparent if (animation != PopupAnimation.None && IsTransparent) { if (animation == PopupAnimation.Fade) { - _popupRoot.Value.SetupFadeAnimation(AnimationDelayTime, visible); + _popupRoot.SetupFadeAnimation(AnimationDelayTime, visible); return true; } else if (visible) // only translate when showing popup { // translate the content - _popupRoot.Value.SetupTranslateAnimations(animation, AnimationDelayTime, AnimateFromRight, AnimateFromBottom); + _popupRoot.SetupTranslateAnimations(animation, AnimationDelayTime, AnimateFromRight, AnimateFromBottom); return true; } } @@ -1850,7 +1850,7 @@ private void UpdateTransform() popupTransform.Scale(transformedUnitX.Length, transformedUnitY.Length); } - _popupRoot.Value.Transform = new MatrixTransform(popupTransform); + _popupRoot.Transform = new MatrixTransform(popupTransform); } private void OnWindowResize(object sender, AutoResizedEventArgs e) @@ -1999,7 +1999,7 @@ private class PositionInfo // the browser area for partial trust private void UpdatePosition() { - if (_popupRoot.Value == null) + if (_popupRoot == null) return; PlacementMode placement = PlacementInternal; @@ -2125,7 +2125,7 @@ private void UpdatePosition() // Popups are not nudged if their axes do not align with the screen axes // Use the size of the popupRoot in case it is clipping the popup content - childBounds = new Rect((Size)_secHelper.GetTransformToDevice().Transform((Point)_popupRoot.Value.RenderSize)); + childBounds = new Rect((Size)_secHelper.GetTransformToDevice().Transform((Point)_popupRoot.RenderSize)); childBounds.Offset(bestTranslation); screenBounds = GetScreenBounds(targetBounds, placementTargetInterestPoints[(int)InterestPoint.TopLeft]); @@ -2398,10 +2398,10 @@ private Point[] GetChildInterestPoints(PlacementMode placement) } // Use remove the render transform translation from the child - Vector offset = _popupRoot.Value.AnimationOffset; + Vector offset = _popupRoot.AnimationOffset; // Transform InterestPoints to popup's space - GeneralTransform childToPopupTransform = TransformToClient(child, _popupRoot.Value); + GeneralTransform childToPopupTransform = TransformToClient(child, _popupRoot); for (int i = 0; i < 5; i++) { @@ -2910,7 +2910,7 @@ private bool IsDragDropActive private PositionInfo _positionInfo; - private SecurityCriticalDataForSet _popupRoot; + private PopupRoot _popupRoot; private DispatcherOperation _asyncCreate; private DispatcherTimer _asyncDestroy; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs index c25c198001c..9f9fe44c19b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs @@ -688,11 +688,11 @@ internal bool NavigatingToAboutBlank { get { - return _navigatingToAboutBlank.Value; + return _navigatingToAboutBlank; } set { - _navigatingToAboutBlank.Value = value; + _navigatingToAboutBlank = value; } } @@ -704,11 +704,11 @@ internal Guid LastNavigation { get { - return _lastNavigation.Value; + return _lastNavigation; } set { - _lastNavigation.Value = value; + _lastNavigation = value; } } @@ -989,16 +989,16 @@ protected override bool TabIntoCore(TraversalRequest request) // Reference to the native ActiveX control's IWebBrowser2 // Do not reference this directly. Use the AxIWebBrowser2 property instead since that // will cause the object to be instantiated if it is not already created. - private UnsafeNativeMethods.IWebBrowser2 _axIWebBrowser2; + private UnsafeNativeMethods.IWebBrowser2 _axIWebBrowser2; - WebOCHostingAdaptor _hostingAdaptor; + WebOCHostingAdaptor _hostingAdaptor; // To hook up events from the native WebBrowser - private ConnectionPointCookie _cookie; - private object _objectForScripting; - private Stream _documentStream; + private ConnectionPointCookie _cookie; + private object _objectForScripting; + private Stream _documentStream; - private SecurityCriticalDataForSet _navigatingToAboutBlank; + private bool _navigatingToAboutBlank; /// /// TFS - Launching a navigation from the Navigating event handler causes reentrancy. @@ -1007,7 +1007,7 @@ protected override bool TabIntoCore(TraversalRequest request) /// we shouldn't clean up the shared state touched by the last navigation (see WebBrowserEvent's /// BeforeNavigate2 method), so that the newly started navigation can continue. /// - private SecurityCriticalDataForSet _lastNavigation; + private Guid _lastNavigation; #endregion Private Fields diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Hyperlink.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Hyperlink.cs index e716ae08041..a645154eb98 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Hyperlink.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Hyperlink.cs @@ -366,7 +366,7 @@ internal static object CoerceNavigateUri(DependencyObject d, object value) // (Or, instead of setting NavigateUri=null, add a handler for Hyperlink.RequestNavigateEvent and // set e.Handled=true.) // - if (s_criticalNavigateUriProtectee.Value == d.GetHashCode() && ShouldPreventUriSpoofing) + if (s_criticalNavigateUriProtectee == d.GetHashCode() && ShouldPreventUriSpoofing) { value = DependencyProperty.UnsetValue; } @@ -527,7 +527,7 @@ protected internal override void OnMouseLeftButtonUp(MouseButtonEventArgs e) /// We keep one per thread in case multiple threads would be involved in the spoofing attack. /// [ThreadStatic] - private static SecurityCriticalDataForSet s_cachedNavigateUri; + private static Uri s_cachedNavigateUri; /// /// Identification code of the hyperlink element currently protected against spoofing attacks. @@ -539,7 +539,7 @@ protected internal override void OnMouseLeftButtonUp(MouseButtonEventArgs e) /// We keep one per thread in case multiple threads would be involved in the spoofing attack. /// [ThreadStatic] - private static SecurityCriticalDataForSet s_criticalNavigateUriProtectee; + private static int? s_criticalNavigateUriProtectee; /// /// Caches a target URI for spoofing prevention. @@ -553,7 +553,7 @@ private static void CacheNavigateUri(DependencyObject d, Uri targetUri) // d.VerifyAccess(); - s_cachedNavigateUri.Value = targetUri; + s_cachedNavigateUri = targetUri; } /// @@ -575,7 +575,7 @@ private static void NavigateToUri(IInputElement sourceElement, Uri targetUri, st // // Spoofing countermeasure makes sure the URI hasn't changed since display in the status bar. // - Uri cachedUri = Hyperlink.s_cachedNavigateUri.Value; + Uri cachedUri = Hyperlink.s_cachedNavigateUri; // ShouldPreventUriSpoofing is checked last in order to avoid incurring a first-chance SecurityException // in common scenarios. if (cachedUri == null || cachedUri.Equals(targetUri) || !ShouldPreventUriSpoofing) @@ -623,7 +623,7 @@ private static void UpdateStatusBar(object sender) // Keep the identification code for the element that's to be protected against spoofing // attacks because its URI is shown on the status bar. // - s_criticalNavigateUriProtectee.Value = dObject.GetHashCode(); + s_criticalNavigateUriProtectee = dObject.GetHashCode(); // // Cache URI for spoofing countermeasures. @@ -664,7 +664,7 @@ private static void ClearStatusBarAndCachedUri(object sender) // // Clear the identification code for the element that was protected against spoofing. // - s_criticalNavigateUriProtectee.Value = null; + s_criticalNavigateUriProtectee = null; } #endregion @@ -831,14 +831,14 @@ static bool ShouldPreventUriSpoofing { get { - if (!s_shouldPreventUriSpoofing.Value.HasValue) + if (!s_shouldPreventUriSpoofing.HasValue) { - s_shouldPreventUriSpoofing.Value = false; + s_shouldPreventUriSpoofing = false; } - return (bool)s_shouldPreventUriSpoofing.Value; + return (bool)s_shouldPreventUriSpoofing; } } - static SecurityCriticalDataForSet s_shouldPreventUriSpoofing; + static bool? s_shouldPreventUriSpoofing; #endregion Private Properties diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs index 08579c01e13..4231671f8bb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs @@ -606,7 +606,7 @@ private void EnumerateSuggestions() // Convert the VARIANT to string, and add it to our list. // There's some special magic here. The VARIANT is VT_UI2/ByRef. // But under the hood it's really a raw WCHAR *. - suggestions.Add(Marshal.PtrToStringUni(variant.data1.Value)); + suggestions.Add(Marshal.PtrToStringUni(variant.data1)); } } finally diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs index 7e6af8c6955..06e56056c9c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs @@ -2822,13 +2822,13 @@ private void PrepareAttributes(InputScope inputScope, double fontSize, FontFamil case AttributeStyle.InputScope: object obj = new InputScopeAttribute(inputScope); attrval.val.vt = (short)NativeMethods.tagVT.VT_UNKNOWN; - attrval.val.data1.Value = Marshal.GetIUnknownForObject(obj); + attrval.val.data1 = Marshal.GetIUnknownForObject(obj); break; case AttributeStyle.Font_Style_Height: // We always evaluate the font size and returns a value. attrval.val.vt = (short)NativeMethods.tagVT.VT_I4; - attrval.val.data1.Value = (IntPtr)(int)fontSize; + attrval.val.data1 = (IntPtr)(int)fontSize; break; case AttributeStyle.Font_FaceName: @@ -2837,24 +2837,24 @@ private void PrepareAttributes(InputScope inputScope, double fontSize, FontFamil if (familyName != null) { attrval.val.vt = (short)NativeMethods.tagVT.VT_BSTR; - attrval.val.data1.Value = Marshal.StringToBSTR(familyName); + attrval.val.data1 = Marshal.StringToBSTR(familyName); } } break; case AttributeStyle.Font_SizePts: attrval.val.vt = (short)NativeMethods.tagVT.VT_I4; - attrval.val.data1.Value = (IntPtr)(int)(fontSize / 96.0 * 72.0); + attrval.val.data1 = (IntPtr)(int)(fontSize / 96.0 * 72.0); break; case AttributeStyle.Text_ReadOnly: attrval.val.vt = (short)NativeMethods.tagVT.VT_BOOL; - attrval.val.data1.Value = IsReadOnly ? (IntPtr)1 : (IntPtr)0; + attrval.val.data1 = IsReadOnly ? (IntPtr)1 : (IntPtr)0; break; case AttributeStyle.Text_Orientation: attrval.val.vt = (short)NativeMethods.tagVT.VT_I4; - attrval.val.data1.Value = (IntPtr)0; + attrval.val.data1 = (IntPtr)0; // Get the transformation that is relative from source. PresentationSource source = null; @@ -2889,7 +2889,7 @@ private void PrepareAttributes(InputScope inputScope, double fontSize, FontFamil else angle = 360 - angleCos; - attrval.val.data1.Value = (IntPtr)((int)angle * 10); + attrval.val.data1 = (IntPtr)((int)angle * 10); } } } @@ -2901,7 +2901,7 @@ private void PrepareAttributes(InputScope inputScope, double fontSize, FontFamil // the vertical writing is not supported yet // attrval.val.vt = (short)NativeMethods.tagVT.VT_BOOL; - attrval.val.data1.Value = (IntPtr)0; + attrval.val.data1 = (IntPtr)0; break; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/WinEventHandler.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/WinEventHandler.cs index e9f80dd1154..1a34ad9cce7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/WinEventHandler.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/WinEventHandler.cs @@ -35,9 +35,9 @@ internal WinEventHandler(int eventMin, int eventMax) _eventMin = eventMin; _eventMax = eventMax; - _winEventProc.Value = new NativeMethods.WinEventProcDef(WinEventDefaultProc); + _winEventProc = new NativeMethods.WinEventProcDef(WinEventDefaultProc); // Keep the garbage collector from moving things around - _gchThis = GCHandle.Alloc(_winEventProc.Value); + _gchThis = GCHandle.Alloc(_winEventProc); // Workaround for bug 150666. _shutdownListener = new WinEventHandlerShutDownListener(this); @@ -88,9 +88,9 @@ internal void Start() { if (_gchThis.IsAllocated) { - _hHook.Value = UnsafeNativeMethods.SetWinEventHook(_eventMin, _eventMax, IntPtr.Zero, _winEventProc.Value, + _hHook = UnsafeNativeMethods.SetWinEventHook(_eventMin, _eventMax, IntPtr.Zero, _winEventProc, 0, 0, NativeMethods.WINEVENT_OUTOFCONTEXT); - if (_hHook.Value == IntPtr.Zero ) + if (_hHook == IntPtr.Zero ) { Stop(); } @@ -100,10 +100,10 @@ internal void Start() // uninstall WinEvent hook. internal void Stop() { - if (_hHook.Value != IntPtr.Zero ) + if (_hHook != IntPtr.Zero ) { - UnsafeNativeMethods.UnhookWinEvent(_hHook.Value); - _hHook.Value = IntPtr.Zero ; + UnsafeNativeMethods.UnhookWinEvent(_hHook); + _hHook = IntPtr.Zero ; } if (_shutdownListener != null) @@ -163,10 +163,10 @@ internal override void OnShutDown(object target, object sender, EventArgs e) private int _eventMax; // hook handle - private SecurityCriticalDataForSet _hHook; + private IntPtr _hHook; // the callback. - private SecurityCriticalDataForSet _winEventProc; + private NativeMethods.WinEventProcDef _winEventProc; // GCHandle to keep the garbage collector from moving things around private GCHandle _gchThis; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs index 08b45b165da..1d15cd774f3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs @@ -103,7 +103,7 @@ internal ActiveXHost(Guid clsid, bool fTrusted ) : base( fTrusted ) } #pragma warning restore 0618 - _clsid.Value = clsid; + _clsid = clsid; // hookup so we are notified when loading is finished. Initialized += new EventHandler(OnInitialized); @@ -570,7 +570,7 @@ private void TransitionFromPassiveToLoaded() // First, create the ActiveX control Debug.Assert(_axInstance == null, "_axInstance must be null"); - _axInstance = CreateActiveXObject(_clsid.Value); + _axInstance = CreateActiveXObject(_clsid); Debug.Assert(_axInstance != null, "w/o an exception being thrown we must have an object..."); // @@ -1051,7 +1051,7 @@ private NativeMethods.SIZE GetExtent() #region ActiveX Related - private SecurityCriticalDataForSet _clsid; + private Guid _clsid; private HandleRef _axWindow; private BitVector32 _axHostState = new BitVector32(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs index 731a79ec19d..69c2e3af5fd 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs @@ -74,8 +74,8 @@ public static object ClientSite internal static HostingFlags HostingFlags { - get { return _hostingFlags.Value; } - set { _hostingFlags.Value = value; } + get { return _hostingFlags; } + set { _hostingFlags = value; } } /// @@ -124,11 +124,11 @@ internal static bool IsInitialViewerNavigation { get { - return IsViewer && _isInitialViewerNavigation.Value; + return IsViewer && _isInitialViewerNavigation; } set { - _isInitialViewerNavigation.Value = value; + _isInitialViewerNavigation = value; } } @@ -148,9 +148,9 @@ internal static UnsafeNativeMethods.IServiceProvider HostHtmlDocumentServiceProv // not to run with a null service provider for sake of security. // See InitializeHostHtmlDocumentServiceProvider as well. /* TODO: straighten this with browser flags to check only when hosted in IE */ - Invariant.Assert(!(_initializedHostScript.Value && _hostHtmlDocumentServiceProvider.Value == null)); + Invariant.Assert(!(_initializedHostScript && _hostHtmlDocumentServiceProvider == null)); - return _hostHtmlDocumentServiceProvider.Value; + return _hostHtmlDocumentServiceProvider; } } @@ -159,7 +159,7 @@ private static void InitializeHostHtmlDocumentServiceProvider(DynamicScriptObjec // The service provider is used for Internet Explorer IDispatchEx use. if ( IsHostedInIEorWebOC && scriptObject.ScriptObject is UnsafeNativeMethods.IHTMLWindow4 - && _hostHtmlDocumentServiceProvider.Value == null) + && _hostHtmlDocumentServiceProvider == null) { // We use the IDispatch infrastructure to gain access to the document DOM node where // the IServiceProvider lives that was recommended to us by IE people. Notice during @@ -176,11 +176,11 @@ private static void InitializeHostHtmlDocumentServiceProvider(DynamicScriptObjec // document property and because we're dealing with IE, we know it has a service // provider on it. Invariant.Assert(foundDoc); - _hostHtmlDocumentServiceProvider.Value = (UnsafeNativeMethods.IServiceProvider)document; + _hostHtmlDocumentServiceProvider = (UnsafeNativeMethods.IServiceProvider)document; // See HostHtmlDocumentServiceProvider property get accessor for more information on the use of // this field to ensure we got a valid service provider. - _initializedHostScript.Value = true; + _initializedHostScript = true; } } @@ -226,18 +226,18 @@ internal static void InitializeHostFilterInput() private static void EnsureScriptInteropAllowed() { - if (_isScriptInteropDisabled.Value == null) + if (_isScriptInteropDisabled == null) { - _isScriptInteropDisabled.Value = SafeSecurityHelper.IsFeatureDisabled(SafeSecurityHelper.KeyToRead.ScriptInteropDisable); + _isScriptInteropDisabled = SafeSecurityHelper.IsFeatureDisabled(SafeSecurityHelper.KeyToRead.ScriptInteropDisable); } } - private static SecurityCriticalDataForSet _hostingFlags; - private static SecurityCriticalDataForSet _isInitialViewerNavigation; - private static SecurityCriticalDataForSet _isScriptInteropDisabled; + private static HostingFlags _hostingFlags; + private static bool _isInitialViewerNavigation; + private static bool? _isScriptInteropDisabled; - private static SecurityCriticalDataForSet _hostHtmlDocumentServiceProvider; - private static SecurityCriticalDataForSet _initializedHostScript; + private static UnsafeNativeMethods.IServiceProvider _hostHtmlDocumentServiceProvider; + private static bool _initializedHostScript; [DllImport(ExternDll.PresentationHostDll, EntryPoint="ForwardTranslateAccelerator")] private static extern int ForwardTranslateAccelerator(ref MSG pMsg, bool appUnhandled); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs index 9da4a5fc08d..4f073391cc2 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs @@ -135,7 +135,7 @@ public event DpiChangedEventHandler DpiChanged protected override void OnKeyUp(KeyEventArgs e) { MSG msg; - if (_fTrusted.Value) + if (_fTrusted) { msg = ComponentDispatcher.UnsecureCurrentKeyboardMessage; } @@ -169,7 +169,7 @@ protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi) protected override void OnKeyDown(KeyEventArgs e) { MSG msg; - if (_fTrusted.Value) + if (_fTrusted) { msg = ComponentDispatcher.UnsecureCurrentKeyboardMessage; } @@ -490,7 +490,7 @@ protected virtual void Dispose(bool disposing) if (_hwndSubclass != null) { // Check if it is trusted (WebOC and AddInHost), call CriticalDetach to avoid the Demand. - if (_fTrusted.Value == true) + if (_fTrusted == true) { _hwndSubclass.CriticalDetach(false); } @@ -829,7 +829,7 @@ private DrawingGroup GetDrawingHelper() private void Initialize( bool fTrusted ) { - _fTrusted = new SecurityCriticalDataForSet ( fTrusted ) ; + _fTrusted = fTrusted; _hwndSubclassHook = new HwndWrapperHook(SubclassWndProc); _handlerLayoutUpdated = new EventHandler(OnLayoutUpdated); @@ -845,7 +845,7 @@ private void Initialize( bool fTrusted ) /// private void DemandIfUntrusted() { - if ( ! _fTrusted.Value ) + if ( ! _fTrusted ) { } } @@ -1171,7 +1171,7 @@ private IntPtr SubclassWndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lPara /// private bool _hasDpiAwarenessContextTransition = false; - private SecurityCriticalDataForSet _fTrusted ; + private bool _fTrusted; private bool _isBuildingWindow = false; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/ParserContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/ParserContext.cs index 863cb98e0a2..79e3d3358ef 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/ParserContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/ParserContext.cs @@ -397,9 +397,9 @@ internal bool SkipJournaledProperties // internal Assembly StreamCreatedAssembly { - get { return _streamCreatedAssembly.Value; } + get { return _streamCreatedAssembly; } - set { _streamCreatedAssembly.Value = value; } + set { _streamCreatedAssembly = value; } } #endif @@ -654,7 +654,7 @@ internal ParserContext ScopedCopy(bool copyNameScopeStack) context._xamlTypeMapper = _xamlTypeMapper; context._targetType = _targetType; - context._streamCreatedAssembly.Value = _streamCreatedAssembly.Value; + context._streamCreatedAssembly = _streamCreatedAssembly; context._rootElement = _rootElement; context._styleConnector = _styleConnector; @@ -830,7 +830,7 @@ internal Freezable TryGetFreezable(string value) #if !PBTCOMPILER private bool _skipJournaledProperties; - private SecurityCriticalDataForSet _streamCreatedAssembly; + private Assembly _streamCreatedAssembly; private bool _ownsBamlStream; private ProvideValueServiceProvider _provideValueServiceProvider; private IStyleConnector _styleConnector; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs index 91dabdb5ac6..dc4729fca43 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs @@ -3282,11 +3282,11 @@ internal int _Style { if (Manager != null) { - return _styleDoNotUse.Value; + return _styleDoNotUse; } else if ( IsSourceWindowNull ) { - return _styleDoNotUse.Value; + return _styleDoNotUse; } else { @@ -3295,7 +3295,7 @@ internal int _Style } set { - _styleDoNotUse= new SecurityCriticalDataForSet(value); + _styleDoNotUse = value; Manager.Dirty = true; } } @@ -3306,11 +3306,11 @@ internal int _StyleEx { if (Manager != null) { - return _styleExDoNotUse.Value; + return _styleExDoNotUse; } else if (IsSourceWindowNull == true ) { - return _styleExDoNotUse.Value; + return _styleExDoNotUse; } else { @@ -3319,7 +3319,7 @@ internal int _StyleEx } set { - _styleExDoNotUse= new SecurityCriticalDataForSet((int)value); + _styleExDoNotUse = value; Manager.Dirty = true; } } @@ -6895,8 +6895,8 @@ internal void Flush() HwndStyleManager manager = Manager; if (manager.Dirty && CriticalHandle != IntPtr.Zero) { - UnsafeNativeMethods.CriticalSetWindowLong(new HandleRef(this,CriticalHandle), NativeMethods.GWL_STYLE, (IntPtr)_styleDoNotUse.Value); - UnsafeNativeMethods.CriticalSetWindowLong(new HandleRef(this,CriticalHandle), NativeMethods.GWL_EXSTYLE, (IntPtr)_styleExDoNotUse.Value); + UnsafeNativeMethods.CriticalSetWindowLong(new HandleRef(this,CriticalHandle), NativeMethods.GWL_STYLE, (IntPtr)_styleDoNotUse); + UnsafeNativeMethods.CriticalSetWindowLong(new HandleRef(this,CriticalHandle), NativeMethods.GWL_EXSTYLE, (IntPtr)_styleExDoNotUse); UnsafeNativeMethods.SetWindowPos(new HandleRef(this, CriticalHandle), NativeMethods.NullHandleRef, 0, 0, 0, 0, NativeMethods.SWP_NOMOVE | @@ -7344,8 +7344,8 @@ private EventHandlerList Events // These should never be used directly, access only through property accessors - private SecurityCriticalDataForSet _styleDoNotUse; - private SecurityCriticalDataForSet _styleExDoNotUse; + private int _styleDoNotUse; + private int _styleExDoNotUse; private HwndStyleManager _manager; // reference to Resize Grip control; this is used to find out whether diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs index 2cf56b75e0d..f43554e4839 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs @@ -221,7 +221,7 @@ internal bool IsDestinationIdenticalToSource #if DEBUG ThrowIfDisposed(); #endif - return ChainOfDependencies.GetLast(this)._isDestinationIdenticalToSource.Value; + return ChainOfDependencies.GetLast(this)._isDestinationIdenticalToSource; } set @@ -229,7 +229,7 @@ internal bool IsDestinationIdenticalToSource #if DEBUG ThrowIfDisposed(); #endif - ChainOfDependencies.GetLast(this)._isDestinationIdenticalToSource.Value = value; + ChainOfDependencies.GetLast(this)._isDestinationIdenticalToSource = value; } } @@ -285,7 +285,7 @@ internal Uri Uri #if DEBUG ThrowIfDisposed(); #endif - return ChainOfDependencies.GetLast(this)._uri.Value; + return ChainOfDependencies.GetLast(this)._uri; } set @@ -293,7 +293,7 @@ internal Uri Uri #if DEBUG ThrowIfDisposed(); #endif - ChainOfDependencies.GetLast(this)._uri = new SecurityCriticalData(value); + ChainOfDependencies.GetLast(this)._uri = value; } } @@ -334,11 +334,11 @@ private void ThrowIfDisposed() // Private Fields //-------------------------------------------------------------------------- - private SecurityCriticalData _uri; + private Uri _uri; private bool _isCopySafe = true; - private SecurityCriticalDataForSet _isDestinationIdenticalToSource; + private bool _isDestinationIdenticalToSource; private bool _isRebindNeeded; private bool _isReloadNeeded; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/PackageDocument.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/PackageDocument.cs index 3f4d4ac4cbf..74e1521fc42 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/PackageDocument.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/PackageDocument.cs @@ -72,9 +72,9 @@ internal override Stream Workspace /// internal TransactionalPackage Package { - get { return _package.Value; } + get { return _package; } - set { _package.Value = value; } + set { _package = value; } } #endregion Internal Properties @@ -110,7 +110,7 @@ protected override void Dispose(bool disposing) //-------------------------------------------------------------------------- // Private Fields //-------------------------------------------------------------------------- - private SecurityCriticalDataForSet _package; + private TransactionalPackage _package; #endregion Private Fields } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RestrictedTransactionalPackage.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RestrictedTransactionalPackage.cs index 59353c0e482..00ab3a60dfe 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RestrictedTransactionalPackage.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RestrictedTransactionalPackage.cs @@ -48,9 +48,9 @@ internal override void MergeChanges(Stream target) { ArgumentNullException.ThrowIfNull(target); - if (TempPackage.Value != null) + if (TempPackage != null) { - foreach (PackagePart part in TempPackage.Value.GetParts()) + foreach (PackagePart part in TempPackage.GetParts()) { // Ensure that all parts being modified are permitted. if ((part != null) && (!IsValidContentType(part.ContentType))) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsController.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsController.cs index 481d7ff5279..66020d164bd 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsController.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsController.cs @@ -57,7 +57,7 @@ bool IDocumentController.EnableEdit(Document document) try { encryptedPackage = - _provider.Value.EncryptPackage(ciphered); + _provider.EncryptPackage(ciphered); if (encryptedPackage != null) { @@ -125,7 +125,7 @@ bool IDocumentController.Open(Document document) RightsManagementProvider provider = new RightsManagementProvider(doc.SourcePackage); - _provider.Value = provider; + _provider = provider; try { @@ -171,7 +171,7 @@ bool IDocumentController.Open(Document document) // If anything failed here, we cannot use the provider any longer, // so we can dispose it provider.Dispose(); - _provider.Value = null; + _provider = null; throw; } @@ -184,7 +184,7 @@ bool IDocumentController.Open(Document document) // If decryption failed, we can no longer do anything with the // provider instance or the current RM manager provider.Dispose(); - _provider.Value = null; + _provider = null; } return true; @@ -334,7 +334,7 @@ bool IDocumentController.SavePreperation(Document document) doc.DestinationProxy = new StreamProxy(clear); // save the use license in case the user acquired one - _provider.Value.SaveUseLicense(doc.DestinationPackage); + _provider.SaveUseLicense(doc.DestinationPackage); handled = true; @@ -356,7 +356,7 @@ bool IDocumentController.SavePreperation(Document document) "Cannot save with changes if Edit permission was not granted."); EncryptedPackageEnvelope encryptedPackage = - _provider.Value.EncryptPackage(ciphered); + _provider.EncryptPackage(ciphered); // the destination is intended to be encrypted when a non-null // value is returned @@ -423,14 +423,14 @@ bool IChainOfResponsibiltyNode.IsResponsible(Document subject) /// void IDisposable.Dispose() { - IDisposable provider = _provider.Value as IDisposable; + IDisposable provider = _provider as IDisposable; if (provider != null) { provider.Dispose(); } - _provider.Value = null; + _provider = null; GC.SuppressFinalize(this); } @@ -506,7 +506,7 @@ private static void CloseEnvelope(EncryptedPackageEnvelope envelope) // Private Fields //-------------------------------------------------------------------------- - private static SecurityCriticalDataForSet _provider; + private static IRightsManagementProvider _provider; #endregion Private Fields } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsDocument.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsDocument.cs index f843114a11a..cdcc7adba7f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsDocument.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsDocument.cs @@ -75,9 +75,9 @@ internal bool IsSourceProtected() /// internal EncryptedPackageEnvelope DestinationPackage { - get { return _destination.Value; } + get { return _destination; } - set { _destination.Value = value; } + set { _destination = value; } } /// @@ -86,9 +86,9 @@ internal EncryptedPackageEnvelope DestinationPackage /// internal EncryptedPackageEnvelope SourcePackage { - get { return _source.Value; } + get { return _source; } - set { _source.Value = value; } + set { _source = value; } } /// @@ -97,9 +97,9 @@ internal EncryptedPackageEnvelope SourcePackage /// internal EncryptedPackageEnvelope WorkspacePackage { - get { return _workspace.Value; } + get { return _workspace; } - set { _workspace.Value = value; } + set { _workspace = value; } } #endregion Internal Properties @@ -172,11 +172,11 @@ protected override void Dispose(bool disposing) // Private Fields //-------------------------------------------------------------------------- - private SecurityCriticalDataForSet _source; + private EncryptedPackageEnvelope _source; - private SecurityCriticalDataForSet _workspace; + private EncryptedPackageEnvelope _workspace; - private SecurityCriticalDataForSet _destination; + private EncryptedPackageEnvelope _destination; #endregion Private Fields } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsManagementSuppressedStream.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsManagementSuppressedStream.cs index 8dc5461c648..37aa8d548bb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsManagementSuppressedStream.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsManagementSuppressedStream.cs @@ -32,7 +32,7 @@ internal sealed class RightsManagementSuppressedStream : StreamProxy internal RightsManagementSuppressedStream(Stream targetOfProxy, bool isWriteAllowed) : base(targetOfProxy, true) { - _allowWrite.Value = isWriteAllowed; + _allowWrite = isWriteAllowed; } #endregion Constructors @@ -182,7 +182,7 @@ private bool AllowWrite { get { - return _allowWrite.Value; + return _allowWrite; } } @@ -196,7 +196,7 @@ private bool AllowWrite /// /// Whether or not the proxy should enforce that the stream is read-only. /// - private SecurityCriticalDataForSet _allowWrite; + private bool _allowWrite; #endregion Private Fields } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamDocument.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamDocument.cs index d541ec07914..d62034da8e1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamDocument.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamDocument.cs @@ -37,7 +37,7 @@ internal StreamDocument(Document dependency) /// internal override Stream Destination { - get { return _destination.Value; } + get { return _destination; } } /// @@ -45,8 +45,8 @@ internal override Stream Destination /// internal T DestinationProxy { - get { return _destination.Value; } - set { _destination.Value = value; } + get { return _destination; } + set { _destination = value; } } /// @@ -54,7 +54,7 @@ internal T DestinationProxy /// internal override Stream Source { - get { return _source.Value; } + get { return _source; } } /// @@ -62,8 +62,8 @@ internal override Stream Source /// internal T SourceProxy { - get { return _source.Value; } - set { _source.Value = value; } + get { return _source; } + set { _source = value; } } /// @@ -71,7 +71,7 @@ internal T SourceProxy /// internal override Stream Workspace { - get { return _workspace.Value; } + get { return _workspace; } } /// @@ -79,8 +79,8 @@ internal override Stream Workspace /// internal T WorkspaceProxy { - get { return _workspace.Value; } - set { _workspace.Value = value; } + get { return _workspace; } + set { _workspace = value; } } #endregion Internal Properties @@ -160,12 +160,9 @@ protected override void Dispose(bool disposing) // Private Fields //-------------------------------------------------------------------------- - private SecurityCriticalDataForSet _destination = - new SecurityCriticalDataForSet(); - private SecurityCriticalDataForSet _source = - new SecurityCriticalDataForSet(); - private SecurityCriticalDataForSet _workspace = - new SecurityCriticalDataForSet(); + private T _destination; + private T _source; + private T _workspace; #endregion Private Fields } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamProxy.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamProxy.cs index 91b1d5e5409..3629144f021 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamProxy.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/StreamProxy.cs @@ -49,8 +49,8 @@ internal StreamProxy(Stream targetOfProxy) /// to read-only. internal StreamProxy(Stream targetOfProxy, bool isTargetReadOnly) { - _proxy.Value = targetOfProxy; - _isTargetReadOnly.Value = isTargetReadOnly; + _proxy = targetOfProxy; + _isTargetReadOnly = isTargetReadOnly; } #endregion Constructors @@ -65,7 +65,7 @@ internal StreamProxy(Stream targetOfProxy, bool isTargetReadOnly) /// public override bool CanRead { - get { return _proxy.Value.CanRead; } + get { return _proxy.CanRead; } } /// @@ -73,7 +73,7 @@ public override bool CanRead /// public override bool CanSeek { - get { return _proxy.Value.CanSeek; } + get { return _proxy.CanSeek; } } /// @@ -83,7 +83,7 @@ public override bool CanTimeout { get { - return _proxy.Value.CanTimeout; + return _proxy.CanTimeout; } } @@ -92,7 +92,7 @@ public override bool CanTimeout /// public override bool CanWrite { - get { return _proxy.Value.CanWrite; } + get { return _proxy.CanWrite; } } /// @@ -100,7 +100,7 @@ public override bool CanWrite /// public override void Close() { - _proxy.Value.Close(); + _proxy.Close(); } /// @@ -108,7 +108,7 @@ public override void Close() /// public override void Flush() { - _proxy.Value.Flush(); + _proxy.Flush(); } /// @@ -116,7 +116,7 @@ public override void Flush() /// public override long Length { - get { return _proxy.Value.Length; } + get { return _proxy.Length; } } /// @@ -126,11 +126,11 @@ public override long Position { get { - return _proxy.Value.Position; + return _proxy.Position; } set { - _proxy.Value.Position = value; + _proxy.Position = value; } } @@ -139,7 +139,7 @@ public override long Position /// public override int Read(byte[] buffer, int offset, int count) { - return _proxy.Value.Read(buffer, offset, count); + return _proxy.Read(buffer, offset, count); } /// @@ -149,11 +149,11 @@ public override int ReadTimeout { get { - return _proxy.Value.ReadTimeout; + return _proxy.ReadTimeout; } set { - _proxy.Value.ReadTimeout = value; + _proxy.ReadTimeout = value; } } @@ -162,7 +162,7 @@ public override int ReadTimeout /// public override long Seek(long offset, SeekOrigin origin) { - return _proxy.Value.Seek(offset, origin); + return _proxy.Seek(offset, origin); } /// @@ -170,7 +170,7 @@ public override long Seek(long offset, SeekOrigin origin) /// public override void SetLength(long value) { - _proxy.Value.SetLength(value); + _proxy.SetLength(value); } /// @@ -178,7 +178,7 @@ public override void SetLength(long value) /// public override void Write(byte[] buffer, int offset, int count) { - _proxy.Value.Write(buffer, offset, count); + _proxy.Write(buffer, offset, count); } /// @@ -188,11 +188,11 @@ public override int WriteTimeout { get { - return _proxy.Value.WriteTimeout; + return _proxy.WriteTimeout; } set { - _proxy.Value.WriteTimeout = value; + _proxy.WriteTimeout = value; } } @@ -210,10 +210,10 @@ protected override void Dispose(bool disposing) } finally { - if (disposing && _proxy.Value != null) + if (disposing && _proxy != null) { - _proxy.Value.Dispose(); - _proxy.Value = null; + _proxy.Dispose(); + _proxy = null; } } } @@ -230,7 +230,7 @@ protected override void Dispose(bool disposing) /// public override int GetHashCode() { - return _proxy.Value.GetHashCode(); + return _proxy.GetHashCode(); } /// @@ -238,7 +238,7 @@ public override int GetHashCode() /// public override bool Equals(object obj) { - return _proxy.Value.Equals(obj); + return _proxy.Equals(obj); } #endregion Object Overrides @@ -250,12 +250,12 @@ public override bool Equals(object obj) internal Stream Target { - get { return _proxy.Value; } + get { return _proxy; } set { - if (!_isTargetReadOnly.Value) + if (!_isTargetReadOnly) { - _proxy.Value = value; + _proxy = value; } else { @@ -271,8 +271,8 @@ internal Stream Target // Private Fields //-------------------------------------------------------------------------- - SecurityCriticalDataForSet _proxy; - SecurityCriticalDataForSet _isTargetReadOnly; + Stream _proxy; + bool _isTargetReadOnly; #endregion Private Fields } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/TransactionalPackage.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/TransactionalPackage.cs index 64323daca28..47e40abf3f5 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/TransactionalPackage.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/TransactionalPackage.cs @@ -68,8 +68,8 @@ internal TransactionalPackage(Stream original) Package originalPackage = Package.Open(original); - _originalPackage = new SecurityCriticalDataForSet(originalPackage); - _tempPackage = new SecurityCriticalDataForSet(null); + _originalPackage = originalPackage; + _tempPackage = null; } #endregion Constructors @@ -93,7 +93,7 @@ internal void EnableEditMode(Stream workspace) Package temporaryPackage = Package.Open( workspace, FileMode.Create, FileAccess.ReadWrite); - _tempPackage = new SecurityCriticalDataForSet(temporaryPackage); + _tempPackage = temporaryPackage; } /// @@ -107,12 +107,12 @@ internal virtual void MergeChanges(Stream target) throw new InvalidOperationException(); } - if (_tempPackage.Value != null) + if (_tempPackage != null) { Package destination = Package.Open( target, FileMode.Open, FileAccess.ReadWrite); - foreach (PackagePart part in _tempPackage.Value.GetParts()) + foreach (PackagePart part in _tempPackage.GetParts()) { if (destination.PartExists(part.Uri)) { @@ -150,8 +150,8 @@ internal void Rebind(Stream newOriginal) ArgumentNullException.ThrowIfNull(newOriginal); // close this as we will open a new one - _originalPackage.Value.Close(); - _trashCan.Add(_originalPackage.Value); + _originalPackage.Close(); + _trashCan.Add(_originalPackage); _isDirty = false; Package newPackage = Package.Open(newOriginal, FileMode.Open, FileAccess.Read); @@ -166,7 +166,7 @@ internal void Rebind(Stream newOriginal) } } - _originalPackage.Value = newPackage; + _originalPackage = newPackage; } #endregion Internal Methods @@ -220,7 +220,7 @@ protected override PackagePart CreatePartCore( EnsureTempPackage(); // the underlying temp package does all the physical work - PackagePart result = _tempPackage.Value.CreatePart( + PackagePart result = _tempPackage.CreatePart( partUri, contentType, compressionOption); Uri normalizedPartUri = PackUriHelper.GetNormalizedPartUri(partUri); @@ -268,9 +268,9 @@ protected override PackagePart CreatePartCore( protected override void DeletePartCore(Uri partUri) { // Skipping parameter validation as it is done by CreatePart. - if (_tempPackage.Value.PartExists(partUri)) + if (_tempPackage.PartExists(partUri)) { - _tempPackage.Value.DeletePart(partUri); + _tempPackage.DeletePart(partUri); Trace.SafeWrite(Trace.Packaging, "Part {0} deleted.", partUri); } @@ -292,16 +292,16 @@ protected override void Dispose(bool disposing) if (disposing) { - if (_tempPackage.Value != null) + if (_tempPackage != null) { - ((IDisposable)_tempPackage.Value).Dispose(); - _tempPackage.Value = null; + ((IDisposable)_tempPackage).Dispose(); + _tempPackage = null; } - if (_originalPackage.Value != null) + if (_originalPackage != null) { - ((IDisposable)_originalPackage.Value).Dispose(); - _originalPackage.Value = null; + ((IDisposable)_originalPackage).Dispose(); + _originalPackage = null; } _activeParts.Clear(); @@ -319,9 +319,9 @@ protected override void Dispose(bool disposing) /// protected override void FlushCore() { - if (_tempPackage.Value != null) + if (_tempPackage != null) { - _tempPackage.Value.Flush(); + _tempPackage.Flush(); } } @@ -382,9 +382,9 @@ protected override PackagePart GetPartCore(Uri partUri) // or the temporary package, this method will return null. bool canGetFromTempPackage = - (_tempPackage.Value != null) && (_tempPackage.Value.PartExists(partUri)); + (_tempPackage != null) && (_tempPackage.PartExists(partUri)); bool canGetFromOriginalPackage = - canGetFromTempPackage ? false : _originalPackage.Value.PartExists(partUri); + canGetFromTempPackage ? false : _originalPackage.PartExists(partUri); if (_activeParts.ContainsKey(normalizedPartUri) && (canGetFromTempPackage || canGetFromOriginalPackage)) @@ -393,7 +393,7 @@ protected override PackagePart GetPartCore(Uri partUri) } else if (canGetFromTempPackage) { - result = _tempPackage.Value.GetPart(partUri); + result = _tempPackage.GetPart(partUri); result = new WriteableOnDemandPackagePart( this, result, TempPackagePartFactory); @@ -409,7 +409,7 @@ protected override PackagePart GetPartCore(Uri partUri) } else if (canGetFromOriginalPackage) { - PackagePart original = _originalPackage.Value.GetPart(partUri); + PackagePart original = _originalPackage.GetPart(partUri); result = new WriteableOnDemandPackagePart( this, original, TempPackagePartFactory); @@ -438,7 +438,7 @@ protected override PackagePart GetPartCore(Uri partUri) protected override PackagePart[] GetPartsCore() { // need to call get parts from the underlying reading package - PackagePartCollection parts = _originalPackage.Value.GetParts(); + PackagePartCollection parts = _originalPackage.GetParts(); // // a temporary list of proxied package parts which will be use to fill return value List _proxiedParts = new List(); @@ -462,7 +462,7 @@ protected override PackagePart[] GetPartsCore() // Protected Properties //------------------------------------------------------------------------- - protected SecurityCriticalDataForSet TempPackage + protected Package TempPackage { get { @@ -496,13 +496,13 @@ private static void CopyPackagePartStream(PackagePart original, PackagePart copy private void EnsureTempPackage() { // if we can not edit ask for it - if (_tempPackage.Value == null) + if (_tempPackage == null) { DocumentManager.CreateDefault().EnableEdit(null); } // if we still don't have it fail - if (_tempPackage.Value == null) + if (_tempPackage == null) { throw new InvalidOperationException( SR.PackagingWriteNotSupported); @@ -532,7 +532,7 @@ private PackagePart TempPackagePartFactory(PackagePart packagePart) PackagePart temp = null; - if (!_tempPackage.Value.PartExists(partUri)) + if (!_tempPackage.PartExists(partUri)) { Trace.SafeWrite( Trace.Packaging, @@ -541,7 +541,7 @@ private PackagePart TempPackagePartFactory(PackagePart packagePart) _isDirty = true; - temp = _tempPackage.Value.CreatePart( + temp = _tempPackage.CreatePart( partUri, packagePart.ContentType, packagePart.CompressionOption); @@ -556,7 +556,7 @@ private PackagePart TempPackagePartFactory(PackagePart packagePart) } else { - temp = _tempPackage.Value.GetPart(partUri); + temp = _tempPackage.GetPart(partUri); Trace.SafeWrite( Trace.Packaging, @@ -584,11 +584,11 @@ private PackagePart TempPackagePartFactory(PackagePart packagePart) /// /// The original Package; this one is to be treated as read-only. /// - private SecurityCriticalDataForSet _originalPackage; + private Package _originalPackage; /// /// The temporary Package; this is the one we work in. /// - private SecurityCriticalDataForSet _tempPackage; + private Package _tempPackage; private List _trashCan = new List(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignature.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignature.cs index 2a839d9d853..1aa2d0bda2e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignature.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignature.cs @@ -38,12 +38,12 @@ internal SignatureStatus SignatureState { get { - return _signatureState.Value; + return _signatureState; } set { - _signatureState.Value = value; + _signatureState = value; } } @@ -54,12 +54,12 @@ internal string SubjectName { get { - return _subjectName.Value; + return _subjectName; } set { - _subjectName.Value = value; + _subjectName = value; } } @@ -70,12 +70,12 @@ internal string Reason { get { - return _reason.Value; + return _reason; } set { - _reason.Value = value; + _reason = value; } } @@ -86,11 +86,11 @@ internal DateTime? SignedOn { get { - return _signedOn.Value; + return _signedOn; } set { - _signedOn.Value = value; + _signedOn = value; } } @@ -101,12 +101,12 @@ internal string Location { get { - return _location.Value; + return _location; } set { - _location.Value = value; + _location = value; } } @@ -117,12 +117,12 @@ internal bool IsDocumentPropertiesRestricted { get { - return _isDocumentPropertiesRestricted.Value; + return _isDocumentPropertiesRestricted; } set { - _isDocumentPropertiesRestricted.Value = value; + _isDocumentPropertiesRestricted = value; } } @@ -133,12 +133,12 @@ internal bool IsAddingSignaturesRestricted { get { - return _isAddingSignaturesRestricted.Value; + return _isAddingSignaturesRestricted; } set { - _isAddingSignaturesRestricted.Value = value; + _isAddingSignaturesRestricted = value; } } @@ -149,12 +149,12 @@ internal Guid? GuidID { get { - return _guidID.Value; + return _guidID; } set { - _guidID.Value = value; + _guidID = value; } } @@ -165,12 +165,12 @@ internal X509Certificate2 Certificate { get { - return _x509Certificate2.Value; + return _x509Certificate2; } set { - _x509Certificate2.Value = value; + _x509Certificate2 = value; } } @@ -182,12 +182,12 @@ internal XpsDigitalSignature XpsDigitalSignature { get { - return _xpsDigitalSignature.Value; + return _xpsDigitalSignature; } set { - _xpsDigitalSignature.Value = value; + _xpsDigitalSignature = value; } } @@ -198,49 +198,49 @@ internal XpsDigitalSignature XpsDigitalSignature /// /// Status of signature (Valid, Invalid, NotSigned ...) /// - private SecurityCriticalDataForSet _signatureState; + private SignatureStatus _signatureState; /// /// Friendly name of the signer (obtained from the certificate) /// - private SecurityCriticalDataForSet _subjectName; + private string _subjectName; /// /// Intent: From the Signature Definition /// - private SecurityCriticalDataForSet _reason; + private string _reason; /// /// When this signature was applied (not a trusted time) /// - private SecurityCriticalDataForSet _signedOn; + private DateTime? _signedOn; /// /// Location field (what signer type into signature definition) /// - private SecurityCriticalDataForSet _location; + private string _location; /// /// Whether or not document properties changes are restricted by this signature /// - private SecurityCriticalDataForSet _isDocumentPropertiesRestricted; + private bool _isDocumentPropertiesRestricted; /// /// Whether or not adding signatures will invalidate this signature /// - private SecurityCriticalDataForSet _isAddingSignaturesRestricted; + private bool _isAddingSignaturesRestricted; /// /// SignatureID /// - private SecurityCriticalDataForSet _guidID; + private Guid? _guidID; - private SecurityCriticalDataForSet _x509Certificate2; + private X509Certificate2 _x509Certificate2; /// /// The XpsDigitalSignature associated with this signature /// - private SecurityCriticalDataForSet _xpsDigitalSignature; + private XpsDigitalSignature _xpsDigitalSignature; #endregion Private data } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignatureProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignatureProvider.cs index 87369ff375e..d215f5bd654 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignatureProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignatureProvider.cs @@ -77,13 +77,13 @@ bool IDigitalSignatureProvider.IsSignable { get { - if (!_isSignableCacheValid.Value) + if (!_isSignableCacheValid) { - _isSignableCache.Value = XpsDocument.IsSignable; - _isSignableCacheValid.Value = true; + _isSignableCache = XpsDocument.IsSignable; + _isSignableCacheValid = true; } - return _isSignableCache.Value; + return _isSignableCache; } } @@ -361,13 +361,13 @@ ReadOnlyCollection IDigitalSignatureProvider.Signatures DigitalSignatureList = GetSignaturesFromPackage(); } - if (_readOnlySignatureList.Value == null) + if (_readOnlySignatureList == null) { - _readOnlySignatureList.Value = + _readOnlySignatureList = new ReadOnlyCollection(DigitalSignatureList); } - return _readOnlySignatureList.Value; + return _readOnlySignatureList; } } @@ -681,11 +681,11 @@ private void AssertIsSignable() // We assert that _isSignableCacheValid is true here -- // we don't want to block on calling XpsDocument.IsSignable so we // require calling code do that work prior to invoking SignDocument. - Invariant.Assert(_isSignableCacheValid.Value); + Invariant.Assert(_isSignableCacheValid); // Assert that the document is actually signable. We should never // get here if it's not. - Invariant.Assert(_isSignableCache.Value); + Invariant.Assert(_isSignableCache); } #endregion Private Methods @@ -704,12 +704,12 @@ private XpsDocument XpsDocument { get { - return _xpsDocument.Value; + return _xpsDocument; } set { - _xpsDocument.Value = value; + _xpsDocument = value; } } @@ -721,12 +721,12 @@ private IXpsFixedDocumentReader FixedDocument { get { - return _fixedDocument.Value; + return _fixedDocument; } set { - _fixedDocument.Value = value; + _fixedDocument = value; } } @@ -737,12 +737,12 @@ private IXpsFixedDocumentSequenceReader FixedDocumentSequence { get { - return _fixedDocumentSequence.Value; + return _fixedDocumentSequence; } set { - _fixedDocumentSequence.Value = value; + _fixedDocumentSequence = value; } } @@ -773,17 +773,17 @@ private IList DigitalSignatureList /// /// The XPS document from which to read signatures. /// - SecurityCriticalDataForSet _xpsDocument; + XpsDocument _xpsDocument; /// /// The fixed document sequence to which to write signature definitions. /// - SecurityCriticalDataForSet _fixedDocumentSequence; + IXpsFixedDocumentSequenceReader _fixedDocumentSequence; /// /// The fixed document to which to write signature definitions. /// - SecurityCriticalDataForSet _fixedDocument; + IXpsFixedDocumentReader _fixedDocument; /// /// A list of all the signatures in the package. @@ -795,7 +795,7 @@ private IList DigitalSignatureList /// around _digitalSignatureList that is intended to be passed out by /// the Signatures property. /// - SecurityCriticalDataForSet> _readOnlySignatureList; + ReadOnlyCollection _readOnlySignatureList; //Contains all known flags that don't convert to Corrupted. //(All flags except Cyclic and NotSignatureValid). We will be looking for unknown flags using this @@ -851,8 +851,8 @@ private IList DigitalSignatureList /// /// Cached value for the IsSignable property /// - private SecurityCriticalDataForSet _isSignableCache; - private SecurityCriticalDataForSet _isSignableCacheValid; + private bool _isSignableCache; + private bool _isSignableCacheValid; #endregion Private Fields } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentApplicationDocumentViewer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentApplicationDocumentViewer.cs index fc2b1d4496a..d0a2e44f370 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentApplicationDocumentViewer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentApplicationDocumentViewer.cs @@ -179,7 +179,7 @@ public RightsManagementPolicy RightsManagementPolicy { get { - return _rightsManagementPolicy.Value; + return _rightsManagementPolicy; } } @@ -242,7 +242,7 @@ public void InitializeUI(DocumentSignatureManager docSigManager, DocumentRightsM _docSigManager.SignatureStatusChange += new DocumentSignatureManager.SignatureStatusChangeHandler(_digSigInfoBar.OnStatusChange); //We disallow all RM-protected actions until the RM Manager tells us otherwise. - _rightsManagementPolicy.Value = RightsManagementPolicy.AllowNothing; + _rightsManagementPolicy = RightsManagementPolicy.AllowNothing; CommandEnforcer.Enforce(); _rmManager = rmManager; @@ -1069,7 +1069,7 @@ private CommandEnforcer CommandEnforcer { get { - return _commandEnforcer.Value; + return _commandEnforcer; } } @@ -1630,7 +1630,7 @@ private void OnRMPolicyChanged(object sender, DocumentRightsManagementManager.Ri ArgumentNullException.ThrowIfNull(args); //Invoke the CommandEnforcer to enable/disable commands as appropriate. - _rightsManagementPolicy.Value = args.RMPolicy; + _rightsManagementPolicy = args.RMPolicy; CommandEnforcer.Enforce(); } @@ -2166,7 +2166,7 @@ private void CreateEnforcer() enforcer.AddBinding(new PolicyBinding(DocumentApplicationDocumentViewer.Sign, RightsManagementPolicy.AllowSign)); enforcer.AddBinding(new PolicyBinding(DocumentApplicationDocumentViewer.RequestSigners, RightsManagementPolicy.AllowSign)); - _commandEnforcer.Value = enforcer; + _commandEnforcer = enforcer; } #endregion Commands @@ -2197,11 +2197,11 @@ private void CreateEnforcer() private StatusInfoItem _rmInfoBar; private DocumentApplicationState _state; private const int _invalidPageNumber = -1; - private SecurityCriticalDataForSet _rightsManagementPolicy; + private RightsManagementPolicy _rightsManagementPolicy; private RightsManagementStatus _rightsManagementStatus; // The enforcer for RM - private SecurityCriticalDataForSet _commandEnforcer; + private CommandEnforcer _commandEnforcer; // Declare commands that are located on DocumentApplicationDocumentViewer private static RoutedUICommand _focusToolBarCommand; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentSignatureManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentSignatureManager.cs index cb8cc097744..e64cf0cdb82 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentSignatureManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DocumentSignatureManager.cs @@ -191,7 +191,7 @@ internal void Evaluate() //Fire the events. OnSignatureStatusChange(calcSigStatus); - _signaturePolicy.Value = calcSigPolicy; + _signaturePolicy = calcSigPolicy; } /// @@ -1160,11 +1160,11 @@ private void OnRMPolicyChanged(object sender, DocumentRightsManagementManager.Ri if ((args.RMPolicy & RightsManagementPolicy.AllowSign) == RightsManagementPolicy.AllowSign) { - _allowSign.Value = true; + _allowSign = true; } else { - _allowSign.Value = false; + _allowSign = false; } } @@ -1295,12 +1295,12 @@ private IDigitalSignatureProvider DigitalSignatureProvider { get { - return _digitalSignatureProvider.Value; + return _digitalSignatureProvider; } set { - _digitalSignatureProvider.Value = value; + _digitalSignatureProvider = value; } } @@ -1313,7 +1313,7 @@ private bool IsSigningAllowed { get { - return _allowSign.Value; + return _allowSign; } } @@ -1325,7 +1325,7 @@ private bool IsSigningAllowedByPolicy { get { - return IsAllowedByPolicy(_signaturePolicy.Value, SignaturePolicy.AllowSigning); + return IsAllowedByPolicy(_signaturePolicy, SignaturePolicy.AllowSigning); } } @@ -1344,12 +1344,12 @@ private bool IsSigningAllowedByPolicy /// The IDigitalSignatureProvider associated with this instance of the /// digital signature manager. /// - private SecurityCriticalDataForSet _digitalSignatureProvider; + private IDigitalSignatureProvider _digitalSignatureProvider; private IDictionary _digSigSigResources; - private SecurityCriticalDataForSet _allowSign; + private bool _allowSign; - private SecurityCriticalDataForSet _signaturePolicy; + private SignaturePolicy _signaturePolicy; /// /// The change log that is used to roll back signatures on failure. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementLicense.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementLicense.cs index 7824a449f8d..5f37777acc3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementLicense.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementLicense.cs @@ -35,7 +35,7 @@ internal sealed class RightsManagementLicense /// The permission to add. internal void AddPermission(RightsManagementPermissions permission) { - _userRights.Value |= permission; + _userRights |= permission; } /// @@ -45,7 +45,7 @@ internal void AddPermission(RightsManagementPermissions permission) /// Whether or not the license grants the permission internal bool HasPermission(RightsManagementPermissions permission) { - return (((_userRights.Value & permission) == permission) && IsLicenseValid); + return (((_userRights & permission) == permission) && IsLicenseValid); } /// @@ -54,7 +54,7 @@ internal bool HasPermission(RightsManagementPermissions permission) /// The permissions granted, converted to a policy internal RightsManagementPolicy ConvertToPolicy() { - return (RightsManagementPolicy)(_userRights.Value); + return (RightsManagementPolicy)(_userRights); } #endregion Internal Methods @@ -94,9 +94,9 @@ internal bool IsLicenseValid /// internal DateTime ValidFrom { - get { return _validFrom.Value; } + get { return _validFrom; } - set { _validFrom.Value = value; } + set { _validFrom = value; } } /// @@ -105,9 +105,9 @@ internal DateTime ValidFrom /// internal DateTime ValidUntil { - get { return _validUntil.Value; } + get { return _validUntil; } - set { _validUntil.Value = value; } + set { _validUntil = value; } } /// @@ -115,9 +115,9 @@ internal DateTime ValidUntil /// internal RightsManagementUser LicensedUser { - get { return _user.Value; } + get { return _user; } - set { _user.Value = value; } + set { _user = value; } } /// @@ -125,9 +125,9 @@ internal RightsManagementUser LicensedUser /// internal RightsManagementPermissions LicensePermissions { - get { return _userRights.Value; } + get { return _userRights; } - set { _userRights.Value = value; } + set { _userRights = value; } } /// @@ -160,10 +160,10 @@ internal Uri ReferralInfoUri // Private Fields //------------------------------------------------------ - private SecurityCriticalDataForSet _validFrom; - private SecurityCriticalDataForSet _validUntil; - private SecurityCriticalDataForSet _user; - private SecurityCriticalDataForSet _userRights; + private DateTime _validFrom; + private DateTime _validUntil; + private RightsManagementUser _user; + private RightsManagementPermissions _userRights; /// /// The name of the person to contact for more rights. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementManager.cs index 1c3d4f77bc0..728b96d01ac 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementManager.cs @@ -44,7 +44,7 @@ private DocumentRightsManagementManager(IRightsManagementProvider rmProvider) { ArgumentNullException.ThrowIfNull(rmProvider); - _rmProviderCache.Value = rmProvider; + _rmProviderCache = rmProvider; //Create dictionary for Credential Management //used to map between CredManResources and RM Users @@ -70,12 +70,12 @@ internal static void Initialize(IRightsManagementProvider rmProvider) Trace.SafeWrite(Trace.Rights, "Initializing RightsManagementManager"); System.Diagnostics.Debug.Assert( - _currentManager.Value == null, + _currentManager == null, "RightsManagementManager initialized twice."); - if (_currentManager.Value == null) + if (_currentManager == null) { - _currentManager.Value = new DocumentRightsManagementManager(rmProvider); + _currentManager = new DocumentRightsManagementManager(rmProvider); } } @@ -715,7 +715,7 @@ internal static DocumentRightsManagementManager Current { get { - return _currentManager.Value; + return _currentManager; } } @@ -1470,7 +1470,7 @@ private IRightsManagementProvider _rmProvider { get { - return _rmProviderCache.Value; + return _rmProviderCache; } } @@ -1481,8 +1481,8 @@ private IRightsManagementProvider _rmProvider // Private Fields //------------------------------------------------------ - private static SecurityCriticalDataForSet _currentManager; - private SecurityCriticalDataForSet _rmProviderCache; + private static DocumentRightsManagementManager _currentManager; + private IRightsManagementProvider _rmProviderCache; /// /// A handle to a currently open instance of the credential manager dialog diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs index 594954b4147..da7fe05244d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs @@ -68,7 +68,7 @@ bool IRightsManagementProvider.IsProtected /// RightsManagementLicense IRightsManagementProvider.CurrentUseLicense { - get { return _rmUseLicense.Value; } + get { return _rmUseLicense; } } /// @@ -87,8 +87,8 @@ PublishLicense IRightsManagementProvider.CurrentPublishLicense _currentPublishLicense = value; // Invalidate the saved use license and grants - _useLicense.Value = null; - _rmUseLicense.Value = null; + _useLicense = null; + _rmUseLicense = null; } } @@ -97,7 +97,7 @@ PublishLicense IRightsManagementProvider.CurrentPublishLicense /// RightsManagementUser IRightsManagementProvider.CurrentUser { - get { return _user.Value; } + get { return _user; } } /// @@ -142,7 +142,7 @@ void IRightsManagementProvider.InitializeEnvironment(EnrollmentAccountType accou } } - _secureEnvironment.Value = SecureEnvironment.Create( + _secureEnvironment = SecureEnvironment.Create( GetApplicationManifest(), authType, userActMode); @@ -171,12 +171,12 @@ void IRightsManagementProvider.InitializeEnvironment(RightsManagementUser user) InitializeMembers(); CleanUpSecureEnvironment(); - _secureEnvironment.Value = SecureEnvironment.Create( + _secureEnvironment = SecureEnvironment.Create( GetApplicationManifest(), user); Trace.SafeWriteIf( - (_secureEnvironment.Value != null), + (_secureEnvironment != null), Trace.Rights, "SecureEnvironment was initialized for a specific user."); @@ -200,12 +200,12 @@ bool IRightsManagementProvider.LoadUseLicense() UseLicense useLicense; useLicense = _encryptedPackageEnvelope - .RightsManagementInformation.LoadUseLicense(_user.Value); + .RightsManagementInformation.LoadUseLicense(_user); if (useLicense != null) { Trace.SafeWrite(Trace.Rights, "Existing use license was found."); - _useLicense.Value = useLicense; + _useLicense = useLicense; } return (useLicense != null); @@ -229,7 +229,7 @@ bool IRightsManagementProvider.AcquireUseLicense() try { - useLicense = CurrentPublishLicense.AcquireUseLicense(_secureEnvironment.Value); + useLicense = CurrentPublishLicense.AcquireUseLicense(_secureEnvironment); } catch(RightsManagementException e) { @@ -240,7 +240,7 @@ bool IRightsManagementProvider.AcquireUseLicense() { Trace.SafeWrite(Trace.Rights, "A new use license was acquired."); - _useLicense.Value = useLicense; + _useLicense = useLicense; } else { @@ -265,7 +265,7 @@ void IRightsManagementProvider.SaveUseLicense(EncryptedPackageEnvelope package) SR.RMProviderExceptionNoPackageToDecrypt); } - if (_useLicense.Value == null) + if (_useLicense == null) { throw new InvalidOperationException( SR.RMProviderExceptionNoUseLicense); @@ -279,7 +279,7 @@ void IRightsManagementProvider.SaveUseLicense(EncryptedPackageEnvelope package) if (package.FileOpenAccess != FileAccess.Read) { package.RightsManagementInformation. - SaveUseLicense(_user.Value, _useLicense.Value); + SaveUseLicense(_user, _useLicense); } } else @@ -301,7 +301,7 @@ void IRightsManagementProvider.BindUseLicense() SR.RMProviderExceptionNoPackageToDecrypt); } - if (_useLicense.Value == null) + if (_useLicense == null) { throw new InvalidOperationException( SR.RMProviderExceptionNoUseLicense); @@ -342,14 +342,14 @@ void IRightsManagementProvider.BindUseLicense() grants != null, "CryptoProvider had no bound grants."); - _rmUseLicense.Value = ConvertGrantList(_user.Value, grants); + _rmUseLicense = ConvertGrantList(_user, grants); // If possible use the CryptoProvider to decrypt the publish license if (HasPermission( - _rmUseLicense.Value, RightsManagementPermissions.AllowOwner)) + _rmUseLicense, RightsManagementPermissions.AllowOwner)) { - _unsignedPublishLicense.Value = + _unsignedPublishLicense = CurrentPublishLicense.DecryptUnsignedPublishLicense( cryptoProvider); @@ -494,12 +494,12 @@ void IRightsManagementProvider.RemoveCredentials(RightsManagementUser user) IRightsManagementProvider.GetAllAccessRights() { if (IsProtected && - _rightsDictionary.Value == null && - _rmUseLicense.Value != null && - _rmUseLicense.Value.HasPermission(RightsManagementPermissions.AllowOwner) && - _unsignedPublishLicense.Value != null) + _rightsDictionary == null && + _rmUseLicense != null && + _rmUseLicense.HasPermission(RightsManagementPermissions.AllowOwner) && + _unsignedPublishLicense != null) { - UnsignedPublishLicense unsignedLicense = _unsignedPublishLicense.Value; + UnsignedPublishLicense unsignedLicense = _unsignedPublishLicense; IDictionary> grantDictionary = new Dictionary>(); @@ -557,11 +557,11 @@ void IRightsManagementProvider.RemoveCredentials(RightsManagementUser user) dictionary[user] = currentLicense; } - _rightsDictionary.Value = + _rightsDictionary = (IDictionary)dictionary; } - return _rightsDictionary.Value; + return _rightsDictionary; } /// @@ -644,7 +644,7 @@ void IRightsManagementProvider.GenerateUnsignedPublishLicense( // If the document is already protected, only owners can republish it // with different permissions if (IsProtected && !HasPermission( - _rmUseLicense.Value, RightsManagementPermissions.AllowOwner)) + _rmUseLicense, RightsManagementPermissions.AllowOwner)) { throw new InvalidOperationException( SR.RMProviderExceptionNotOwnerOfDocument); @@ -704,11 +704,11 @@ void IRightsManagementProvider.GenerateUnsignedPublishLicense( // If the current user was not specified as an owner, add the user to // the rights dictionary and grant the user admin privileges forever - if (!rights.ContainsKey(_user.Value)) + if (!rights.ContainsKey(_user)) { ContentGrant ownerGrant = CreateGrant( - _user.Value, + _user, ContentRight.Owner, DateTime.MinValue, DateTime.MaxValue); @@ -719,14 +719,14 @@ void IRightsManagementProvider.GenerateUnsignedPublishLicense( // Add the grant to the rights dictionary IList grantList = new List(); grantList.Add(ownerGrant); - rights[_user.Value] = ConvertGrantList(_user.Value, grantList); + rights[_user] = ConvertGrantList(_user, grantList); } // // Set up remaining properties of the unsigned publish license // - unsignedPublishLicense.Owner = _user.Value; + unsignedPublishLicense.Owner = _user; unsignedPublishLicense.ReferralInfoName = referralInfoName; unsignedPublishLicense.ReferralInfoUri = referralInfoUri; @@ -735,8 +735,8 @@ void IRightsManagementProvider.GenerateUnsignedPublishLicense( // Save temporary unsigned license and rights dictionary for signing // - _temporaryRightsDictionary.Value = rights; - _temporaryUnsignedPublishLicense.Value = unsignedPublishLicense; + _temporaryRightsDictionary = rights; + _temporaryUnsignedPublishLicense = unsignedPublishLicense; } /// @@ -772,7 +772,7 @@ void IRightsManagementProvider.GenerateUnsignedPublishLicense(string template) // If the listed owner is not the current user, change the listed owner // and ensure that the old owner still maintains owner rights on the // document - if (!_user.Value.Equals(currentOwner)) + if (!_user.Equals(currentOwner)) { ContentGrant currentOwnerGrant = null; @@ -785,7 +785,7 @@ void IRightsManagementProvider.GenerateUnsignedPublishLicense(string template) DateTime.MaxValue); } - unsignedPublishLicense.Owner = _user.Value; + unsignedPublishLicense.Owner = _user; if (currentOwnerGrant != null) { @@ -794,8 +794,8 @@ void IRightsManagementProvider.GenerateUnsignedPublishLicense(string template) } // Assign the new publish license. - _temporaryRightsDictionary.Value = null; - _temporaryUnsignedPublishLicense.Value = unsignedPublishLicense; + _temporaryRightsDictionary = null; + _temporaryUnsignedPublishLicense = unsignedPublishLicense; } /// @@ -807,7 +807,7 @@ void IRightsManagementProvider.SignPublishLicense() { // If the document is already protected, only owners can republish it if (IsProtected && - !HasPermission(_rmUseLicense.Value, + !HasPermission(_rmUseLicense, RightsManagementPermissions.AllowOwner)) { throw new InvalidOperationException( @@ -820,29 +820,29 @@ void IRightsManagementProvider.SignPublishLicense() Trace.Rights, "Signing the publish license for the document."); CurrentPublishLicense = - _temporaryUnsignedPublishLicense.Value.Sign( - _secureEnvironment.Value, out useLicense); + _temporaryUnsignedPublishLicense.Sign( + _secureEnvironment, out useLicense); - _useLicense.Value = useLicense; + _useLicense = useLicense; // Copy and clear temporary values - _unsignedPublishLicense.Value = _temporaryUnsignedPublishLicense.Value; - _rightsDictionary.Value = _temporaryRightsDictionary.Value; - _temporaryUnsignedPublishLicense.Value = null; - _temporaryRightsDictionary.Value = null; + _unsignedPublishLicense = _temporaryUnsignedPublishLicense; + _rightsDictionary = _temporaryRightsDictionary; + _temporaryUnsignedPublishLicense = null; + _temporaryRightsDictionary = null; // If the RightsDictionary exists then set use license. - if (_rightsDictionary.Value != null) + if (_rightsDictionary != null) { - _rmUseLicense.Value = _rightsDictionary.Value[_user.Value]; + _rmUseLicense = _rightsDictionary[_user]; } else { // Since the RightsDictionary doesn't exist (most likely because we're using // a template), generate the owner data. List grantList = new List(); - grantList.Add(CreateGrant(_user.Value, ContentRight.Owner, DateTime.MinValue, DateTime.MaxValue)); - _rmUseLicense.Value = ConvertGrantList(_user.Value, grantList); + grantList.Add(CreateGrant(_user, ContentRight.Owner, DateTime.MinValue, DateTime.MaxValue)); + _rmUseLicense = ConvertGrantList(_user, grantList); } } @@ -853,9 +853,9 @@ void IRightsManagementProvider.SaveCurrentLicenses() { // Save the current publish license and use licenses for rollback _lastSavedPublishLicense = _currentPublishLicense; - _lastSavedRMUseLicense.Value = _rmUseLicense.Value; - _lastSavedUseLicense.Value = _useLicense.Value; - _lastSavedRightsDictionary.Value = _rightsDictionary.Value; + _lastSavedRMUseLicense = _rmUseLicense; + _lastSavedUseLicense = _useLicense; + _lastSavedRightsDictionary = _rightsDictionary; } /// @@ -864,14 +864,14 @@ void IRightsManagementProvider.SaveCurrentLicenses() void IRightsManagementProvider.RevertToSavedLicenses() { CurrentPublishLicense = _lastSavedPublishLicense; - _useLicense.Value = _lastSavedUseLicense.Value; - _rmUseLicense.Value = _lastSavedRMUseLicense.Value; - _rightsDictionary.Value = _lastSavedRightsDictionary.Value; + _useLicense = _lastSavedUseLicense; + _rmUseLicense = _lastSavedRMUseLicense; + _rightsDictionary = _lastSavedRightsDictionary; _lastSavedPublishLicense = null; - _lastSavedUseLicense.Value = null; - _lastSavedRMUseLicense.Value = null; - _lastSavedRightsDictionary.Value = null; + _lastSavedUseLicense = null; + _lastSavedRMUseLicense = null; + _lastSavedRightsDictionary = null; } /// @@ -893,8 +893,8 @@ void IRightsManagementProvider.SetEncryptedPackage(EncryptedPackageEnvelope newP if (_publishLicenseFromEnvelope != null) { savedPublishLicense = _publishLicenseFromEnvelope; - savedUseLicense = _useLicense.Value; - savedRMLicense = _rmUseLicense.Value; + savedUseLicense = _useLicense; + savedRMLicense = _rmUseLicense; } _encryptedPackageEnvelope = newPackage; @@ -934,8 +934,8 @@ void IRightsManagementProvider.SetEncryptedPackage(EncryptedPackageEnvelope newP // If the publish license hasn't changed, restore the saved use // license and generate a new CryptoProvider from it. - _useLicense.Value = savedUseLicense; - _rmUseLicense.Value = savedRMLicense; + _useLicense = savedUseLicense; + _rmUseLicense = savedRMLicense; CryptoProvider cryptoProvider = GenerateCryptoProvider(); @@ -946,9 +946,9 @@ void IRightsManagementProvider.SetEncryptedPackage(EncryptedPackageEnvelope newP // Since the encrypted package envelope has been changed, the last saved // licenses aren't applicable any more. _lastSavedPublishLicense = null; - _lastSavedUseLicense.Value = null; - _lastSavedRMUseLicense.Value = null; - _lastSavedRightsDictionary.Value = null; + _lastSavedUseLicense = null; + _lastSavedRMUseLicense = null; + _lastSavedRightsDictionary = null; Trace.SafeWrite( Trace.Rights, @@ -1006,7 +1006,7 @@ private CryptoProvider GenerateCryptoProvider() { CryptoProvider cryptoProvider = null; - cryptoProvider = _useLicense.Value.Bind(_secureEnvironment.Value); + cryptoProvider = _useLicense.Bind(_secureEnvironment); Trace.SafeWrite( Trace.Rights, "The CryptoProvider was initialized."); @@ -1291,10 +1291,10 @@ private void InitializeMembers() /// private void CleanUpSecureEnvironment() { - if (_secureEnvironment.Value != null) + if (_secureEnvironment != null) { - _secureEnvironment.Value.Dispose(); - _secureEnvironment.Value = null; + _secureEnvironment.Dispose(); + _secureEnvironment = null; } } @@ -1302,24 +1302,10 @@ private void CleanUpSecureEnvironment() /// Sets the currently active user from the value stored in the saved /// secure environment. /// - /// Critical - /// 1) Asserts for RightsManagementPermission to get the value of the - /// _secureEnvironment.Value.User parameter - /// 2) Sets SecurityCriticalDataForSet variable _user - /// 3) Calls SecurityCritical function RightsManagementUser.CreateUser - /// TreatAsSafe - /// 1) _secureEnvironment is SecurityCriticalDataForSet, and the call is - /// reading a property value which requires asserts to access any data - /// from it. - /// 2) The _user variable is set from SecurityCritical function - /// RightsManagementUser.CreateUser. - /// 3) The argument to the CreateUser function is information that is - /// retrieved from the SecureEnvironment created by SecurityCritical - /// method Create. private void SetUserFromSecureEnvironment() { - _user.Value = - RightsManagementUser.CreateUser(_secureEnvironment.Value.User); + _user = + RightsManagementUser.CreateUser(_secureEnvironment.User); } /// @@ -1435,9 +1421,9 @@ private bool AllowLicenseCaching // in the Use License's ApplicationData, this signifies that license // caching should be disabled (and thus we will return false here) result = - !(_useLicense.Value != null && - _useLicense.Value.ApplicationData != null && - _useLicense.Value.ApplicationData.Contains(_noLicCacheKeyValuePair)); + !(_useLicense != null && + _useLicense.ApplicationData != null && + _useLicense.ApplicationData.Contains(_noLicCacheKeyValuePair)); return result; } @@ -1458,28 +1444,28 @@ private bool AllowLicenseCaching /// /// The currently active secure environment. /// - SecurityCriticalDataForSet _secureEnvironment; + SecureEnvironment _secureEnvironment; /// /// The use license the user has for the currently open package. /// - SecurityCriticalDataForSet _useLicense; + UseLicense _useLicense; /// /// The last saved use license. /// - SecurityCriticalDataForSet _lastSavedUseLicense; + UseLicense _lastSavedUseLicense; /// /// A copy of the unsigned publish license. /// - SecurityCriticalDataForSet _unsignedPublishLicense; + UnsignedPublishLicense _unsignedPublishLicense; /// /// A generated unsigned publish license that has not yet been signed. Once /// it is signed, it will replace the _unsignedPublishLicense above. /// - SecurityCriticalDataForSet _temporaryUnsignedPublishLicense; + UnsignedPublishLicense _temporaryUnsignedPublishLicense; /// /// The publish license saved in the current _encryptedPackage. @@ -1502,36 +1488,33 @@ private bool AllowLicenseCaching /// The specially formatted version of the use license describing what /// rights the current user has on the document. /// - SecurityCriticalDataForSet _rmUseLicense; + RightsManagementLicense _rmUseLicense; /// /// The last saved RM use license. /// - SecurityCriticalDataForSet _lastSavedRMUseLicense; + RightsManagementLicense _lastSavedRMUseLicense; /// /// The user for whom this document has been opened. /// - SecurityCriticalDataForSet _user; + RightsManagementUser _user; /// /// A dictionary of rights granted to users on this document. /// - SecurityCriticalDataForSet< - IDictionary> _rightsDictionary; + IDictionary _rightsDictionary; /// /// The last saved version of the dictionary of rights granted to users. /// - SecurityCriticalDataForSet< - IDictionary> _lastSavedRightsDictionary; + IDictionary _lastSavedRightsDictionary; /// /// A dictionary of rights corresponding to the rights granted in a /// temporary unsigned publish license. /// - SecurityCriticalDataForSet< - IDictionary> _temporaryRightsDictionary; + IDictionary _temporaryRightsDictionary; /// /// A list of all the CryptoProviders generated diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementUser.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementUser.cs index 20818b30dd7..642d522ea39 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementUser.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementUser.cs @@ -176,12 +176,12 @@ internal static RightsManagementUser AnyoneRightsManagementUser { get { - if (_anyoneUserInstance.Value == null) + if (_anyoneUserInstance == null) { - _anyoneUserInstance.Value = CreateUser(AnyoneUser); + _anyoneUserInstance = CreateUser(AnyoneUser); } - return _anyoneUserInstance.Value; + return _anyoneUserInstance; } } @@ -195,7 +195,7 @@ internal static RightsManagementUser AnyoneRightsManagementUser /// /// The Anyone user as a RightsManagementUser. /// - private static SecurityCriticalDataForSet _anyoneUserInstance; + private static RightsManagementUser _anyoneUserInstance; private int _hashCode; diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityCriticalDataForSet.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityCriticalDataForSet.cs deleted file mode 100644 index ae51324e013..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityCriticalDataForSet.cs +++ /dev/null @@ -1,54 +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. - -#nullable disable - -// Description: -// This is a helper class to facilate the storage of data that's Critical for set. -// The data itself is not information disclosure but the value controls a critical -// operation. -// -// For example a filepath variable might control what part of the file system the -// code gets access to. - -using System ; -using System.Security ; - -#if SYSTEM_XAML -namespace MS.Internal.Xaml -#else -namespace MS.Internal -#endif -{ - [Serializable] - internal struct SecurityCriticalDataForSet - { - internal SecurityCriticalDataForSet(T value) - { - _value = value; - } - - internal T Value - { - #if DEBUG - [System.Diagnostics.DebuggerStepThrough] - #endif - get - { - return _value; - } - - #if DEBUG - [System.Diagnostics.DebuggerStepThrough] - #endif - set - { - _value = value; - } - } - - private T _value; - } -} - diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/TraceProvider.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/TraceProvider.cs index de57b30600f..9a9b1ef9dec 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/TraceProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/TraceProvider.cs @@ -42,7 +42,7 @@ internal abstract class TraceProvider protected EventTrace.Level _level = EventTrace.Level.LogAlways; protected EventTrace.Keyword _keywords = (EventTrace.Keyword)0; /* aka Flags */ protected EventTrace.Keyword _matchAllKeyword = (EventTrace.Keyword)0; /*Vista only*/ - protected SecurityCriticalDataForSet _registrationHandle; + protected ulong _registrationHandle; private const int s_basicTypeAllocationBufferSize = sizeof(decimal); private const int s_traceEventMaximumSize = 65482; // maximum buffer size is 64k - header size @@ -53,7 +53,7 @@ internal abstract class TraceProvider internal TraceProvider() { - _registrationHandle = new SecurityCriticalDataForSet(0); + _registrationHandle = 0; } internal abstract void Register(Guid providerGuid); @@ -443,7 +443,7 @@ internal override unsafe void Register(Guid providerGuid) guidReg.RegHandle = null; ClassicEtw.RegisterTraceGuidsW(_etwProc, IntPtr.Zero, ref providerGuid, 1, ref guidReg, null, null, out registrationHandle); - _registrationHandle.Value = registrationHandle; + _registrationHandle = registrationHandle; } // @@ -490,7 +490,7 @@ private unsafe uint EtwEnableCallback(ClassicEtw.WMIDPREQUESTCODE requestCode, I ~ClassicTraceProvider() { #pragma warning suppress 6031 //presharp suppression - ClassicEtw.UnregisterTraceGuids(_registrationHandle.Value); + ClassicEtw.UnregisterTraceGuids(_registrationHandle); } // pack the argv data and emit the event using TraceEvent @@ -537,7 +537,7 @@ internal unsafe override void Register(Guid providerGuid) _etwEnabledCallback =new ManifestEtw.EtwEnableCallback(EtwEnableCallback); ulong registrationHandle = 0; ManifestEtw.EventRegister(ref providerGuid, _etwEnabledCallback, null, ref registrationHandle); - _registrationHandle.Value = registrationHandle; + _registrationHandle = registrationHandle; } private unsafe void EtwEnableCallback(ref Guid sourceId, int isEnabled, byte level, long matchAnyKeywords, long matchAllKeywords, ManifestEtw.EVENT_FILTER_DESCRIPTOR* filterData, void* callbackContext) @@ -552,15 +552,15 @@ private unsafe void EtwEnableCallback(ref Guid sourceId, int isEnabled, byte lev ~ManifestTraceProvider() { - if(_registrationHandle.Value != 0) + if(_registrationHandle != 0) { try { - ManifestEtw.EventUnregister(_registrationHandle.Value); + ManifestEtw.EventUnregister(_registrationHandle); } finally { - _registrationHandle.Value = 0; + _registrationHandle = 0; } } } @@ -580,7 +580,7 @@ internal unsafe override uint EventWrite(EventTrace.Event eventID, EventTrace.Ke argv = null; } - return ManifestEtw.EventWrite(_registrationHandle.Value, ref eventDescriptor, (uint)argc, argv); + return ManifestEtw.EventWrite(_registrationHandle, ref eventDescriptor, (uint)argc, argv); } } } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs index a9dbdf4525d..64688ccdc5c 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs @@ -49,7 +49,7 @@ public HwndWrapper( IntPtr parent, HwndWrapperHook[] hooks) { - _ownerThreadID = new SecurityCriticalDataForSet(Environment.CurrentManagedThreadId); + _ownerThreadID = Environment.CurrentManagedThreadId; // First, add the set of hooks. This allows the hooks to receive the @@ -213,7 +213,7 @@ private void Dispose(bool disposing, bool isHwndBeingDestroyed) // (we know this since we're listening for WM_NCDESTROY). Since we're being disposed // we destroy it now. - if(Environment.CurrentManagedThreadId == _ownerThreadID.Value) + if(Environment.CurrentManagedThreadId == _ownerThreadID) { // We are the owner thread, we can safely destroy the window and unregister // the class @@ -420,7 +420,7 @@ public ushort ClassAtom private SecurityCriticalDataClass _handle; private UInt16 _classAtom; private SecurityCriticalDataClass _hooks; - private SecurityCriticalDataForSet _ownerThreadID; + private int _ownerThreadID; private SecurityCriticalData _wndProc; private bool _isDisposed; diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs index f71435eafa1..2e0a430c69c 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs @@ -4368,9 +4368,9 @@ public sealed class VARIANT { [MarshalAs(UnmanagedType.I2)] public short reserved3; - public SecurityCriticalDataForSet data1; + public IntPtr data1; - public SecurityCriticalDataForSet data2; + public IntPtr data2; public bool Byref{ @@ -4380,15 +4380,15 @@ public bool Byref{ } public void Clear() { - if ((this.vt == (int)tagVT.VT_UNKNOWN || this.vt == (int)tagVT.VT_DISPATCH) && this.data1.Value != IntPtr.Zero) { - Marshal.Release(this.data1.Value); + if ((this.vt == (int)tagVT.VT_UNKNOWN || this.vt == (int)tagVT.VT_DISPATCH) && this.data1 != IntPtr.Zero) { + Marshal.Release(this.data1); } - if (this.vt == (int)tagVT.VT_BSTR && this.data1.Value != IntPtr.Zero) { - SysFreeString(this.data1.Value); + if (this.vt == (int)tagVT.VT_BSTR && this.data1 != IntPtr.Zero) { + SysFreeString(this.data1); } - this.data1.Value = this.data2.Value = IntPtr.Zero; + this.data1 = this.data2 = IntPtr.Zero; this.vt = (int)tagVT.VT_EMPTY; } @@ -4500,8 +4500,8 @@ public static VARIANT FromObject(Object var) { [DllImport(ExternDll.Oleaut32,CharSet=CharSet.Auto)] private static extern void SysFreeString(IntPtr pbstr); public void SetLong(long lVal) { - data1.Value = (IntPtr)(lVal & 0xFFFFFFFF); - data2.Value = (IntPtr)((lVal >> 32) & 0xFFFFFFFF); + data1 = (IntPtr)(lVal & 0xFFFFFFFF); + data2 = (IntPtr)((lVal >> 32) & 0xFFFFFFFF); } public IntPtr ToCoTaskMemPtr() { @@ -4510,13 +4510,13 @@ public IntPtr ToCoTaskMemPtr() { Marshal.WriteInt16(mem, 2, reserved1); Marshal.WriteInt16(mem, 4, reserved2); Marshal.WriteInt16(mem, 6, reserved3); - Marshal.WriteInt32(mem, 8, (int) data1.Value); - Marshal.WriteInt32(mem, 12, (int) data2.Value); + Marshal.WriteInt32(mem, 8, (int) data1); + Marshal.WriteInt32(mem, 12, (int) data2); return mem; } public object ToObject() { - IntPtr val = data1.Value; + IntPtr val = data1; long longVal; int vtType = (int)(this.vt & (short)tagVT.VT_TYPEMASK); @@ -4572,7 +4572,7 @@ public object ToObject() { longVal = Marshal.ReadInt64(val); } else { - longVal = ((uint)data1.Value & 0xffffffff) | ((uint)data2.Value << 32); + longVal = ((uint)data1 & 0xffffffff) | ((uint)data2 << 32); } if (vt == (int)tagVT.VT_I8) { @@ -4596,7 +4596,7 @@ public object ToObject() { case (int)tagVT.VT_CY: // internally currency is 8-byte int scaled by 10,000 - longVal = ((uint)data1.Value & 0xffffffff) | ((uint)data2.Value << 32); + longVal = ((uint)data1 & 0xffffffff) | ((uint)data2 << 32); return new Decimal(longVal); case (int)tagVT.VT_DATE: throw new FormatException(/*SR.GetString(SR.CannotConvertDoubleToDate)*/); @@ -4618,7 +4618,7 @@ public object ToObject() { return val; case (int)tagVT.VT_DECIMAL: - longVal = ((uint)data1.Value & 0xffffffff) | ((uint)data2.Value << 32); + longVal = ((uint)data1 & 0xffffffff) | ((uint)data2 << 32); return new Decimal(longVal); case (int)tagVT.VT_BOOL: @@ -4633,7 +4633,7 @@ public object ToObject() { return guid; case (int)tagVT.VT_FILETIME: - longVal = ((uint)data1.Value & 0xffffffff) | ((uint)data2.Value << 32); + longVal = ((uint)data1 & 0xffffffff) | ((uint)data2 << 32); return new DateTime(longVal); case (int)tagVT.VT_ARRAY: diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj index b9b13602544..24a8ae2478f 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj @@ -24,9 +24,6 @@ Common\WPF\MS\Internal\SafeSecurityHelper.cs - - Common\WPF\MS\Internal\SecurityCriticalDataForSet.cs - Common\WPF\MS\Internal\CriticalExceptions.cs diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj index 10682b6c706..6177a0cc772 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj @@ -21,7 +21,6 @@ - diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj index 357a09f9290..4aadedce621 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj @@ -28,7 +28,6 @@ -