Skip to content

Commit

Permalink
Merge pull request praeclarum#134 from oysteinkrog/feature/RS_Attributes
Browse files Browse the repository at this point in the history
ReSharper attributes
  • Loading branch information
oysteinkrog committed Mar 9, 2015
2 parents e54bbcc + dd51679 commit 43216c5
Show file tree
Hide file tree
Showing 51 changed files with 442 additions and 47 deletions.
33 changes: 24 additions & 9 deletions src/SQLite.Net.Async/AsyncTableQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;

namespace SQLite.Net.Async
{
public class AsyncTableQuery<T>
where T : class
{
private readonly TableQuery<T> _innerQuery;
private readonly TaskCreationOptions _taskCreationOptions = TaskCreationOptions.None;
private readonly TaskScheduler _taskScheduler;
[NotNull] private readonly TableQuery<T> _innerQuery;
private readonly TaskCreationOptions _taskCreationOptions;
[CanBeNull] private readonly TaskScheduler _taskScheduler;

/// <summary>
/// </summary>
Expand All @@ -42,7 +43,9 @@ public class AsyncTableQuery<T>
/// not in ctor)
/// </param>
/// <param name="taskCreationOptions">Defaults to DenyChildAttach</param>
public AsyncTableQuery(TableQuery<T> innerQuery, TaskScheduler taskScheduler = null, TaskCreationOptions taskCreationOptions = TaskCreationOptions.None)
[PublicAPI]
public AsyncTableQuery([NotNull] TableQuery<T> innerQuery, [CanBeNull] TaskScheduler taskScheduler = null,
TaskCreationOptions taskCreationOptions = TaskCreationOptions.None)
{
if (innerQuery == null)
{
Expand All @@ -53,7 +56,8 @@ public AsyncTableQuery(TableQuery<T> innerQuery, TaskScheduler taskScheduler = n
_taskCreationOptions = taskCreationOptions;
}

public AsyncTableQuery<T> Where(Expression<Func<T, bool>> predExpr)
[PublicAPI]
public AsyncTableQuery<T> Where([NotNull] Expression<Func<T, bool>> predExpr)
{
if (predExpr == null)
{
Expand All @@ -62,17 +66,20 @@ public AsyncTableQuery<T> Where(Expression<Func<T, bool>> predExpr)
return new AsyncTableQuery<T>(_innerQuery.Where(predExpr), _taskScheduler ?? TaskScheduler.Default, _taskCreationOptions);
}

[PublicAPI]
public AsyncTableQuery<T> Skip(int n)
{
return new AsyncTableQuery<T>(_innerQuery.Skip(n), _taskScheduler ?? TaskScheduler.Default, _taskCreationOptions);
}

[PublicAPI]
public AsyncTableQuery<T> Take(int n)
{
return new AsyncTableQuery<T>(_innerQuery.Take(n), _taskScheduler ?? TaskScheduler.Default, _taskCreationOptions);
}

public AsyncTableQuery<T> OrderBy<TValue>(Expression<Func<T, TValue>> orderExpr)
[PublicAPI]
public AsyncTableQuery<T> OrderBy<TValue>([NotNull] Expression<Func<T, TValue>> orderExpr)
{
if (orderExpr == null)
{
Expand All @@ -81,7 +88,8 @@ public AsyncTableQuery<T> OrderBy<TValue>(Expression<Func<T, TValue>> orderExpr)
return new AsyncTableQuery<T>(_innerQuery.OrderBy(orderExpr), _taskScheduler ?? TaskScheduler.Default, _taskCreationOptions);
}

public AsyncTableQuery<T> OrderByDescending<TValue>(Expression<Func<T, TValue>> orderExpr)
[PublicAPI]
public AsyncTableQuery<T> OrderByDescending<TValue>([NotNull] Expression<Func<T, TValue>> orderExpr)
{
if (orderExpr == null)
{
Expand All @@ -90,7 +98,8 @@ public AsyncTableQuery<T> OrderByDescending<TValue>(Expression<Func<T, TValue>>
return new AsyncTableQuery<T>(_innerQuery.OrderByDescending(orderExpr), _taskScheduler ?? TaskScheduler.Default, _taskCreationOptions);
}

public AsyncTableQuery<T> ThenBy<TValue>(Expression<Func<T, TValue>> orderExpr)
[PublicAPI]
public AsyncTableQuery<T> ThenBy<TValue>([NotNull] Expression<Func<T, TValue>> orderExpr)
{
if (orderExpr == null)
{
Expand All @@ -99,7 +108,8 @@ public AsyncTableQuery<T> ThenBy<TValue>(Expression<Func<T, TValue>> orderExpr)
return new AsyncTableQuery<T>(_innerQuery.ThenBy(orderExpr), _taskScheduler ?? TaskScheduler.Default, _taskCreationOptions);
}

public AsyncTableQuery<T> ThenByDescending<TValue>(Expression<Func<T, TValue>> orderExpr)
[PublicAPI]
public AsyncTableQuery<T> ThenByDescending<TValue>([NotNull] Expression<Func<T, TValue>> orderExpr)
{
if (orderExpr == null)
{
Expand All @@ -108,6 +118,7 @@ public AsyncTableQuery<T> ThenByDescending<TValue>(Expression<Func<T, TValue>> o
return new AsyncTableQuery<T>(_innerQuery.ThenByDescending(orderExpr), _taskScheduler ?? TaskScheduler.Default, _taskCreationOptions);
}

[PublicAPI]
public Task<List<T>> ToListAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return Task.Factory.StartNew(() =>
Expand All @@ -120,6 +131,7 @@ public Task<List<T>> ToListAsync(CancellationToken cancellationToken = default(C
}, cancellationToken, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default);
}

[PublicAPI]
public Task<int> CountAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return Task.Factory.StartNew(() =>
Expand All @@ -132,6 +144,7 @@ public Task<int> CountAsync(CancellationToken cancellationToken = default(Cancel
}, cancellationToken, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default);
}

[PublicAPI]
public Task<T> ElementAtAsync(int index, CancellationToken cancellationToken = default(CancellationToken))
{
return Task.Factory.StartNew(() =>
Expand All @@ -144,6 +157,7 @@ public Task<T> ElementAtAsync(int index, CancellationToken cancellationToken = d
}, cancellationToken, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default);
}

[PublicAPI]
public Task<T> FirstAsync(CancellationToken cancellationToken = default (CancellationToken))
{
return Task.Factory.StartNew(() =>
Expand All @@ -157,6 +171,7 @@ public Task<T> FirstAsync(CancellationToken cancellationToken = default (Cancell
}, cancellationToken, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default);
}

[PublicAPI]
public Task<T> FirstOrDefaultAsync(CancellationToken cancellationToken = default (CancellationToken))
{
return Task.Factory.StartNew(() =>
Expand Down
10 changes: 8 additions & 2 deletions src/SQLite.Net.Async/SQLite.Net.Async.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,22 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;JETBRAINS_ANNOTATIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;JETBRAINS_ANNOTATIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="JetBrains.Annotations.PCL328">
<HintPath>..\..\packages\JetBrains.Annotations.8.0.5.0\lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\JetBrains.Annotations.PCL328.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
Expand All @@ -58,6 +61,9 @@
<Name>SQLite.Net</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Loading

0 comments on commit 43216c5

Please sign in to comment.