Skip to content

Commit 783e979

Browse files
authored
Add netstandard support back to Federation (#5703)
* Add netstandard support back to Federation * Moved WrapperSecurityCommunicationObject to S.IM.Security namespace to avoid check that WCF implementations implement async methods
1 parent be9708a commit 783e979

38 files changed

+1702
-156
lines changed

src/System.Private.ServiceModel/tests/Scenarios/Extensibility/MessageInterceptor/AsyncResult.cs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,120 +11,120 @@
1111
/// A generic base class for IAsyncResult implementations
1212
/// that wraps a ManualResetEvent.
1313
/// </summary>
14-
abstract class AsyncResult : IAsyncResult
14+
internal abstract class AsyncResult : IAsyncResult
1515
{
16-
AsyncCallback callback;
17-
object state;
18-
bool completedSynchronously;
19-
bool endCalled;
20-
Exception exception;
21-
bool isCompleted;
22-
ManualResetEvent manualResetEvent;
23-
object thisLock;
16+
private AsyncCallback _callback;
17+
private object _state;
18+
private bool _completedSynchronously;
19+
private bool _endCalled;
20+
private Exception _exception;
21+
private bool _isCompleted;
22+
private ManualResetEvent _manualResetEvent;
23+
private object _thisLock;
2424

2525
protected AsyncResult(AsyncCallback callback, object state)
2626
{
27-
this.callback = callback;
28-
this.state = state;
29-
this.thisLock = new object();
27+
this._callback = callback;
28+
this._state = state;
29+
this._thisLock = new object();
3030
}
3131

3232
public object AsyncState
3333
{
3434
get
3535
{
36-
return state;
36+
return _state;
3737
}
3838
}
3939

4040
public WaitHandle AsyncWaitHandle
4141
{
4242
get
4343
{
44-
if (manualResetEvent != null)
44+
if (_manualResetEvent != null)
4545
{
46-
return manualResetEvent;
46+
return _manualResetEvent;
4747
}
4848

4949
lock (ThisLock)
5050
{
51-
if (manualResetEvent == null)
51+
if (_manualResetEvent == null)
5252
{
53-
manualResetEvent = new ManualResetEvent(isCompleted);
53+
_manualResetEvent = new ManualResetEvent(_isCompleted);
5454
}
5555
}
5656

57-
return manualResetEvent;
57+
return _manualResetEvent;
5858
}
5959
}
6060

6161
public bool CompletedSynchronously
6262
{
6363
get
6464
{
65-
return completedSynchronously;
65+
return _completedSynchronously;
6666
}
6767
}
6868

6969
public bool IsCompleted
7070
{
7171
get
7272
{
73-
return isCompleted;
73+
return _isCompleted;
7474
}
7575
}
7676

77-
object ThisLock
77+
private object ThisLock
7878
{
7979
get
8080
{
81-
return this.thisLock;
81+
return this._thisLock;
8282
}
8383
}
8484

8585
// Call this version of complete when your asynchronous operation is complete. This will update the state
8686
// of the operation and notify the callback.
8787
protected void Complete(bool completedSynchronously)
8888
{
89-
if (isCompleted)
89+
if (_isCompleted)
9090
{
9191
// It is a bug to call Complete twice.
9292
throw new InvalidOperationException("Cannot call Complete twice");
9393
}
9494

95-
this.completedSynchronously = completedSynchronously;
95+
this._completedSynchronously = completedSynchronously;
9696

9797
if (completedSynchronously)
9898
{
9999
// If we completedSynchronously, then there is no chance that the manualResetEvent was created so
100100
// we do not need to worry about a race condition.
101-
Debug.Assert(this.manualResetEvent == null, "No ManualResetEvent should be created for a synchronous AsyncResult.");
102-
this.isCompleted = true;
101+
Debug.Assert(this._manualResetEvent == null, "No ManualResetEvent should be created for a synchronous AsyncResult.");
102+
this._isCompleted = true;
103103
}
104104
else
105105
{
106106
lock (ThisLock)
107107
{
108-
this.isCompleted = true;
109-
if (this.manualResetEvent != null)
108+
this._isCompleted = true;
109+
if (this._manualResetEvent != null)
110110
{
111-
this.manualResetEvent.Set();
111+
this._manualResetEvent.Set();
112112
}
113113
}
114114
}
115115

116116
// If the callback throws, there is a bug in the callback implementation
117-
if (callback != null)
117+
if (_callback != null)
118118
{
119-
callback(this);
119+
_callback(this);
120120
}
121121
}
122122

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

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

148-
if (asyncResult.endCalled)
148+
if (asyncResult._endCalled)
149149
{
150150
throw new InvalidOperationException("Async object already ended.");
151151
}
152152

153-
asyncResult.endCalled = true;
153+
asyncResult._endCalled = true;
154154

155-
if (!asyncResult.isCompleted)
155+
if (!asyncResult._isCompleted)
156156
{
157157
asyncResult.AsyncWaitHandle.WaitOne();
158158
}
159159

160-
if (asyncResult.manualResetEvent != null)
160+
if (asyncResult._manualResetEvent != null)
161161
{
162-
asyncResult.manualResetEvent.Dispose();
162+
asyncResult._manualResetEvent.Dispose();
163163
}
164164

165-
if (asyncResult.exception != null)
165+
if (asyncResult._exception != null)
166166
{
167-
throw asyncResult.exception;
167+
throw asyncResult._exception;
168168
}
169169

170170
return asyncResult;
171171
}
172172
}
173173

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

