Skip to content

Commit

Permalink
Add code contracts, update raw version number, bump version numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
bordoley committed Mar 21, 2015
1 parent 38db6fe commit 8ec4dd5
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 15 deletions.
4 changes: 2 additions & 2 deletions SQLitePCL.pretty.Async.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>SQLitePCL.pretty.Async</id>
<version>0.0.12-pre2</version>
<version>0.0.12-pre3</version>
<title>SQLitePCL.pretty.Async</title>
<authors>David Bordoley</authors>
<licenseUrl>https://github.com/bordoley/SQLitePCL.pretty/blob/master/LICENSE</licenseUrl>
Expand All @@ -15,7 +15,7 @@
<reference file="SQLitePCL.pretty.Async.dll" />
</references>
<dependencies>
<dependency id="SQLitePCL.pretty" version="0.0.12-pre2" />
<dependency id="SQLitePCL.pretty" version="0.0.12-pre3" />
<dependency id="Rx-Main" version="2.2.5" />
</dependencies>
</metadata>
Expand Down
8 changes: 4 additions & 4 deletions SQLitePCL.pretty.Orm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
<package >
<metadata>
<id>SQLitePCL.pretty.Orm</id>
<version>0.0.12-pre2</version>
<version>0.0.12-pre3</version>
<title>SQLitePCL.pretty.Orm</title>
<authors>David Bordoley</authors>
<licenseUrl>https://github.com/bordoley/SQLitePCL.pretty/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/bordoley/SQLitePCL.pretty</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>Table mapping ORM for SQLitePCL.pretty</summary>
<description>Provides a simple table mapping ORM similar to the one provided by SQLite-Net.</description>
<description>Provides a simple table mapping ORM for SQLitePCL.pretty.</description>
<tags>portable sqlite pcl rx reactive LINQ orm</tags>
<references>
<reference file="SQLitePCL.pretty.Orm.dll" />
</references>
<dependencies>
<dependency id="SQLitePCL.pretty" version="0.0.12-pre2" />
<dependency id="SQLitePCL.pretty.Async" version="0.0.12-pre2" />
<dependency id="SQLitePCL.pretty" version="0.0.12-pre3" />
<dependency id="SQLitePCL.pretty.Async" version="0.0.12-pre3" />
</dependencies>
</metadata>
<files>
Expand Down
46 changes: 45 additions & 1 deletion SQLitePCL.pretty.Orm/SQLitePCL.pretty.Orm.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -10,6 +10,7 @@
<AssemblyName>SQLitePCL.pretty.Orm</AssemblyName>
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<CodeContractsAssemblyMode>1</CodeContractsAssemblyMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -29,6 +30,49 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<DocumentationFile>bin\Release\SQLitePCL.pretty.Orm.xml</DocumentationFile>
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>True</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>True</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>True</CodeContractsEnumObligations>
<CodeContractsRedundantAssumptions>True</CodeContractsRedundantAssumptions>
<CodeContractsAssertsToContractsCheckBox>True</CodeContractsAssertsToContractsCheckBox>
<CodeContractsRedundantTests>True</CodeContractsRedundantTests>
<CodeContractsMissingPublicRequiresAsWarnings>True</CodeContractsMissingPublicRequiresAsWarnings>
<CodeContractsMissingPublicEnsuresAsWarnings>False</CodeContractsMissingPublicEnsuresAsWarnings>
<CodeContractsInferRequires>True</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferEnsuresAutoProperties>True</CodeContractsInferEnsuresAutoProperties>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestAssumptionsForCallees>False</CodeContractsSuggestAssumptionsForCallees>
<CodeContractsSuggestRequires>False</CodeContractsSuggestRequires>
<CodeContractsNecessaryEnsures>True</CodeContractsNecessaryEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsSuggestReadonly>True</CodeContractsSuggestReadonly>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>True</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions />
<CodeContractsSQLServerOption />
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsSkipAnalysisIfCannotConnectToCache>False</CodeContractsSkipAnalysisIfCannotConnectToCache>
<CodeContractsFailBuildOnWarnings>False</CodeContractsFailBuildOnWarnings>
<CodeContractsBeingOptimisticOnExternal>True</CodeContractsBeingOptimisticOnExternal>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
3 changes: 3 additions & 0 deletions SQLitePCL.pretty.Orm/TableMappedStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public static class TableMappedStatement
/// <typeparam name="T">The mapped type.</typeparam>
public static void Bind<T>(this ITableMappedStatement<T> This, T obj)
{
Contract.Requires(This != null);
Contract.Requires(obj != null);

This.Bind(This.Mapping, obj);
}

Expand Down
28 changes: 28 additions & 0 deletions SQLitePCL.pretty.Orm/TableMapping.Delete.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -17,6 +18,9 @@ public static partial class TableMapping
/// <typeparam name="T">The mapped type</typeparam>
public static IStatement PrepareDeleteStatement<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);

return This.PrepareDelete(tableMapping.TableName, tableMapping.PrimaryKeyColumn());
}

Expand Down Expand Up @@ -48,6 +52,9 @@ private static IEnumerable<KeyValuePair<long,T>> YieldDeleteAll<T>(this IDatabas
/// <typeparam name="T">The mapped type.</typeparam>
public static bool TryDelete<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, long primaryKey, out T deleted)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);

