Skip to content

Commit 59ffc1f

Browse files
Generates ICache async counter-parts instead of hand coding them.
1 parent d7e1dc9 commit 59ffc1f

File tree

18 files changed

+1409
-534
lines changed

18 files changed

+1409
-534
lines changed

AsyncGenerator.yml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,228 @@
11
projects:
2+
- filePath: EnyimMemcached\NHibernate.Caches.EnyimMemcached\NHibernate.Caches.EnyimMemcached.csproj
3+
concurrentRun: true
4+
applyChanges: true
5+
analyzation:
6+
methodConversion:
7+
- conversion: Ignore
8+
hasAttributeName: ObsoleteAttribute
9+
callForwarding: true
10+
cancellationTokens:
11+
guards: true
12+
methodParameter:
13+
- anyInterfaceRule: PubliclyExposedType
14+
parameter: Optional
15+
- parameter: Optional
16+
rule: PubliclyExposedType
17+
- parameter: Required
18+
scanMethodBody: true
19+
scanForMissingAsyncMembers:
20+
- all: true
21+
transformation:
22+
configureAwaitArgument: false
23+
localFunctions: true
24+
asyncLock:
25+
type: NHibernate.Util.AsyncLock
26+
methodName: LockAsync
27+
registerPlugin:
28+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
29+
assemblyName: AsyncGenerator.Core
30+
- filePath: MemCache\NHibernate.Caches.MemCache\NHibernate.Caches.MemCache.csproj
31+
concurrentRun: true
32+
applyChanges: true
33+
analyzation:
34+
methodConversion:
35+
- conversion: Ignore
36+
hasAttributeName: ObsoleteAttribute
37+
callForwarding: true
38+
cancellationTokens:
39+
guards: true
40+
methodParameter:
41+
- anyInterfaceRule: PubliclyExposedType
42+
parameter: Optional
43+
- parameter: Optional
44+
rule: PubliclyExposedType
45+
- parameter: Required
46+
scanMethodBody: true
47+
scanForMissingAsyncMembers:
48+
- all: true
49+
transformation:
50+
configureAwaitArgument: false
51+
localFunctions: true
52+
asyncLock:
53+
type: NHibernate.Util.AsyncLock
54+
methodName: LockAsync
55+
registerPlugin:
56+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
57+
assemblyName: AsyncGenerator.Core
58+
- filePath: Prevalence\NHibernate.Caches.Prevalence\NHibernate.Caches.Prevalence.csproj
59+
concurrentRun: true
60+
applyChanges: true
61+
analyzation:
62+
methodConversion:
63+
- conversion: Ignore
64+
hasAttributeName: ObsoleteAttribute
65+
callForwarding: true
66+
cancellationTokens:
67+
guards: true
68+
methodParameter:
69+
- anyInterfaceRule: PubliclyExposedType
70+
parameter: Optional
71+
- parameter: Optional
72+
rule: PubliclyExposedType
73+
- parameter: Required
74+
scanMethodBody: true
75+
scanForMissingAsyncMembers:
76+
- all: true
77+
transformation:
78+
configureAwaitArgument: false
79+
localFunctions: true
80+
asyncLock:
81+
type: NHibernate.Util.AsyncLock
82+
methodName: LockAsync
83+
registerPlugin:
84+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
85+
assemblyName: AsyncGenerator.Core
86+
- filePath: RtMemoryCache\NHibernate.Caches.RtMemoryCache\NHibernate.Caches.RtMemoryCache.csproj
87+
concurrentRun: true
88+
applyChanges: true
89+
analyzation:
90+
methodConversion:
91+
- conversion: Ignore
92+
hasAttributeName: ObsoleteAttribute
93+
callForwarding: true
94+
cancellationTokens:
95+
guards: true
96+
methodParameter:
97+
- anyInterfaceRule: PubliclyExposedType
98+
parameter: Optional
99+
- parameter: Optional
100+
rule: PubliclyExposedType
101+
- parameter: Required
102+
scanMethodBody: true
103+
scanForMissingAsyncMembers:
104+
- all: true
105+
transformation:
106+
configureAwaitArgument: false
107+
localFunctions: true
108+
asyncLock:
109+
type: NHibernate.Util.AsyncLock
110+
methodName: LockAsync
111+
registerPlugin:
112+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
113+
assemblyName: AsyncGenerator.Core
114+
- filePath: SharedCache\NHibernate.Caches.SharedCache\NHibernate.Caches.SharedCache.csproj
115+
concurrentRun: true
116+
applyChanges: true
117+
analyzation:
118+
methodConversion:
119+
- conversion: Ignore
120+
hasAttributeName: ObsoleteAttribute
121+
callForwarding: true
122+
cancellationTokens:
123+
guards: true
124+
methodParameter:
125+
- anyInterfaceRule: PubliclyExposedType
126+
parameter: Optional
127+
- parameter: Optional
128+
rule: PubliclyExposedType
129+
- parameter: Required
130+
scanMethodBody: true
131+
scanForMissingAsyncMembers:
132+
- all: true
133+
transformation:
134+
configureAwaitArgument: false
135+
localFunctions: true
136+
asyncLock:
137+
type: NHibernate.Util.AsyncLock
138+
methodName: LockAsync
139+
registerPlugin:
140+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
141+
assemblyName: AsyncGenerator.Core
142+
- filePath: SysCache\NHibernate.Caches.SysCache\NHibernate.Caches.SysCache.csproj
143+
concurrentRun: true
144+
applyChanges: true
145+
analyzation:
146+
methodConversion:
147+
- conversion: Ignore
148+
hasAttributeName: ObsoleteAttribute
149+
callForwarding: true
150+
cancellationTokens:
151+
guards: true
152+
methodParameter:
153+
- anyInterfaceRule: PubliclyExposedType
154+
parameter: Optional
155+
- parameter: Optional
156+
rule: PubliclyExposedType
157+
- parameter: Required
158+
scanMethodBody: true
159+
scanForMissingAsyncMembers:
160+
- all: true
161+
transformation:
162+
configureAwaitArgument: false
163+
localFunctions: true
164+
asyncLock:
165+
type: NHibernate.Util.AsyncLock
166+
methodName: LockAsync
167+
registerPlugin:
168+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
169+
assemblyName: AsyncGenerator.Core
170+
- filePath: SysCache2\NHibernate.Caches.SysCache2\NHibernate.Caches.SysCache2.csproj
171+
concurrentRun: true
172+
applyChanges: true
173+
analyzation:
174+
methodConversion:
175+
- conversion: Ignore
176+
hasAttributeName: ObsoleteAttribute
177+
callForwarding: true
178+
cancellationTokens:
179+
guards: true
180+
methodParameter:
181+
- anyInterfaceRule: PubliclyExposedType
182+
parameter: Optional
183+
- parameter: Optional
184+
rule: PubliclyExposedType
185+
- parameter: Required
186+
scanMethodBody: true
187+
scanForMissingAsyncMembers:
188+
- all: true
189+
transformation:
190+
configureAwaitArgument: false
191+
localFunctions: true
192+
asyncLock:
193+
type: NHibernate.Util.AsyncLock
194+
methodName: LockAsync
195+
registerPlugin:
196+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
197+
assemblyName: AsyncGenerator.Core
198+
- filePath: Velocity\NHibernate.Caches.Velocity\NHibernate.Caches.Velocity.csproj
199+
concurrentRun: true
200+
applyChanges: true
201+
analyzation:
202+
methodConversion:
203+
- conversion: Ignore
204+
hasAttributeName: ObsoleteAttribute
205+
callForwarding: true
206+
cancellationTokens:
207+
guards: true
208+
methodParameter:
209+
- anyInterfaceRule: PubliclyExposedType
210+
parameter: Optional
211+
- parameter: Optional
212+
rule: PubliclyExposedType
213+
- parameter: Required
214+
scanMethodBody: true
215+
scanForMissingAsyncMembers:
216+
- all: true
217+
transformation:
218+
configureAwaitArgument: false
219+
localFunctions: true
220+
asyncLock:
221+
type: NHibernate.Util.AsyncLock
222+
methodName: LockAsync
223+
registerPlugin:
224+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
225+
assemblyName: AsyncGenerator.Core
2226
- filePath: NHibernate.Caches.Common.Tests\NHibernate.Caches.Common.Tests.csproj
3227
concurrentRun: true
4228
applyChanges: true

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The main GitHub repository is at [https://github.com/nhibernate/NHibernate-Cache
2020

2121
**Nant** builds are defined in the root of the repository.
2222

23-
1. Run **nant generate-async** to generate async counterparts of any test you have added or changed.
23+
1. Run **nant generate-async** to generate async counterparts of any method you have added or changed (including tests).
2424
2. Run **nant test** to run the tests. Cache provider tests depending on a cache server does not fail the task by default, check the nant output for unexpected failures.
2525
3. **GaRelease.bat** will create the release package.
2626

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System;
12+
using System.Collections;
13+
using System.Collections.Generic;
14+
using System.Security.Cryptography;
15+
using System.Text;
16+
using Enyim.Caching;
17+
using Enyim.Caching.Memcached;
18+
using NHibernate.Cache;
19+
using Environment = NHibernate.Cfg.Environment;
20+
21+
namespace NHibernate.Caches.EnyimMemcached
22+
{
23+
using System.Threading.Tasks;
24+
using System.Threading;
25+
public partial class MemCacheClient : ICache
26+
{
27+
28+
#region ICache Members
29+
30+
public Task<object> GetAsync(object key, CancellationToken cancellationToken)
31+
{
32+
if (cancellationToken.IsCancellationRequested)
33+
{
34+
return Task.FromCanceled<object>(cancellationToken);
35+
}
36+
try
37+
{
38+
return Task.FromResult<object>(Get(key));
39+
}
40+
catch (Exception ex)
41+
{
42+
return Task.FromException<object>(ex);
43+
}
44+
}
45+
46+
public Task PutAsync(object key, object value, CancellationToken cancellationToken)
47+
{
48+
if (key == null)
49+
{
50+
throw new ArgumentNullException("key", "null key not allowed");
51+
}
52+
if (value == null)
53+
{
54+
throw new ArgumentNullException("value", "null value not allowed");
55+
}
56+
if (cancellationToken.IsCancellationRequested)
57+
{
58+
return Task.FromCanceled<object>(cancellationToken);
59+
}
60+
try
61+
{
62+
Put(key, value);
63+
return Task.CompletedTask;
64+
}
65+
catch (Exception ex)
66+
{
67+
return Task.FromException<object>(ex);
68+
}
69+
}
70+
71+
public Task RemoveAsync(object key, CancellationToken cancellationToken)
72+
{
73+
if (key == null)
74+
{
75+
throw new ArgumentNullException("key");
76+
}
77+
if (cancellationToken.IsCancellationRequested)
78+
{
79+
return Task.FromCanceled<object>(cancellationToken);
80+
}
81+
try
82+
{
83+
Remove(key);
84+
return Task.CompletedTask;
85+
}
86+
catch (Exception ex)
87+
{
88+
return Task.FromException<object>(ex);
89+
}
90+
}
91+
92+
public Task ClearAsync(CancellationToken cancellationToken)
93+
{
94+
if (cancellationToken.IsCancellationRequested)
95+
{
96+
return Task.FromCanceled<object>(cancellationToken);
97+
}
98+
try
99+
{
100+
Clear();
101+
return Task.CompletedTask;
102+
}
103+
catch (Exception ex)
104+
{
105+
return Task.FromException<object>(ex);
106+
}
107+
}
108+
109+
public Task LockAsync(object key, CancellationToken cancellationToken)
110+
{
111+
if (cancellationToken.IsCancellationRequested)
112+
{
113+
return Task.FromCanceled<object>(cancellationToken);
114+
}
115+
try
116+
{
117+
Lock(key);
118+
return Task.CompletedTask;
119+
}
120+
catch (Exception ex)
121+
{
122+
return Task.FromException<object>(ex);
123+
}
124+
// do nothing
125+
}
126+
127+
public Task UnlockAsync(object key, CancellationToken cancellationToken)
128+
{
129+
if (cancellationToken.IsCancellationRequested)
130+
{
131+
return Task.FromCanceled<object>(cancellationToken);
132+
}
133+
try
134+
{
135+
Unlock(key);
136+
return Task.CompletedTask;
137+
}
138+
catch (Exception ex)
139+
{
140+
return Task.FromException<object>(ex);
141+
}
142+
// do nothing
143+
}
144+
145+
#endregion
146+
}
147+
}

0 commit comments

Comments
 (0)