Skip to content

Commit 8ec4dd5

Browse files
committed
Add code contracts, update raw version number, bump version numbers.
1 parent 38db6fe commit 8ec4dd5

13 files changed

+152
-15
lines changed

SQLitePCL.pretty.Async.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>SQLitePCL.pretty.Async</id>
5-
<version>0.0.12-pre2</version>
5+
<version>0.0.12-pre3</version>
66
<title>SQLitePCL.pretty.Async</title>
77
<authors>David Bordoley</authors>
88
<licenseUrl>https://github.com/bordoley/SQLitePCL.pretty/blob/master/LICENSE</licenseUrl>
@@ -15,7 +15,7 @@
1515
<reference file="SQLitePCL.pretty.Async.dll" />
1616
</references>
1717
<dependencies>
18-
<dependency id="SQLitePCL.pretty" version="0.0.12-pre2" />
18+
<dependency id="SQLitePCL.pretty" version="0.0.12-pre3" />
1919
<dependency id="Rx-Main" version="2.2.5" />
2020
</dependencies>
2121
</metadata>

SQLitePCL.pretty.Orm.nuspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
<package >
33
<metadata>
44
<id>SQLitePCL.pretty.Orm</id>
5-
<version>0.0.12-pre2</version>
5+
<version>0.0.12-pre3</version>
66
<title>SQLitePCL.pretty.Orm</title>
77
<authors>David Bordoley</authors>
88
<licenseUrl>https://github.com/bordoley/SQLitePCL.pretty/blob/master/LICENSE</licenseUrl>
99
<projectUrl>https://github.com/bordoley/SQLitePCL.pretty</projectUrl>
1010
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1111
<summary>Table mapping ORM for SQLitePCL.pretty</summary>
12-
<description>Provides a simple table mapping ORM similar to the one provided by SQLite-Net.</description>
12+
<description>Provides a simple table mapping ORM for SQLitePCL.pretty.</description>
1313
<tags>portable sqlite pcl rx reactive LINQ orm</tags>
1414
<references>
1515
<reference file="SQLitePCL.pretty.Orm.dll" />
1616
</references>
1717
<dependencies>
18-
<dependency id="SQLitePCL.pretty" version="0.0.12-pre2" />
19-
<dependency id="SQLitePCL.pretty.Async" version="0.0.12-pre2" />
18+
<dependency id="SQLitePCL.pretty" version="0.0.12-pre3" />
19+
<dependency id="SQLitePCL.pretty.Async" version="0.0.12-pre3" />
2020
</dependencies>
2121
</metadata>
2222
<files>