var result = This.YieldDeleteAll(tableMapping, new long[] { primaryKey }).FirstOrDefault();
if (result.Value != null)
{
Expand All @@ -71,6 +78,10 @@ public static bool TryDelete<T>(this IDatabaseConnection This, ITableMapping<T>
/// <typeparam name="T">The mapped type.</typeparam>
public static IReadOnlyDictionary<long,T> DeleteAll<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(primaryKeys != null);

return This.RunInTransaction(_ =>
This.YieldDeleteAll(tableMapping, primaryKeys)
.Where(kvp => kvp.Value != null)
Expand All @@ -88,6 +99,10 @@ public static IReadOnlyDictionary<long,T> DeleteAll<T>(this IDatabaseConnection
/// <typeparam name="T">The mapped type.</typeparam>
public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys, CancellationToken ct)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(primaryKeys != null);

return This.Use((db,_) => db.DeleteAll<T>(tableMapping, primaryKeys), ct);
}

Expand All @@ -101,6 +116,10 @@ public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDat
/// <typeparam name="T">The mapped type.</typeparam>
public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(primaryKeys != null);

return This.DeleteAllAsync(tableMapping, primaryKeys, CancellationToken.None);
}

Expand All @@ -112,6 +131,9 @@ public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDat
/// <typeparam name="T">The mapped type.</typeparam>
public static void DeleteAllRows<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);

This.DeleteAll(tableMapping.TableName);
}

Expand All @@ -125,6 +147,9 @@ public static void DeleteAllRows<T>(this IDatabaseConnection This, ITableMapping
/// <typeparam name="T">The mapped type.</typeparam>
public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping, CancellationToken ct)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);

return This.Use((db, _) => db.DeleteAllRows(tableMapping), ct);
}

Expand All @@ -137,6 +162,9 @@ public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, ITa
/// <typeparam name="T">The mapped type.</typeparam>
public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);

return This.DeleteAllRowsAsync(tableMapping, CancellationToken.None);
}
}
Expand Down
19 changes: 19 additions & 0 deletions SQLitePCL.pretty.Orm/TableMapping.Find.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
Expand Down Expand Up @@ -30,6 +31,9 @@ private static string Find(this ITableMapping This)
/// <typeparam name="T">The mapped type</typeparam>
public static ITableMappedStatement<T> PrepareFindStatement<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);

return new TableMappedStatement<T>(This.PrepareStatement(tableMapping.Find()), tableMapping);
}

Expand All @@ -56,6 +60,9 @@ private static IEnumerable<KeyValuePair<long,T>> YieldFindAll<T>(this IDatabaseC
/// <typeparam name="T">The mapped type.</typeparam>
public static bool TryFind<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, long primaryKey, out T value)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);

var result = This.YieldFindAll(tableMapping, new long[] { primaryKey }).FirstOrDefault();

if (result.Value != null)
Expand All @@ -78,6 +85,10 @@ public static bool TryFind<T>(this IDatabaseConnection This, ITableMapping<T> ta
/// <typeparam name="T">The mapped type.</typeparam>
public static IReadOnlyDictionary<long,T> FindAll<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(primaryKeys != null);

return This.YieldFindAll(tableMapping, primaryKeys)
.Where(kvp => kvp.Value != null)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
Expand All @@ -98,6 +109,10 @@ public static Task<IReadOnlyDictionary<long,T>> FindAllAsync<T>(
IEnumerable<long> primaryKeys,
CancellationToken ct)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(primaryKeys != null);

return This.Use((db,_) => db.FindAll(tableMapping, primaryKeys), ct);
}

Expand All @@ -114,6 +129,10 @@ public static Task<IReadOnlyDictionary<long,T>> FindAllAsync<T>(
ITableMapping<T> tableMapping,
IEnumerable<long> primaryKeys)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(primaryKeys != null);

return This.FindAllAsync(tableMapping, primaryKeys, CancellationToken.None);
}
}
Expand Down
19 changes: 19 additions & 0 deletions SQLitePCL.pretty.Orm/TableMapping.InsertOrReplace.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -22,6 +23,8 @@ private static string InsertOrReplace<T>(this ITableMapping<T> tableMapping)
/// <typeparam name="T">The mapped type</typeparam>
public static ITableMappedStatement<T> PrepareInsertOrReplaceStatement<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
return new TableMappedStatement<T>(This.PrepareStatement(tableMapping.InsertOrReplace()), tableMapping);
}

Expand Down Expand Up @@ -49,6 +52,10 @@ private static IEnumerable<KeyValuePair<T,T>> YieldInsertOrReplaceAll<T>(this ID
/// <typeparam name="T">The mapped type.</typeparam>
public static T InsertOrReplace<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, T obj)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(obj != null);

return This.YieldInsertOrReplaceAll(tableMapping, new T[] {obj}).First().Value;
}

Expand All @@ -62,6 +69,10 @@ public static T InsertOrReplace<T>(this IDatabaseConnection This, ITableMapping<
/// <typeparam name="T">The mapped type.</typeparam>
public static IReadOnlyDictionary<T,T> InsertOrReplaceAll<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<T> objects)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(objects != null);

return This.RunInTransaction(_ =>
This.YieldInsertOrReplaceAll(tableMapping, objects).ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
}
Expand All @@ -81,6 +92,10 @@ public static Task<IReadOnlyDictionary<T,T>> InsertOrReplaceAllAsync<T>(
IEnumerable<T> objects,
CancellationToken ct)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(objects != null);

return This.Use((db, _) => db.InsertOrReplaceAll(tableMapping, objects), ct);
}

Expand All @@ -97,6 +112,10 @@ public static Task<IReadOnlyDictionary<T,T>> InsertOrReplaceAllAsync<T>(
ITableMapping<T> tableMapping,
IEnumerable<T> objects)
{
Contract.Requires(This != null);
Contract.Requires(tableMapping != null);
Contract.Requires(objects != null);

return This.InsertOrReplaceAllAsync(tableMapping, objects, CancellationToken.None);
}
}
Expand Down
Loading

0 comments on commit 8ec4dd5

Please sign in to comment.