189189
//A strongly typed AsyncResult
190-
abstract class TypedAsyncResult<T> : AsyncResult
190+
internal abstract class TypedAsyncResult<T> : AsyncResult
191191
{
192-
T data;
192+
private T _data;
193193

194194
protected TypedAsyncResult(AsyncCallback callback, object state)
195195
: base(callback, state)
@@ -198,12 +198,12 @@ protected TypedAsyncResult(AsyncCallback callback, object state)
198198

199199
public T Data
200200
{
201-
get { return data; }
201+
get { return _data; }
202202
}
203203

204204
protected void Complete(T data, bool completedSynchronously)
205205
{
206-
this.data = data;
206+
this._data = data;
207207
Complete(completedSynchronously);
208208
}
209209

@@ -215,7 +215,7 @@ public static T End(IAsyncResult result)
215215
}
216216

217217
//A strongly typed AsyncResult that completes as soon as it is instantiated.
218-
class TypedCompletedAsyncResult<T> : TypedAsyncResult<T>
218+
internal class TypedCompletedAsyncResult<T> : TypedAsyncResult<T>
219219
{
220220
public TypedCompletedAsyncResult(T data, AsyncCallback callback, object state)
221221
: base(callback, state)

src/System.Private.ServiceModel/tests/Scenarios/Extensibility/MessageInterceptor/TimeoutHelper.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ public struct TimeoutHelper
1111
public static TimeSpan DefaultTimeout { get { return TimeSpan.FromMinutes(2); } }
1212
public static TimeSpan DefaultShortTimeout { get { return TimeSpan.FromSeconds(4); } }
1313
public static TimeSpan Infinite { get { return TimeSpan.MaxValue; } }
14-
DateTime deadline;
15-
TimeSpan originalTimeout;
14+
15+
private DateTime _deadline;
16+
private TimeSpan _originalTimeout;
1617

1718
public TimeoutHelper(TimeSpan timeout)
1819
{
@@ -21,31 +22,31 @@ public TimeoutHelper(TimeSpan timeout)
2122
throw new ArgumentOutOfRangeException("timeout");
2223
}
2324

24-
this.originalTimeout = timeout;
25+
this._originalTimeout = timeout;
2526
if (timeout == TimeSpan.MaxValue)
2627
{
27-
this.deadline = DateTime.MaxValue;
28+
this._deadline = DateTime.MaxValue;
2829
}
2930
else
3031
{
31-
this.deadline = DateTime.UtcNow + timeout;
32+
this._deadline = DateTime.UtcNow + timeout;
3233
}
3334
}
3435

3536
public TimeSpan OriginalTimeout
3637
{
37-
get { return this.originalTimeout; }
38+
get { return this._originalTimeout; }
3839
}
3940

