Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add netstandard support back to Federation #5703

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,120 +11,120 @@
/// A generic base class for IAsyncResult implementations
/// that wraps a ManualResetEvent.
/// </summary>
abstract class AsyncResult : IAsyncResult
internal abstract class AsyncResult : IAsyncResult
{
AsyncCallback callback;
object state;
bool completedSynchronously;
bool endCalled;
Exception exception;
bool isCompleted;
ManualResetEvent manualResetEvent;
object thisLock;
private AsyncCallback _callback;
private object _state;
private bool _completedSynchronously;
private bool _endCalled;
private Exception _exception;
private bool _isCompleted;
private ManualResetEvent _manualResetEvent;
private object _thisLock;

protected AsyncResult(AsyncCallback callback, object state)
{
this.callback = callback;
this.state = state;
this.thisLock = new object();
this._callback = callback;
this._state = state;
this._thisLock = new object();
}

public object AsyncState
{
get
{
return state;
return _state;
}
}

public WaitHandle AsyncWaitHandle
{
get
{
if (manualResetEvent != null)
if (_manualResetEvent != null)
{
return manualResetEvent;
return _manualResetEvent;
}

lock (ThisLock)
{
if (manualResetEvent == null)
if (_manualResetEvent == null)
{
manualResetEvent = new ManualResetEvent(isCompleted);
_manualResetEvent = new ManualResetEvent(_isCompleted);
}
}

return manualResetEvent;
return _manualResetEvent;
}
}

public bool CompletedSynchronously
{
get
{
return completedSynchronously;
return _completedSynchronously;
}
}

public bool IsCompleted
{
get
{
return isCompleted;
return _isCompleted;
}
}

object ThisLock
private object ThisLock
{
get
{
return this.thisLock;
return this._thisLock;
}
}

// Call this version of complete when your asynchronous operation is complete. This will update the state
// of the operation and notify the callback.
protected void Complete(bool completedSynchronously)
{
if (isCompleted)
if (_isCompleted)
{
// It is a bug to call Complete twice.
throw new InvalidOperationException("Cannot call Complete twice");
}

this.completedSynchronously = completedSynchronously;
this._completedSynchronously = completedSynchronously;

if (completedSynchronously)
{
// If we completedSynchronously, then there is no chance that the manualResetEvent was created so
// we do not need to worry about a race condition.
Debug.Assert(this.manualResetEvent == null, "No ManualResetEvent should be created for a synchronous AsyncResult.");
this.isCompleted = true;
Debug.Assert(this._manualResetEvent == null, "No ManualResetEvent should be created for a synchronous AsyncResult.");
this._isCompleted = true;
}
else
{
lock (ThisLock)
{
this.isCompleted = true;
if (this.manualResetEvent != null)
this._isCompleted = true;
if (this._manualResetEvent != null)
{
this.manualResetEvent.Set();
this._manualResetEvent.Set();
}
}
}

// If the callback throws, there is a bug in the callback implementation
if (callback != null)
if (_callback != null)
{
callback(this);
_callback(this);
}
}

// Call this version of complete if you raise an exception during processing. In addition to notifying
// the callback, it will capture the exception and store it to be thrown during AsyncResult.End.
protected void Complete(bool completedSynchronously, Exception exception)
{
this.exception = exception;
this._exception = exception;
Complete(completedSynchronously);
}

Expand All @@ -145,34 +145,34 @@ protected static TAsyncResult End<TAsyncResult>(IAsyncResult result)
throw new ArgumentException("Invalid async result.", "result");
}

if (asyncResult.endCalled)
if (asyncResult._endCalled)
{
throw new InvalidOperationException("Async object already ended.");
}

asyncResult.endCalled = true;
asyncResult._endCalled = true;

if (!asyncResult.isCompleted)
if (!asyncResult._isCompleted)
{
asyncResult.AsyncWaitHandle.WaitOne();
}

