Skip to content

Commit a7f5cd6

Browse files
Remove SecurityCriticalDataForSet
1 parent e500f8e commit a7f5cd6

File tree

81 files changed

+938
-1066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+938
-1066
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ internal static Uri SiteOfOrigin
4949
[FriendAccessAllowed]
5050
get
5151
{
52-
Uri siteOfOrigin = SiteOfOriginForClickOnceApp;
53-
if (siteOfOrigin == null)
54-
{
55-
// Calling FixFileUri because BaseDirectory will be a c:\\ style path
56-
siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(System.AppDomain.CurrentDomain.BaseDirectory));
57-
}
52+
// Calling FixFileUri because BaseDirectory will be a c:\\ style path
53+
Uri siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(System.AppDomain.CurrentDomain.BaseDirectory));
5854
#if DEBUG
5955
if (_traceSwitch.Enabled)
6056
System.Diagnostics.Trace.TraceInformation(
@@ -66,40 +62,16 @@ internal static Uri SiteOfOrigin
6662
return siteOfOrigin;
6763
}
6864
}
69-
70-
// we separated this from the rest of the code because this code is used for media permission
71-
// tests in partial trust but we want to do this without hitting the code path for regular exe's
72-
// as in the code above. This will get hit for click once apps, xbaps, xaml and xps
73-
internal static Uri SiteOfOriginForClickOnceApp
74-
{
75-
get
76-
{
77-
// The ClickOnce API, ApplicationDeployment.IsNetworkDeployed, determines whether the app is network-deployed
78-
// by getting the ApplicationDeployment.CurrentDeployment property and catch the exception it can throw.
79-
// The exception is a first chance exception and caught, but it often confuses developers,
80-
// and can also have a perf impact. So we change to cache the value of SiteofOrigin in Dev10 to avoid the
81-
// exception being thrown too many times.
82-
// An alternative is to cache the value of ApplicationDeployment.IsNetworkDeployed.
83-
if (_siteOfOriginForClickOnceApp == null)
84-
{
85-
_siteOfOriginForClickOnceApp = new SecurityCriticalDataForSet<Uri>(null);
86-
}
87-
88-
Invariant.Assert(_siteOfOriginForClickOnceApp != null);
89-
90-
return _siteOfOriginForClickOnceApp.Value.Value;
91-
}
92-
}
9365

9466
internal static Uri BrowserSource
9567
{
9668
get
9769
{
98-
return _browserSource.Value;
70+
return _browserSource;
9971
}
10072
set
10173
{
102-
_browserSource.Value = value;
74+
_browserSource = value;
10375
}
10476
}
10577

@@ -246,8 +218,7 @@ protected override PackagePart GetPartCore(Uri uri)
246218

247219
#region Private Members
248220

249-
private static SecurityCriticalDataForSet<Uri> _browserSource;
250-
private static SecurityCriticalDataForSet<Uri>? _siteOfOriginForClickOnceApp;
221+
private static Uri _browserSource;
251222

