Skip to content

Commit d60ef93

Browse files
author
Oren (electricessence)
committed
Updates.
Resharper inspection fixes.
1 parent 6f760c7 commit d60ef93

File tree

8 files changed

+358
-292
lines changed

8 files changed

+358
-292
lines changed

AsyncProcess.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public virtual T Progress
147147
return new T();
148148

149149
var state = t.AsyncState;
150-
T result = (T)state;
150+
var result = (T)state;
151151
return result;
152152
}
153153
}
@@ -181,7 +181,7 @@ public string TimeStatistics
181181
{
182182
get
183183
{
184-
var result = String.Empty;
184+
var result = string.Empty;
185185
if (LatestCompleted != default(DateTime))
186186
result += "\n" + (DateTime.Now - LatestCompleted).ToString() + " ago";
187187

AsyncQuery.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected Task<TResult> EnsureProcessValued(bool once, TimeSpan? timeAllowedBefo
4040
}, () =>
4141
{
4242

43-
task = new Task<TResult>((Func<object, TResult>)Process, new Progress());
43+
task = new Task<TResult>(Process, new Progress());
4444
task.Start(Scheduler);
4545
InternalTask = InternalTaskValued = task;
4646
Count++;
@@ -169,7 +169,7 @@ public TResult LatestEnsured
169169
{
170170
get
171171
{
172-
return GetLatestOrRunning(out DateTime completed);
172+
return GetLatestOrRunning(out var completed);
173173
}
174174
}
175175

@@ -211,9 +211,9 @@ public TResult ActiveRunningValueOrLatestPossible
211211

212212
public virtual bool TryGetLatest(out TResult latest, out DateTime completed)
213213
{
214-
TResult result = default(TResult);
215-
DateTime resultComplete = DateTime.MinValue;
216-
bool isReady = SyncLock.ReadValue(() =>
214+
var result = default(TResult);
215+
var resultComplete = DateTime.MinValue;
216+
var isReady = SyncLock.ReadValue(() =>
217217
{
218218
result = _latest;
219219
resultComplete = LatestCompleted;
@@ -226,7 +226,7 @@ public virtual bool TryGetLatest(out TResult latest, out DateTime completed)
226226

227227
public virtual bool TryGetLatest(out TResult latest)
228228
{
229-
return TryGetLatest(out latest, out DateTime completed);
229+
return TryGetLatest(out latest, out var completed);
230230
}
231231

232232
public virtual bool TryGetLatestOrStart(out TResult latest, out DateTime completed)
@@ -239,12 +239,12 @@ public virtual bool TryGetLatestOrStart(out TResult latest, out DateTime complet
239239

240240
public virtual bool TryGetLatestOrStart(out TResult latest)
241241
{
242-
return TryGetLatestOrStart(out latest, out DateTime completed);
242+
return TryGetLatestOrStart(out latest, out var completed);
243243
}
244244

245245
public virtual bool TryGetLatestOrStart()
246246
{
247-
return TryGetLatestOrStart(out TResult latest, out DateTime completed);
247+
return TryGetLatestOrStart(out var latest, out var completed);
248248
}
249249

250250

@@ -269,7 +269,7 @@ public TResult GetRunningValue()
269269

270270
public TResult GetLatestOrRunning(out DateTime completed)
271271
{
272-
if (!TryGetLatest(out TResult result, out completed))
272+
if (!TryGetLatest(out var result, out completed))
273273
{
274274
result = RunningValue;
275275
completed = DateTime.Now;

Container.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ public T GetValue()
120120
public bool SetValue(T value)
121121
{
122122
AssertIsAlive();
123-
bool init = false;
123+
var init = false;
124124

125-
T original = SyncLock.WriteValue(() =>
125+
var original = SyncLock.WriteValue(() =>
126126
{
127127
AssertIsAlive();
128128

129-
T o = _value;
129+
var o = _value;
130130
_value = value;
131131
init = !HasValue;
132132
HasValue = true;
@@ -136,7 +136,7 @@ public bool SetValue(T value)
136136
if (init)
137137
OnValueInitializedInternal(value);
138138

139-
bool updating = !original.Equals(value);
139+
var updating = !original.Equals(value);
140140
if (updating)
141141
OnValueUpdatedInternal(original, value);
142142

@@ -191,10 +191,10 @@ protected virtual T Eval()
191191
/// <returns>True if the source is set.</returns>
192192
public bool GetValue(out T value)
193193
{
194-
bool hv = false;
194+
var hv = false;
195195
value = SyncLock.ReadValue(() =>
196196
{
197-
T r = GetValue();
197+
var r = GetValue();
198198
hv = HasValue;
199199
return r;
200200
});
@@ -207,7 +207,7 @@ public bool GetValue(out T value)
207207
/// <param name="valueFactory">The Func&lt;TLock&gt; for creating the source if it's missing.</param>
208208
public T GetOrUpdate(Func<T> valueFactory)
209209
{
210-
T result = _value;
210+
var result = _value;
211211
if (valueFactory != null)
212212
{
213213
SyncLock.ReadWriteConditional((locked) =>
@@ -320,7 +320,7 @@ protected override T Eval()
320320
{
321321
return SyncLock.ReadValue(() =>
322322
{
323-
T result = base.Eval();
323+
var result = base.Eval();
324324
ValueFactory = null;
325325
return result;
326326
});

ModificationSynchronizedBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
1+

2+
using Open.Disposable;
23
using System;
34
using System.Threading;
4-
using Open.Disposable;
55

66
namespace Open.Threading
77
{
@@ -41,8 +41,8 @@ protected virtual ModificationSynchronizer InitSync(object sync = null)
4141
return sync == null
4242
? new ModificationSynchronizer()
4343
: sync is ReaderWriterLockSlim
44-
? (ModificationSynchronizer)(new ReadWriteModificationSynchronizer((ReaderWriterLockSlim)sync))
45-
: (ModificationSynchronizer)(new SimpleLockingModificationSynchronizer());
44+
? new ReadWriteModificationSynchronizer((ReaderWriterLockSlim)sync)
45+
: (ModificationSynchronizer)new SimpleLockingModificationSynchronizer();
4646
}
4747

4848

@@ -78,7 +78,7 @@ void SetSyncSynced(IModificationSynchronizer value)
7878
{
7979
if (_sync is ModificationSynchronizer sync)
8080
{
81-
bool owned = false;
81+
var owned = false;
8282
// Allow for wrap-up.
8383
if (!sync.IsDisposed) sync.Modifying(() =>
8484
{
@@ -145,4 +145,4 @@ protected virtual void OnFrozen()
145145
}
146146

147147

148-
}
148+
}

ModificationSynchronizer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ public virtual bool Modifying<T>(ref T target, T newValue)
179179
public sealed class SimpleLockingModificationSynchronizer : ModificationSynchronizer
180180
{
181181

182-
readonly object _sync = new Object();
182+
readonly object _sync = new object();
183183

184184
public SimpleLockingModificationSynchronizer(object sync = null)
185185
{
186-
_sync = sync ?? new Object();
186+
_sync = sync ?? new object();
187187
}
188188

189189

@@ -202,7 +202,7 @@ public override T Reading<T>(Func<T> action)
202202

203203
public override bool Modifying(Func<bool> condition, Func<bool> action)
204204
{
205-
bool modified = false;
205+
var modified = false;
206206
ThreadSafety.LockConditional(
207207
_sync,
208208
() => AssertIsAlive() && (condition == null || condition()),
@@ -274,7 +274,7 @@ public override bool Modifying(Func<bool> condition, Func<bool> action)
274274
if (condition != null && !_sync.ReadValue(condition))
275275
return false;
276276

277-
bool modified = false;
277+
var modified = false;
278278
_sync.ReadUpgradeable(() =>
279279
{
280280
AssertIsAlive();

Open.Threading.csproj

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@
1010
Part of the "Open" set of libraries.</Description>
1111
<PackageLicenseUrl>https://github.com/electricessence/Open.Threading/blob/master/LISCENSE.md</PackageLicenseUrl>
1212
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
13-
<Version>1.3.0</Version>
14-
<AssemblyVersion>1.3.0.0</AssemblyVersion>
15-
<FileVersion>1.3.0.0</FileVersion>
13+
<Version>1.4.1</Version>
14+
<AssemblyVersion>1.4.0.0</AssemblyVersion>
15+
<FileVersion>1.4.0.0</FileVersion>
1616
<Copyright>https://github.com/electricessence/Open.Threading/blob/master/LISCENSE.md</Copyright>
1717
<PackageProjectUrl>https://github.com/electricessence/Open.Threading/</PackageProjectUrl>
1818
<RepositoryUrl>https://github.com/electricessence/Open.Threading/</RepositoryUrl>
1919
<RepositoryType>git</RepositoryType>
2020
<PackageTags>dotnet, dotnet-core, dotnetcore, cs, collections, extensions, threadsafe, thread-safe, readwrite, read-write, readerwriterlock, readerwriterlockslim</PackageTags>
21-
<PackageReleaseNotes>Updated to .NET Standard for compatability.</PackageReleaseNotes>
21+
<PackageReleaseNotes></PackageReleaseNotes>
22+
</PropertyGroup>
23+
24+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
25+
<LangVersion>latest</LangVersion>
26+
</PropertyGroup>
27+
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
29+
<LangVersion>latest</LangVersion>
2230
</PropertyGroup>
2331

2432
<ItemGroup>
@@ -34,7 +42,7 @@ Part of the "Open" set of libraries.</Description>
3442

3543
<ItemGroup>
3644
<PackageReference Include="Open.Diagnostics" Version="1.3.0" />
37-
<PackageReference Include="Open.Threading.ReadWrite" Version="1.1.0" />
45+
<PackageReference Include="Open.Threading.ReadWrite" Version="1.1.1" />
3846
</ItemGroup>
3947

4048
</Project>

0 commit comments

Comments
 (0)