if (asyncResult.manualResetEvent != null)
if (asyncResult._manualResetEvent != null)
{
asyncResult.manualResetEvent.Dispose();
asyncResult._manualResetEvent.Dispose();
}

if (asyncResult.exception != null)
if (asyncResult._exception != null)
{
throw asyncResult.exception;
throw asyncResult._exception;
}

return asyncResult;
}
}

//An AsyncResult that completes as soon as it is instantiated.
class CompletedAsyncResult : AsyncResult
internal class CompletedAsyncResult : AsyncResult
{
public CompletedAsyncResult(AsyncCallback callback, object state)
: base(callback, state)
Expand All @@ -187,9 +187,9 @@ public static void End(IAsyncResult result)
}

//A strongly typed AsyncResult
abstract class TypedAsyncResult<T> : AsyncResult
internal abstract class TypedAsyncResult<T> : AsyncResult
{
T data;
private T _data;

protected TypedAsyncResult(AsyncCallback callback, object state)
: base(callback, state)
Expand All @@ -198,12 +198,12 @@ protected TypedAsyncResult(AsyncCallback callback, object state)

public T Data
{
get { return data; }
get { return _data; }
}

protected void Complete(T data, bool completedSynchronously)
{
this.data = data;
this._data = data;
Complete(completedSynchronously);
}

Expand All @@ -215,7 +215,7 @@ public static T End(IAsyncResult result)
}