4041
public TimeSpan RemainingTime()
4142
{
42-
if (this.deadline == DateTime.MaxValue)
43+
if (this._deadline == DateTime.MaxValue)
4344
{
4445
return TimeSpan.MaxValue;
4546
}
4647
else
4748
{
48-
TimeSpan remaining = this.deadline - DateTime.UtcNow;
49+
TimeSpan remaining = this._deadline - DateTime.UtcNow;
4950
if (remaining <= TimeSpan.Zero)
5051
{
5152
return TimeSpan.Zero;
@@ -150,7 +151,7 @@ public static bool WaitOne(WaitHandle waitHandle, TimeSpan timeout, bool exitSyn
150151
}
151152
}
152153

153-
static class Ticks
154+
private static class Ticks
154155
{
155156
public static long FromMilliseconds(int milliseconds)
156157
{

src/System.ServiceModel.Federation/src/Resources/Strings.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,10 @@
198198
<data name="CannotDetermineSPNBasedOnAddress" xml:space="preserve">
199199
<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>
200200
</data>
201+
<data name="AsyncResultCompletedTwice" xml:space="preserve">
202+
<value>AsyncResult completed twice.</value>
203+
</data>
204+
<data name="KeyTypeNotSupported" xml:space="preserve">
205+
<value>KeyType is not supported: {0}</value>
206+
</data>
201207
</root>

src/System.ServiceModel.Federation/src/Resources/xlf/Strings.cs.xlf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<target state="translated">Zpracujte akci {0}.</target>
88
<note />
99
</trans-unit>
10+
<trans-unit id="AsyncResultCompletedTwice">
11+
<source>AsyncResult completed twice.</source>
12+
<target state="new">AsyncResult completed twice.</target>
13+
<note />
14+
</trans-unit>
1015
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
1116
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
1217
<target state="translated">Scénáře nosných klíčů by v odpovědi neměly obsahovat ověřovací token nebo entropii vystavitele.</target>
@@ -72,6 +77,11 @@
7277
<target state="translated">IssuedTokenRenewalThresholdPercentage musí být větší nebo rovno 1 a menší nebo rovno 100. Bylo: '{0}'.</target>
7378
<note />
7479
</trans-unit>
80+
<trans-unit id="KeyTypeNotSupported">
81+
<source>KeyType is not supported: {0}</source>
82+
<target state="new">KeyType is not supported: {0}</target>
83+
<note />
84+
</trans-unit>
7585
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
7686
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
7787
<target state="translated">MaxIssuedTokenCachingTime musí být větší než TimeSpan.Zero. Bylo: '{0}'.</target>

src/System.ServiceModel.Federation/src/Resources/xlf/Strings.de.xlf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<target state="translated">Aktion "{0}" verarbeiten.</target>
88
<note />
99
</trans-unit>
10+
<trans-unit id="AsyncResultCompletedTwice">
11+
<source>AsyncResult completed twice.</source>
12+
<target state="new">AsyncResult completed twice.</target>
13+
<note />
14+
</trans-unit>
1015
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
1116
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
1217
<target state="translated">Bearerschlüsselszenarien sollten kein Nachweistoken oder eine Ausstellerentropie in der Antwort enthalten.</target>
@@ -72,6 +77,11 @@
7277
<target state="translated">"IssuedTokenRenewalThresholdPercentage" muss größer oder gleich 1 und kleiner oder gleich 100 sein. War: '{0}'.</target>
7378
<note />
7479
</trans-unit>
80+
<trans-unit id="KeyTypeNotSupported">
81+
<source>KeyType is not supported: {0}</source>
82+
<target state="new">KeyType is not supported: {0}</target>
83+
<note />
84+
</trans-unit>
7585
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
7686
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
7787
<target state="translated">MaxIssuedTokenCachingTime muss größer als TimeSpan.Zero sein. War: '{0}'.</target>

src/System.ServiceModel.Federation/src/Resources/xlf/Strings.es.xlf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<target state="translated">Procese la acción "{0}".</target>
88
<note />
99
</trans-unit>
10+
<trans-unit id="AsyncResultCompletedTwice">
11+
<source>AsyncResult completed twice.</source>
12+
<target state="new">AsyncResult completed twice.</target>
13+
<note />
14+
</trans-unit>
1015
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
1116
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
1217
<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>
@@ -72,6 +77,11 @@
7277
<target state="translated">IssuedTokenRenewalThresholdPercentage debe ser mayor o igual que 1 y menor o igual que 100. Era: "{0}".</target>
7378
<note />
7479
</trans-unit>
80+
<trans-unit id="KeyTypeNotSupported">
81+
<source>KeyType is not supported: {0}</source>
82+
<target state="new">KeyType is not supported: {0}</target>
83+
<note />
84+
</trans-unit>
7585
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
7686
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
7787
<target state="translated">MaxIssuedTokenCachingTime debe ser mayor que TimeSpan.Zero. Era: "{0}".</target>

src/System.ServiceModel.Federation/src/Resources/xlf/Strings.fr.xlf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<target state="translated">Traiter l'action '{0}'.</target>
88
<note />
99
</trans-unit>
10+
<trans-unit id="AsyncResultCompletedTwice">
11+
<source>AsyncResult completed twice.</source>
12+
<target state="new">AsyncResult completed twice.</target>
13+
<note />
14+
</trans-unit>
1015
<trans-unit id="BearerKeyShouldNotIincludeAProofToken">
1116
<source>Bearer key scenarios should not include a proof token or issuer entropy in the response.</source>
1217
<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>
@@ -72,6 +77,11 @@
7277
<target state="translated">IssuedTokenRenewalThresholdPercentage doit être supérieur ou égal à 1 et inférieur ou égal à 100. Was: '{0}'.</target>
7378
<note />
7479
</trans-unit>
80+
<trans-unit id="KeyTypeNotSupported">
81+
<source>KeyType is not supported: {0}</source>
82+
<target state="new">KeyType is not supported: {0}</target>
83+
<note />
84+
</trans-unit>
7585
<trans-unit id="MaxIssuedTokenCachingTimeMustBeGreaterThanTimeSpanZero">
7686
<source>MaxIssuedTokenCachingTime must be greater than TimeSpan.Zero. Was: '{0}'.</source>
7787
<target state="translated">MaxIssuedTokenCachingTime doit être supérieur à TimeSpan.Zero. Was: '{0}'.</target>

0 commit comments

Comments
 (0)