SQLitePCL.pretty.Orm/SQLitePCL.pretty.Orm.csproj

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -10,6 +10,7 @@
1010
<AssemblyName>SQLitePCL.pretty.Orm</AssemblyName>
1111
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
1212
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<CodeContractsAssemblyMode>1</CodeContractsAssemblyMode>
1314
</PropertyGroup>
1415
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1516
<DebugSymbols>true</DebugSymbols>
@@ -29,6 +30,49 @@
2930
<WarningLevel>4</WarningLevel>
3031
<ConsolePause>false</ConsolePause>
3132
<DocumentationFile>bin\Release\SQLitePCL.pretty.Orm.xml</DocumentationFile>
33+
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
34+
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
35+
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
36+
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
37+
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
38+
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
39+
<CodeContractsNonNullObligations>True</CodeContractsNonNullObligations>
40+
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
41+
<CodeContractsArithmeticObligations>True</CodeContractsArithmeticObligations>
42+
<CodeContractsEnumObligations>True</CodeContractsEnumObligations>
43+
<CodeContractsRedundantAssumptions>True</CodeContractsRedundantAssumptions>
44+
<CodeContractsAssertsToContractsCheckBox>True</CodeContractsAssertsToContractsCheckBox>
45+
<CodeContractsRedundantTests>True</CodeContractsRedundantTests>
46+
<CodeContractsMissingPublicRequiresAsWarnings>True</CodeContractsMissingPublicRequiresAsWarnings>
47+
<CodeContractsMissingPublicEnsuresAsWarnings>False</CodeContractsMissingPublicEnsuresAsWarnings>
48+
<CodeContractsInferRequires>True</CodeContractsInferRequires>
49+
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
50+
<CodeContractsInferEnsuresAutoProperties>True</CodeContractsInferEnsuresAutoProperties>
51+
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
52+
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
53+
<CodeContractsSuggestAssumptionsForCallees>False</CodeContractsSuggestAssumptionsForCallees>
54+
<CodeContractsSuggestRequires>False</CodeContractsSuggestRequires>
55+
<CodeContractsNecessaryEnsures>True</CodeContractsNecessaryEnsures>
56+
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
57+
<CodeContractsSuggestReadonly>True</CodeContractsSuggestReadonly>
58+
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
59+
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
60+
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
61+
<CodeContractsEmitXMLDocs>True</CodeContractsEmitXMLDocs>
62+
<CodeContractsCustomRewriterAssembly />
63+
<CodeContractsCustomRewriterClass />
64+
<CodeContractsLibPaths />
65+
<CodeContractsExtraRewriteOptions />
66+
<CodeContractsExtraAnalysisOptions />
67+
<CodeContractsSQLServerOption />
68+
<CodeContractsBaseLineFile />
69+
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
70+
<CodeContractsSkipAnalysisIfCannotConnectToCache>False</CodeContractsSkipAnalysisIfCannotConnectToCache>
71+
<CodeContractsFailBuildOnWarnings>False</CodeContractsFailBuildOnWarnings>
72+
<CodeContractsBeingOptimisticOnExternal>True</CodeContractsBeingOptimisticOnExternal>
73+
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
74+
<CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly>
75+
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
3276
</PropertyGroup>
3377
<ItemGroup>
3478
<Compile Include="Properties\AssemblyInfo.cs" />

SQLitePCL.pretty.Orm/TableMappedStatement.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public static class TableMappedStatement
2020
/// <typeparam name="T">The mapped type.</typeparam>
2121
public static void Bind<T>(this ITableMappedStatement<T> This, T obj)
2222
{
23+
Contract.Requires(This != null);
24+
Contract.Requires(obj != null);
25+
2326
This.Bind(This.Mapping, obj);
2427
}
2528

SQLitePCL.pretty.Orm/TableMapping.Delete.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.Contracts;
34
using System.Linq;
45
using System.Threading;
56
using System.Threading.Tasks;
@@ -17,6 +18,9 @@ public static partial class TableMapping
1718
/// <typeparam name="T">The mapped type</typeparam>
1819
public static IStatement PrepareDeleteStatement<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
1920
{
21+
Contract.Requires(This != null);
22+
Contract.Requires(tableMapping != null);
23+
2024
return This.PrepareDelete(tableMapping.TableName, tableMapping.PrimaryKeyColumn());
2125
}
2226