//A strongly typed AsyncResult that completes as soon as it is instantiated.
class TypedCompletedAsyncResult<T> : TypedAsyncResult<T>
internal class TypedCompletedAsyncResult<T> : TypedAsyncResult<T>
{
public TypedCompletedAsyncResult(T data, AsyncCallback callback, object state)
: base(callback, state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ public struct TimeoutHelper
public static TimeSpan DefaultTimeout { get { return TimeSpan.FromMinutes(2); } }
public static TimeSpan DefaultShortTimeout { get { return TimeSpan.FromSeconds(4); } }
public static TimeSpan Infinite { get { return TimeSpan.MaxValue; } }
DateTime deadline;
TimeSpan originalTimeout;

private DateTime _deadline;
private TimeSpan _originalTimeout;

public TimeoutHelper(TimeSpan timeout)
{
Expand All @@ -21,31 +22,31 @@ public TimeoutHelper(TimeSpan timeout)
throw new ArgumentOutOfRangeException("timeout");
}

this.originalTimeout = timeout;
this._originalTimeout = timeout;
if (timeout == TimeSpan.MaxValue)
{
this.deadline = DateTime.MaxValue;
this._deadline = DateTime.MaxValue;
}
else
{
this.deadline = DateTime.UtcNow + timeout;
this._deadline = DateTime.UtcNow + timeout;
}
}

public TimeSpan OriginalTimeout
{
get { return this.originalTimeout; }
get { return this._originalTimeout; }
}

public TimeSpan RemainingTime()
{
if (this.deadline == DateTime.MaxValue)
if (this._deadline == DateTime.MaxValue)
{
return TimeSpan.MaxValue;
}
else
{
TimeSpan remaining = this.deadline - DateTime.UtcNow;
TimeSpan remaining = this._deadline - DateTime.UtcNow;
if (remaining <= TimeSpan.Zero)
{
return TimeSpan.Zero;
Expand Down Expand Up @@ -150,7 +151,7 @@ public static bool WaitOne(WaitHandle waitHandle, TimeSpan timeout, bool exitSyn
}
}

static class Ticks
private static class Ticks
{
public static long FromMilliseconds(int milliseconds)
{
Expand Down
6 changes: 6 additions & 0 deletions src/System.ServiceModel.Federation/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,10 @@
<data name="CannotDetermineSPNBasedOnAddress" xml:space="preserve">
<value>Client cannot determine the Service Principal Name based on the identity in the target address '{0}' for the purpose of SspiNegotiation/Kerberos. The target address identity must be a UPN identity (like acmedomain\alice) or SPN identity (like host/bobs-machine).</value>
</data>
<data name="AsyncResultCompletedTwice" xml:space="preserve">
<value>AsyncResult completed twice.</value>
</data>
<data name="KeyTypeNotSupported" xml:space="preserve">
<value>KeyType is not supported: {0}</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Zpracujte akci {0}.</target>
<note />
</trans-unit>
<trans-unit id="AsyncResultCompletedTwice">
<source>AsyncResult completed twice.</source>
<target state="new">AsyncResult completed twice.</target>
<note />
</trans-unit>
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
<target state="translated">Scénáře nosných klíčů by v odpovědi neměly obsahovat ověřovací token nebo entropii vystavitele.</target>
Expand Down Expand Up @@ -72,6 +77,11 @@
<target state="translated">IssuedTokenRenewalThresholdPercentage musí být větší nebo rovno 1 a menší nebo rovno 100. Bylo: '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="KeyTypeNotSupported">
<source>KeyType is not supported: {0}</source>
<target state="new">KeyType is not supported: {0}</target>
<note />
</trans-unit>
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
<target state="translated">MaxIssuedTokenCachingTime musí být větší než TimeSpan.Zero. Bylo: '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Aktion "{0}" verarbeiten.</target>
<note />
</trans-unit>
<trans-unit id="AsyncResultCompletedTwice">
<source>AsyncResult completed twice.</source>
<target state="new">AsyncResult completed twice.</target>
<note />
</trans-unit>
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
<target state="translated">Bearerschlüsselszenarien sollten kein Nachweistoken oder eine Ausstellerentropie in der Antwort enthalten.</target>
Expand Down Expand Up @@ -72,6 +77,11 @@
<target state="translated">"IssuedTokenRenewalThresholdPercentage" muss größer oder gleich 1 und kleiner oder gleich 100 sein. War: '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="KeyTypeNotSupported">
<source>KeyType is not supported: {0}</source>
<target state="new">KeyType is not supported: {0}</target>
<note />
</trans-unit>
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
<target state="translated">MaxIssuedTokenCachingTime muss größer als TimeSpan.Zero sein. War: '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Procese la acción "{0}".</target>
<note />
</trans-unit>
<trans-unit id="AsyncResultCompletedTwice">
<source>AsyncResult completed twice.</source>
<target state="new">AsyncResult completed twice.</target>
<note />
</trans-unit>
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
<target state="translated">Los escenarios de clave del portador no deben incluir un token de prueba o una entropía de emisor en la respuesta.</target>
Expand Down Expand Up @@ -72,6 +77,11 @@
<target state="translated">IssuedTokenRenewalThresholdPercentage debe ser mayor o igual que 1 y menor o igual que 100. Era: "{0}".</target>
<note />
</trans-unit>
<trans-unit id="KeyTypeNotSupported">
<source>KeyType is not supported: {0}</source>
<target state="new">KeyType is not supported: {0}</target>
<note />
</trans-unit>
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
<target state="translated">MaxIssuedTokenCachingTime debe ser mayor que TimeSpan.Zero. Era: "{0}".</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Traiter l'action '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="AsyncResultCompletedTwice">
<source>AsyncResult completed twice.</source>
<target state="new">AsyncResult completed twice.</target>
<note />
</trans-unit>
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
<target state="translated">Les scénarios de clé de porteur ne doivent pas inclure de jeton de preuve ou d’entropie d’émetteur dans la réponse.</target>
Expand Down Expand Up @@ -72,6 +77,11 @@
<target state="translated">IssuedTokenRenewalThresholdPercentage doit être supérieur ou égal à 1 et inférieur ou égal à 100. Was: '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="KeyTypeNotSupported">
<source>KeyType is not supported: {0}</source>
<target state="new">KeyType is not supported: {0}</target>
<note />
</trans-unit>
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
<target state="translated">MaxIssuedTokenCachingTime doit être supérieur à TimeSpan.Zero. Was: '{0}'.</target>
Expand Down
Loading
Loading