252223
#endregion Private Members
253224

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/UshortList2.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,33 +277,33 @@ internal unsafe class UnsafeUshortArray : UshortBuffer
277277
{
278278
private ushort* _array;
279279

280-
private SecurityCriticalDataForSet<int> _arrayLength;
280+
private int _arrayLength;
281281

282282

283283
internal UnsafeUshortArray(CheckedUShortPointer array, int arrayLength)
284284
{
285285
_array = array.Probe(0, arrayLength);
286-
_arrayLength.Value = arrayLength;
286+
_arrayLength = arrayLength;
287287
}
288288

289289

290290
public override ushort this[int index]
291291
{
292292
get
293293
{
294-
Invariant.Assert(index >= 0 && index < _arrayLength.Value);
294+
Invariant.Assert(index >= 0 && index < _arrayLength);
295295
return _array[index];
296296
}
297297
set
298298
{
299-
Invariant.Assert(index >= 0 && index < _arrayLength.Value);
299+
Invariant.Assert(index >= 0 && index < _arrayLength);
300300
_array[index] = value;
301301
}
302302
}
303303

304304
public override int Length
305305
{
306-
get { return _arrayLength.Value; }
306+
get { return _arrayLength; }
307307
}
308308
}
309309
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextBreakpoint.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ namespace MS.Internal.TextFormatting
3737
internal sealed class FullTextBreakpoint : TextBreakpoint
3838
{
3939
private TextMetrics _metrics; // full text metrics
40-
private SecurityCriticalDataForSet<IntPtr> _ploline; // native object representing this break
41-
private SecurityCriticalDataForSet<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.
40+
private IntPtr _ploline; // native object representing this break
41+
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.
4242
private bool _isDisposed; // flag indicates whether this object is disposed
4343
private bool _isLineTruncated; // flag indicates whether the line produced at this breakpoint is truncated.
4444

@@ -85,7 +85,7 @@ out int bestFitIndex
8585

8686
IntPtr previousBreakRecord = IntPtr.Zero;
8787
if (settings.PreviousLineBreak != null)
88-
previousBreakRecord = settings.PreviousLineBreak.BreakRecord.Value;
88+
previousBreakRecord = settings.PreviousLineBreak.BreakRecord;
8989

9090
// need not consider marker as tab since marker does not affect line metrics and it wasnt drawn.
9191
fullText.SetTabs(context);
@@ -95,7 +95,7 @@ out int bestFitIndex
9595
LsErr lserr = context.CreateBreaks(
9696
fullText.GetBreakpointInternalCp(firstCharIndex),
9797
previousBreakRecord,
98-
paragraphCache.Ploparabreak.Value, // para breaking session
98+
paragraphCache.Ploparabreak, // para breaking session
9999
penaltyRestriction,
100100
ref lsbreaks,
101101
out bestFitIndex
@@ -179,10 +179,10 @@ int breakIndex
179179
&lsbreaks.plslinfoArray[breakIndex]
180180
);
181181

182-
_ploline = new SecurityCriticalDataForSet<IntPtr>(lsbreaks.pplolineArray[breakIndex]);
182+
_ploline = lsbreaks.pplolineArray[breakIndex];
183183

184184
// keep the line penalty handle
185-
_penaltyResource = new SecurityCriticalDataForSet<IntPtr>(lsbreaks.plinepenaltyArray[breakIndex]);
185+
_penaltyResource = lsbreaks.plinepenaltyArray[breakIndex];
186186

187187
if (lsbreaks.plslinfoArray[breakIndex].fForcedBreak != 0)
188188
_isLineTruncated = true;
@@ -213,11 +213,11 @@ private FullTextBreakpoint()
213213
/// </summary>
214214
protected override void Dispose(bool disposing)
215215
{
216-
if(_ploline.Value != IntPtr.Zero)
216+
if(_ploline != IntPtr.Zero)
217217
{
218-
UnsafeNativeMethods.LoDisposeLine(_ploline.Value, !disposing);
219-
_ploline.Value = IntPtr.Zero;
220-
_penaltyResource.Value = IntPtr.Zero;
218+
UnsafeNativeMethods.LoDisposeLine(_ploline, !disposing);
219+
_ploline = IntPtr.Zero;
220+
_penaltyResource = IntPtr.Zero;
221221
_isDisposed = true;
222222
GC.KeepAlive(this);
223223
}
@@ -237,7 +237,7 @@ public override TextLineBreak GetTextLineBreak()
237237
{
238238
throw new ObjectDisposedException(SR.TextBreakpointHasBeenDisposed);
239239
}
240-
return _metrics.GetTextLineBreak(_ploline.Value);
240+
return _metrics.GetTextLineBreak(_ploline);
241241
}
242242

243243

@@ -249,14 +249,14 @@ public override TextLineBreak GetTextLineBreak()
249249
/// We would make a correspondent call to notify our unmanaged wrapper to release them from duty of managing this
250250
/// resource.
251251
/// </remarks>
252-
internal override SecurityCriticalDataForSet<IntPtr> GetTextPenaltyResource()
252+
internal override IntPtr GetTextPenaltyResource()
253253
{
254254
if (_isDisposed)
255255
{
256256
throw new ObjectDisposedException(SR.TextBreakpointHasBeenDisposed);
257257
}
258258

259-
LsErr lserr = UnsafeNativeMethods.LoRelievePenaltyResource(_ploline.Value);
259+
LsErr lserr = UnsafeNativeMethods.LoRelievePenaltyResource(_ploline);
260260
if (lserr != LsErr.None)
261261
{
262262
TextFormatterContext.ThrowExceptionFromLsError(SR.Format(SR.RelievePenaltyResourceFailure, lserr), lserr);

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextLine.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ internal class FullTextLine : TextLine
4949
private int _depthQueryMax; // maximum depth of reversals used in querying
5050
private int _paragraphWidth; // paragraph width
5151
private int _textMinWidthAtTrailing; // smallest text width excluding trailing whitespaces
52-
private SecurityCriticalDataForSet<IntPtr> _ploline; // actual LS line
53-
private SecurityCriticalDataForSet<IntPtr> _ploc; // actual LS context
52+
private IntPtr _ploline; // actual LS line
53+
private IntPtr _ploc; // actual LS context
5454
private Overhang _overhang; // overhang metrics
5555
private StatusFlags _statusFlags; // status flags of the line
5656

@@ -156,11 +156,11 @@ public override void Dispose()
156156
/// </summary>
157157
private void DisposeInternal(bool finalizing)
158158
{
159-
if (_ploline.Value != System.IntPtr.Zero)
159+
if (_ploline != System.IntPtr.Zero)
160160
{
161-
UnsafeNativeMethods.LoDisposeLine(_ploline.Value, finalizing);
161+
UnsafeNativeMethods.LoDisposeLine(_ploline, finalizing);
162162

163-
_ploline.Value = System.IntPtr.Zero;
163+
_ploline = System.IntPtr.Zero;
164164
GC.KeepAlive(this);
165165
}
166166
}
@@ -178,7 +178,7 @@ private FullTextLine(TextFormattingMode textFormattingMode, bool justify, double
178178
}
179179
_metrics = new TextMetrics();
180180
_metrics._pixelsPerDip = pixelsPerDip;
181-
_ploline = new SecurityCriticalDataForSet<IntPtr>(IntPtr.Zero);
181+
_ploline = IntPtr.Zero;
182182
}
183183

184184

@@ -300,7 +300,7 @@ out lineWidths
300300
}
301301
}
302302

