Skip to content

Commit 620b77b

Browse files
committed
removed the explicit check for FullTrust as it was unnecessary.
1 parent ccf0307 commit 620b77b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Bson/ObjectModel/ObjectId.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ static ObjectId()
5555

5656
try
5757
{
58-
// we are testing for FullTrust here and, if we have it, then we use the current process' id.
59-
new PermissionSet(PermissionState.Unrestricted).Demand();
6058
SetPidToCurrentProcessId();
6159
}
6260
catch (SecurityException)
@@ -377,6 +375,11 @@ private static int GetTimestampFromDateTime(DateTime timestamp)
377375
return (int)Math.Floor((BsonUtils.ToUniversalTime(timestamp) - BsonConstants.UnixEpoch).TotalSeconds);
378376
}
379377

378+
/// <summary>
379+
/// Sets the pid to current process id. This method exists because of how CAS operates on the call stack, checking
380+
/// for permissions before executing the method. Hence, if we inlined this call, the calling method would not execute
381+
/// before throwing an exception requiring the try/catch at an even higher level that we don't necessarily control.
382+
/// </summary>
380383
[MethodImpl(MethodImplOptions.NoInlining)]
381384
private static void SetPidToCurrentProcessId()
382385
{

0 commit comments

Comments
 (0)