@@ -48,6 +52,9 @@ private static IEnumerable<KeyValuePair<long,T>> YieldDeleteAll<T>(this IDatabas
4852
/// <typeparam name="T">The mapped type.</typeparam>
4953
public static bool TryDelete<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, long primaryKey, out T deleted)
5054
{
55+
Contract.Requires(This != null);
56+
Contract.Requires(tableMapping != null);
57+
5158
var result = This.YieldDeleteAll(tableMapping, new long[] { primaryKey }).FirstOrDefault();
5259
if (result.Value != null)
5360
{
@@ -71,6 +78,10 @@ public static bool TryDelete<T>(this IDatabaseConnection This, ITableMapping<T>
7178
/// <typeparam name="T">The mapped type.</typeparam>
7279
public static IReadOnlyDictionary<long,T> DeleteAll<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys)
7380
{
81+
Contract.Requires(This != null);
82+
Contract.Requires(tableMapping != null);
83+
Contract.Requires(primaryKeys != null);
84+
7485
return This.RunInTransaction(_ =>
7586
This.YieldDeleteAll(tableMapping, primaryKeys)
7687
.Where(kvp => kvp.Value != null)
@@ -88,6 +99,10 @@ public static IReadOnlyDictionary<long,T> DeleteAll<T>(this IDatabaseConnection
8899
/// <typeparam name="T">The mapped type.</typeparam>
89100
public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys, CancellationToken ct)
90101
{
102+
Contract.Requires(This != null);
103+
Contract.Requires(tableMapping != null);
104+
Contract.Requires(primaryKeys != null);
105+
91106
return This.Use((db,_) => db.DeleteAll<T>(tableMapping, primaryKeys), ct);
92107
}
93108

@@ -101,6 +116,10 @@ public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDat
101116
/// <typeparam name="T">The mapped type.</typeparam>
102117
public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys)
103118
{
119+
Contract.Requires(This != null);
120+
Contract.Requires(tableMapping != null);
121+
Contract.Requires(primaryKeys != null);
122+
104123
return This.DeleteAllAsync(tableMapping, primaryKeys, CancellationToken.None);
105124
}
106125

@@ -112,6 +131,9 @@ public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(this IAsyncDat
112131
/// <typeparam name="T">The mapped type.</typeparam>
113132
public static void DeleteAllRows<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
114133
{
134+
Contract.Requires(This != null);
135+
Contract.Requires(tableMapping != null);
136+
115137
This.DeleteAll(tableMapping.TableName);
116138
}
117139

@@ -125,6 +147,9 @@ public static void DeleteAllRows<T>(this IDatabaseConnection This, ITableMapping
125147
/// <typeparam name="T">The mapped type.</typeparam>
126148
public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping, CancellationToken ct)
127149
{
150+
Contract.Requires(This != null);
151+
Contract.Requires(tableMapping != null);
152+
128153
return This.Use((db, _) => db.DeleteAllRows(tableMapping), ct);
129154
}
130155

@@ -137,6 +162,9 @@ public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, ITa
137162
/// <typeparam name="T">The mapped type.</typeparam>
138163
public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, ITableMapping<T> tableMapping)
139164
{
165+
Contract.Requires(This != null);
166+
Contract.Requires(tableMapping != null);
167+
140168
return This.DeleteAllRowsAsync(tableMapping, CancellationToken.None);
141169
}
142170
}

SQLitePCL.pretty.Orm/TableMapping.Find.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.Contracts;
34
using System.Linq;
45
using System.Runtime.CompilerServices;
56
using System.Threading;
@@ -30,6 +31,9 @@ private static string Find(this ITableMapping This)
3031
/// <typeparam name="T">The mapped type</typeparam>
3132
public static ITableMappedStatement<T> PrepareFindStatement<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
3233
{
34+
Contract.Requires(This != null);
35+
Contract.Requires(tableMapping != null);
36+
3337
return new TableMappedStatement<T>(This.PrepareStatement(tableMapping.Find()), tableMapping);
3438
}
3539

@@ -56,6 +60,9 @@ private static IEnumerable<KeyValuePair<long,T>> YieldFindAll<T>(this IDatabaseC
5660
/// <typeparam name="T">The mapped type.</typeparam>
5761
public static bool TryFind<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, long primaryKey, out T value)
5862
{
63+
Contract.Requires(This != null);
64+
Contract.Requires(tableMapping != null);
65+
5966
var result = This.YieldFindAll(tableMapping, new long[] { primaryKey }).FirstOrDefault();
6067

6168
if (result.Value != null)
@@ -78,6 +85,10 @@ public static bool TryFind<T>(this IDatabaseConnection This, ITableMapping<T> ta
7885
/// <typeparam name="T">The mapped type.</typeparam>
7986
public static IReadOnlyDictionary<long,T> FindAll<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<long> primaryKeys)
8087
{
88+
Contract.Requires(This != null);
89+
Contract.Requires(tableMapping != null);
90+
Contract.Requires(primaryKeys != null);
91+
8192
return This.YieldFindAll(tableMapping, primaryKeys)
8293
.Where(kvp => kvp.Value != null)
8394
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
@@ -98,6 +109,10 @@ public static Task<IReadOnlyDictionary<long,T>> FindAllAsync<T>(
98109
IEnumerable<long> primaryKeys,
99110
CancellationToken ct)
100111
{
112+
Contract.Requires(This != null);
113+
Contract.Requires(tableMapping != null);
114+
Contract.Requires(primaryKeys != null);
115+
101116
return This.Use((db,_) => db.FindAll(tableMapping, primaryKeys), ct);
102117
}
103118

@@ -114,6 +129,10 @@ public static Task<IReadOnlyDictionary<long,T>> FindAllAsync<T>(
114129
ITableMapping<T> tableMapping,
115130
IEnumerable<long> primaryKeys)
116131
{
132+
Contract.Requires(This != null);
133+
Contract.Requires(tableMapping != null);
134+
Contract.Requires(primaryKeys != null);
135+
117136
return This.FindAllAsync(tableMapping, primaryKeys, CancellationToken.None);
118137
}
119138
}

SQLitePCL.pretty.Orm/TableMapping.InsertOrReplace.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.Contracts;
34
using System.Linq;
45
using System.Threading;
56
using System.Threading.Tasks;
@@ -22,6 +23,8 @@ private static string InsertOrReplace<T>(this ITableMapping<T> tableMapping)
2223
/// <typeparam name="T">The mapped type</typeparam>
2324
public static ITableMappedStatement<T> PrepareInsertOrReplaceStatement<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping)
2425
{
26+
Contract.Requires(This != null);
27+
Contract.Requires(tableMapping != null);
2528
return new TableMappedStatement<T>(This.PrepareStatement(tableMapping.InsertOrReplace()), tableMapping);
2629
}
2730

@@ -49,6 +52,10 @@ private static IEnumerable<KeyValuePair<T,T>> YieldInsertOrReplaceAll<T>(this ID
4952
/// <typeparam name="T">The mapped type.</typeparam>
5053
public static T InsertOrReplace<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, T obj)
5154
{
55+
Contract.Requires(This != null);
56+
Contract.Requires(tableMapping != null);
57+
Contract.Requires(obj != null);
58+
5259
return This.YieldInsertOrReplaceAll(tableMapping, new T[] {obj}).First().Value;
5360
}
5461

@@ -62,6 +69,10 @@ public static T InsertOrReplace<T>(this IDatabaseConnection This, ITableMapping<
6269
/// <typeparam name="T">The mapped type.</typeparam>
6370
public static IReadOnlyDictionary<T,T> InsertOrReplaceAll<T>(this IDatabaseConnection This, ITableMapping<T> tableMapping, IEnumerable<T> objects)
6471
{
72+
Contract.Requires(This != null);
73+
Contract.Requires(tableMapping != null);
74+
Contract.Requires(objects != null);
75+
6576
return This.RunInTransaction(_ =>
6677
This.YieldInsertOrReplaceAll(tableMapping, objects).ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
6778
}
@@ -81,6 +92,10 @@ public static Task<IReadOnlyDictionary<T,T>> InsertOrReplaceAllAsync<T>(
8192
IEnumerable<T> objects,
8293
CancellationToken ct)
8394
{
95+
Contract.Requires(This != null);
96+
Contract.Requires(tableMapping != null);
97+
Contract.Requires(objects != null);
98+
8499
return This.Use((db, _) => db.InsertOrReplaceAll(tableMapping, objects), ct);
85100
}
86101

@@ -97,6 +112,10 @@ public static Task<IReadOnlyDictionary<T,T>> InsertOrReplaceAllAsync<T>(
97112
ITableMapping<T> tableMapping,
98113
IEnumerable<T> objects)
99114
{
115+
Contract.Requires(This != null);
116+
Contract.Requires(tableMapping != null);
117+
Contract.Requires(objects != null);
118+
100119
return This.InsertOrReplaceAllAsync(tableMapping, objects, CancellationToken.None);
101120
}
102121
}

0 commit comments

Comments
 (0)