303-
_ploline.Value = ploline;
303+
_ploline = ploline;
304304

305305
// get the exception in context before it is released
306306
Exception callbackException = context.CallbackException;
@@ -592,7 +592,7 @@ MatrixTransform antiInversion
592592
{
593593
Rect boundingBox = Rect.Empty;
594594

595-
if (_ploline.Value != System.IntPtr.Zero)
595+
if (_ploline != System.IntPtr.Zero)
596596
{
597597
TextFormatterContext context;
598598
LsErr lserr = LsErr.None;
@@ -603,7 +603,7 @@ MatrixTransform antiInversion
603603
{
604604
context = _metrics._formatter.AcquireContext(
605605
drawingState,
606-
_ploc.Value
606+
_ploc
607607
);
608608

609609
// set the collector and send the line to LS to draw
@@ -614,7 +614,7 @@ MatrixTransform antiInversion
614614
LSPOINT lsRefOrigin = new LSPOINT(0, _metrics._baselineOffset);
615615

616616
lserr = UnsafeNativeMethods.LoDisplayLine(
617-
_ploline.Value,
617+
_ploline,
618618
ref lsRefOrigin,
619619
1, // 0 - opaque, 1 - transparent
620620
ref rect
@@ -864,7 +864,7 @@ private CharacterHit CharacterHitFromDistance(int hitTestDistance)
864864
// assuming the first cp of the line
865865
CharacterHit characterHit = new CharacterHit(_cpFirst, 0);
866866

867-
if(_ploline.Value == IntPtr.Zero)
867+
if(_ploline == IntPtr.Zero)
868868
{
869869
// Returning the first cp for the empty line
870870
return characterHit;
@@ -999,7 +999,7 @@ private int DistanceFromCharacterHit(CharacterHit characterHit)
999999
{
10001000
int hitTestDistance = 0;
10011001

1002-
if (_ploline.Value == IntPtr.Zero)
1002+
if (_ploline == IntPtr.Zero)
10031003
{
10041004
// Returning start of the line for empty line
10051005
return hitTestDistance;
@@ -1147,7 +1147,7 @@ CharacterHit characterHit
11471147

11481148
TextFormatterImp.VerifyCaretCharacterHit(characterHit, _cpFirst, _metrics._cchLength);
11491149

1150-
if (_ploline.Value == System.IntPtr.Zero)
1150+
if (_ploline == System.IntPtr.Zero)
11511151
{
11521152
return characterHit;
11531153
}
@@ -1240,7 +1240,7 @@ CaretDirection direction
12401240

12411241
TextFormatterImp.VerifyCaretCharacterHit(characterHit, _cpFirst, _metrics._cchLength);
12421242

1243-
if (_ploline.Value == IntPtr.Zero)
1243+
if (_ploline == IntPtr.Zero)
12441244
{
12451245
return characterHit;
12461246
}
@@ -1517,7 +1517,7 @@ int textLength
15171517
textLength = (_cpFirst + _metrics._cchLength - firstTextSourceCharacterIndex);
15181518
}
15191519

1520-
if (_ploline.Value == IntPtr.Zero)
1520+
if (_ploline == IntPtr.Zero)
15211521
{
15221522
return CreateDegenerateBounds();
15231523
}
@@ -2129,11 +2129,11 @@ public override IEnumerable<IndexedGlyphRun> GetIndexedGlyphRuns()
21292129

21302130
IEnumerable<IndexedGlyphRun> result = null;
21312131

2132-
if (_ploline.Value != System.IntPtr.Zero)
2132+
if (_ploline != System.IntPtr.Zero)
21332133
{
21342134
TextFormatterContext context = _metrics._formatter.AcquireContext(
21352135
new DrawingState(null, new Point(0, 0), null, this),
2136-
_ploc.Value
2136+
_ploc
21372137
);
21382138

21392139
//
@@ -2143,7 +2143,7 @@ public override IEnumerable<IndexedGlyphRun> GetIndexedGlyphRuns()
21432143

21442144
LSPOINT point = new LSPOINT(0, 0);
21452145
lserr = UnsafeNativeMethods.LoEnumLine(
2146-
_ploline.Value, // line
2146+
_ploline, // line
21472147
false, // reverse enumeration
21482148
false, // geometry needed
21492149
ref point // starting point
@@ -2452,7 +2452,7 @@ private void QueryLinePointPcp(
24522452
out LsTextCell lsTextCell
24532453
)
24542454
{
2455-
Debug.Assert(_ploline.Value != IntPtr.Zero);
2455+
Debug.Assert(_ploline != IntPtr.Zero);
24562456

24572457
LsErr lserr = LsErr.None;
24582458
lsTextCell = new LsTextCell();
@@ -2462,7 +2462,7 @@ out LsTextCell lsTextCell
24622462
{
24632463
LSPOINT pt = new LSPOINT((int)ptQuery.X, (int)ptQuery.Y);
24642464
lserr = UnsafeNativeMethods.LoQueryLinePointPcp(
2465-
_ploline.Value,
2465+
_ploline,
24662466
ref pt,
24672467
subLineInfo.Length,
24682468
(System.IntPtr)plsqsubl,
@@ -2505,7 +2505,7 @@ private void QueryLineCpPpoint(
25052505
out LsTextCell lsTextCell
25062506
)
25072507
{
2508-
Debug.Assert(_ploline.Value != IntPtr.Zero);
2508+
Debug.Assert(_ploline != IntPtr.Zero);
25092509

25102510
LsErr lserr = LsErr.None;
25112511

@@ -2519,7 +2519,7 @@ out LsTextCell lsTextCell
25192519
fixed(LsQSubInfo* plsqsubl = subLineInfo)
25202520
{
25212521
lserr = UnsafeNativeMethods.LoQueryLineCpPpoint(
2522-
_ploline.Value,
2522+
_ploline,
25232523
lscpValidQuery,
25242524
subLineInfo.Length,
25252525
(System.IntPtr)plsqsubl,

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ IntPtr ploc
541541
if(context.Owner == null)
542542
break;
543543
}
544-
else if (ploc == context.Ploc.Value)
544+
else if (ploc == context.Ploc)
545545
{
546546
// LS requires that we use the exact same context for line
547547
// destruction or hittesting (part of the reason is that LS

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextMetrics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ internal TextLineBreak GetTextLineBreak(IntPtr ploline)
318318
{
319319
return new TextLineBreak(
320320
_lastRun.TextModifierScope,
321-
new SecurityCriticalDataForSet<IntPtr>(pbreakrec)
321+
pbreakrec
322322
);
323323
}
324-
return (pbreakrec != IntPtr.Zero) ? new TextLineBreak(null, new SecurityCriticalDataForSet<IntPtr>(pbreakrec)) : null;
324+
return (pbreakrec != IntPtr.Zero) ? new TextLineBreak(null, pbreakrec) : null;
325325
}
326326

327327

0 commit comments

Comments
 (0)