From 9dc059fe8abbeec16fa2c60cbd228cb3b59e6865 Mon Sep 17 00:00:00 2001 From: Rob Ashton Date: Sat, 23 Oct 2010 19:02:10 +0100 Subject: [PATCH] Merged Ayende's changes --- .gitignore | 190 +- Raven.Client.3.5/Raven.Client.3.5.csproj.orig | 841 +++++++++ .../Raven.Client.Lightweight.csproj.orig | 891 ++++++++++ .../Bugs/CanUseNonStringsForId.cs | 136 +- .../Bugs/ProjectionFromDynamicQuery.cs | 324 ++-- .../Raven.Client.Tests.csproj.orig | 504 ++++++ Raven.Client/Converters/GuidConverter.cs | 94 +- Raven.Client/Converters/ITypeConverter.cs | 78 +- Raven.Client/Converters/Int32Converter.cs | 94 +- Raven.Client/Converters/Int64Converter.cs | 94 +- Raven.Client/Document/DocumentConvention.cs | 362 ++-- .../InMemoryDocumentSessionOperations.cs | 1522 ++++++++--------- Raven.Client/Raven.Client.csproj.orig | 431 +++++ RavenDB.nuspec | 24 +- default.ps1 | 20 +- 15 files changed, 4136 insertions(+), 1469 deletions(-) create mode 100644 Raven.Client.3.5/Raven.Client.3.5.csproj.orig create mode 100644 Raven.Client.Lightweight/Raven.Client.Lightweight.csproj.orig create mode 100644 Raven.Client.Tests/Raven.Client.Tests.csproj.orig create mode 100644 Raven.Client/Raven.Client.csproj.orig diff --git a/.gitignore b/.gitignore index a2de6890b31c..f88874e6421e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,101 +16,101 @@ _ReSharper.*/ /Data/logs/ /Data/system/ /Data/temp/ -*.InstallLog -/Raven.Database/Raven.Database.g.csproj -/test/storage.raven -/Raven.Web/Data/ +*.InstallLog +/Raven.Database/Raven.Database.g.csproj +/test/storage.raven +/Raven.Web/Data/ /SharedLibs/Sources/Json-52373/trunk/Working/ VERSION -AssemblyInfo.cs -/Samples/Raven.Samples.IndexReplication/Server/Esent.Interop.dll -/Samples/Raven.Samples.IndexReplication/Server/ICSharpCode.NRefactory.dll -/Samples/Raven.Samples.IndexReplication/Server/Lucene.Net.dll -/Samples/Raven.Samples.IndexReplication/Server/Newtonsoft.Json.dll -/Samples/Raven.Samples.IndexReplication/Server/Raven.Database.dll -/Samples/Raven.Samples.IndexReplication/Server/Raven.Server.exe -/Samples/Raven.Samples.IndexReplication/Server/Raven.Storage.Esent.dll -/Samples/Raven.Samples.IndexReplication/Server/Rhino.Licensing.dll -/Samples/Raven.Samples.IndexReplication/Server/log4net.dll -/Samples/MvcMusicStore/Server/Esent.Interop.dll -/Samples/MvcMusicStore/Server/ICSharpCode.NRefactory.dll -/Samples/MvcMusicStore/Server/Lucene.Net.dll -/Samples/MvcMusicStore/Server/Newtonsoft.Json.dll -/Samples/MvcMusicStore/Server/Raven.Database.dll -/Samples/MvcMusicStore/Server/Raven.Server.exe -/Samples/MvcMusicStore/Server/Raven.Storage.Esent.dll -/Samples/MvcMusicStore/Server/Rhino.Licensing.dll -/Samples/MvcMusicStore/Server/log4net.dll -/Samples/MvcMusicStore/Server/Esent.Interop.dll -/Samples/MvcMusicStore/Server/ICSharpCode.NRefactory.dll -/Samples/MvcMusicStore/Server/Lucene.Net.dll -/Samples/MvcMusicStore/Server/Newtonsoft.Json.dll -/Samples/MvcMusicStore/Server/Raven.Database.dll -/Samples/MvcMusicStore/Server/Raven.Server.exe -/Samples/MvcMusicStore/Server/Raven.Storage.Esent.dll -/Samples/MvcMusicStore/Server/Rhino.Licensing.dll -/Samples/MvcMusicStore/Server/log4net.dll -/Samples/Raven.Sample.EventSourcing/Server/Esent.Interop.dll -/Samples/Raven.Sample.EventSourcing/Server/ICSharpCode.NRefactory.dll -/Samples/Raven.Sample.EventSourcing/Server/Lucene.Net.dll -/Samples/Raven.Sample.EventSourcing/Server/Newtonsoft.Json.dll -/Samples/Raven.Sample.EventSourcing/Server/Raven.Database.dll -/Samples/Raven.Sample.EventSourcing/Server/Raven.Server.exe -/Samples/Raven.Sample.EventSourcing/Server/Raven.Storage.Esent.dll -/Samples/Raven.Sample.EventSourcing/Server/Rhino.Licensing.dll -/Samples/Raven.Sample.EventSourcing/Server/log4net.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/Esent.Interop.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/ICSharpCode.NRefactory.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/Lucene.Net.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/Newtonsoft.Json.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/Raven.Database.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/Raven.Server.exe -/Samples/Raven.Sample.Failover/Servers/Shard1/Raven.Storage.Esent.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/Rhino.Licensing.dll -/Samples/Raven.Sample.Failover/Servers/Shard1/log4net.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/Esent.Interop.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/ICSharpCode.NRefactory.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/Lucene.Net.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/Newtonsoft.Json.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/Raven.Database.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/Raven.Server.exe -/Samples/Raven.Sample.Failover/Servers/Shard2/Raven.Storage.Esent.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/Rhino.Licensing.dll -/Samples/Raven.Sample.Failover/Servers/Shard2/log4net.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/Esent.Interop.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/ICSharpCode.NRefactory.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/Lucene.Net.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/Newtonsoft.Json.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/Raven.Database.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/Raven.Server.exe -/Samples/Raven.Sample.Replication/Servers/Shard1/Raven.Storage.Esent.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/Rhino.Licensing.dll -/Samples/Raven.Sample.Replication/Servers/Shard1/log4net.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/Esent.Interop.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/ICSharpCode.NRefactory.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/Lucene.Net.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/Newtonsoft.Json.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/Raven.Database.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/Raven.Server.exe -/Samples/Raven.Sample.Replication/Servers/Shard2/Raven.Storage.Esent.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/Rhino.Licensing.dll -/Samples/Raven.Sample.Replication/Servers/Shard2/log4net.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/Esent.Interop.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/ICSharpCode.NRefactory.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/Lucene.Net.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/Newtonsoft.Json.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/Raven.Database.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/Raven.Server.exe -/Samples/Raven.Sample.ShardClient/Servers/Shard1/Raven.Storage.Esent.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/Rhino.Licensing.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard1/log4net.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/Esent.Interop.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/ICSharpCode.NRefactory.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/Lucene.Net.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/Newtonsoft.Json.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/Raven.Database.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/Raven.Server.exe -/Samples/Raven.Sample.ShardClient/Servers/Shard2/Raven.Storage.Esent.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/Rhino.Licensing.dll -/Samples/Raven.Sample.ShardClient/Servers/Shard2/log4net.dll +AssemblyInfo.cs +/Samples/Raven.Samples.IndexReplication/Server/Esent.Interop.dll +/Samples/Raven.Samples.IndexReplication/Server/ICSharpCode.NRefactory.dll +/Samples/Raven.Samples.IndexReplication/Server/Lucene.Net.dll +/Samples/Raven.Samples.IndexReplication/Server/Newtonsoft.Json.dll +/Samples/Raven.Samples.IndexReplication/Server/Raven.Database.dll +/Samples/Raven.Samples.IndexReplication/Server/Raven.Server.exe +/Samples/Raven.Samples.IndexReplication/Server/Raven.Storage.Esent.dll +/Samples/Raven.Samples.IndexReplication/Server/Rhino.Licensing.dll +/Samples/Raven.Samples.IndexReplication/Server/log4net.dll +/Samples/MvcMusicStore/Server/Esent.Interop.dll +/Samples/MvcMusicStore/Server/ICSharpCode.NRefactory.dll +/Samples/MvcMusicStore/Server/Lucene.Net.dll +/Samples/MvcMusicStore/Server/Newtonsoft.Json.dll +/Samples/MvcMusicStore/Server/Raven.Database.dll +/Samples/MvcMusicStore/Server/Raven.Server.exe +/Samples/MvcMusicStore/Server/Raven.Storage.Esent.dll +/Samples/MvcMusicStore/Server/Rhino.Licensing.dll +/Samples/MvcMusicStore/Server/log4net.dll +/Samples/MvcMusicStore/Server/Esent.Interop.dll +/Samples/MvcMusicStore/Server/ICSharpCode.NRefactory.dll +/Samples/MvcMusicStore/Server/Lucene.Net.dll +/Samples/MvcMusicStore/Server/Newtonsoft.Json.dll +/Samples/MvcMusicStore/Server/Raven.Database.dll +/Samples/MvcMusicStore/Server/Raven.Server.exe +/Samples/MvcMusicStore/Server/Raven.Storage.Esent.dll +/Samples/MvcMusicStore/Server/Rhino.Licensing.dll +/Samples/MvcMusicStore/Server/log4net.dll +/Samples/Raven.Sample.EventSourcing/Server/Esent.Interop.dll +/Samples/Raven.Sample.EventSourcing/Server/ICSharpCode.NRefactory.dll +/Samples/Raven.Sample.EventSourcing/Server/Lucene.Net.dll +/Samples/Raven.Sample.EventSourcing/Server/Newtonsoft.Json.dll +/Samples/Raven.Sample.EventSourcing/Server/Raven.Database.dll +/Samples/Raven.Sample.EventSourcing/Server/Raven.Server.exe +/Samples/Raven.Sample.EventSourcing/Server/Raven.Storage.Esent.dll +/Samples/Raven.Sample.EventSourcing/Server/Rhino.Licensing.dll +/Samples/Raven.Sample.EventSourcing/Server/log4net.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/Esent.Interop.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/ICSharpCode.NRefactory.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/Lucene.Net.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/Newtonsoft.Json.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/Raven.Database.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/Raven.Server.exe +/Samples/Raven.Sample.Failover/Servers/Shard1/Raven.Storage.Esent.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/Rhino.Licensing.dll +/Samples/Raven.Sample.Failover/Servers/Shard1/log4net.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/Esent.Interop.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/ICSharpCode.NRefactory.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/Lucene.Net.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/Newtonsoft.Json.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/Raven.Database.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/Raven.Server.exe +/Samples/Raven.Sample.Failover/Servers/Shard2/Raven.Storage.Esent.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/Rhino.Licensing.dll +/Samples/Raven.Sample.Failover/Servers/Shard2/log4net.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/Esent.Interop.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/ICSharpCode.NRefactory.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/Lucene.Net.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/Newtonsoft.Json.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/Raven.Database.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/Raven.Server.exe +/Samples/Raven.Sample.Replication/Servers/Shard1/Raven.Storage.Esent.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/Rhino.Licensing.dll +/Samples/Raven.Sample.Replication/Servers/Shard1/log4net.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/Esent.Interop.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/ICSharpCode.NRefactory.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/Lucene.Net.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/Newtonsoft.Json.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/Raven.Database.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/Raven.Server.exe +/Samples/Raven.Sample.Replication/Servers/Shard2/Raven.Storage.Esent.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/Rhino.Licensing.dll +/Samples/Raven.Sample.Replication/Servers/Shard2/log4net.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/Esent.Interop.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/ICSharpCode.NRefactory.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/Lucene.Net.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/Newtonsoft.Json.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/Raven.Database.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/Raven.Server.exe +/Samples/Raven.Sample.ShardClient/Servers/Shard1/Raven.Storage.Esent.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/Rhino.Licensing.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard1/log4net.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/Esent.Interop.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/ICSharpCode.NRefactory.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/Lucene.Net.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/Newtonsoft.Json.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/Raven.Database.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/Raven.Server.exe +/Samples/Raven.Sample.ShardClient/Servers/Shard2/Raven.Storage.Esent.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/Rhino.Licensing.dll +/Samples/Raven.Sample.ShardClient/Servers/Shard2/log4net.dll *.nupkg \ No newline at end of file diff --git a/Raven.Client.3.5/Raven.Client.3.5.csproj.orig b/Raven.Client.3.5/Raven.Client.3.5.csproj.orig new file mode 100644 index 000000000000..0ddc6383b2d5 --- /dev/null +++ b/Raven.Client.3.5/Raven.Client.3.5.csproj.orig @@ -0,0 +1,841 @@ +<<<<<<< HEAD + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {FCAF4299-10DF-4ECF-A81E-28BA158174BF} + Library + Properties + Raven.Client + Raven.Client-3.5 + v3.5 + 512 + Client + + + true + full + false + bin\Debug\ + TRACE;DEBUG;CLIENT NET_3_5 + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE;CLIENT NET_3_5 + prompt + 4 + + + true + + + ..\Raven.Database\RavenDB.snk + + + + ..\SharedLibs\Newtonsoft.Json.dll + + + + + + + + + + + + + Data\ReplicationDestination.cs + + + Data\ReplicationDocument.cs + + + Client\Async\AsyncServerClient.cs + + + Client\Async\IAsyncDatabaseCommands.cs + + + Client\Async\WrapperAsyncData.cs + + + Client\HttpJsonRequest.cs + + + Client\IDatabaseCommands.cs + + + Client\JsonExtensions.cs + + + Client\JsonLuceneDateTimeConverter.cs + + + Client\RavenQuery.cs + + + Client\RavenTransactionAccessor.cs + + + Client\ReplicationInformer.cs + + + Client\SerializationHelper.cs + + + Client\ServerClient.cs + + + Client\WebRequestEventArgs.cs + + + Client\WebResponseExtensions.cs + + + Document\Async\AsyncDocumentSession.cs + + + Document\Async\SyncronousLoadResult.cs + + + Document\DefaultRavenContractResolver.cs + + + Document\DocumentConvention.cs + + + Document\DocumentQuery.cs + + + Document\DocumentSession.cs + + + Document\DocumentStore.cs + + + Document\HiLoKeyGenerator.cs + + + Document\ILoaderWithInclude.cs + + + Document\InMemoryDocumentSessionOperations.cs + + + Document\MultiLoaderWithInclude.cs + + + Document\MultiTypeHiLoKeyGenerator.cs + + + Document\PromotableRavenClientEnlistment.cs + + + Document\RavenClientEnlistment.cs + + + Document\ReflectionUtil.cs + + + Document\ShardedDocumentQuery.cs + + + Document\SpatialDocumentQuery.cs + + + Document\EntityStored.cs + + + Document\EntityToDocument.cs + + + Exceptions\ConflictException.cs + + + Exceptions\NonAuthoritiveInformationException.cs + + + Exceptions\NonUniqueObjectException.cs + + + Exceptions\ReadVetoException.cs + + + IAdvancedDocumentSessionOperations.cs + + + IAsyncAdvancedSessionOperations.cs + + + IAsyncDocumentSession.cs + + + IDocumentDeleteListener.cs + + + IDocumentQuery.cs + + + IDocumentQueryCustomization.cs + + + IDocumentSession.cs + + + IDocumentStore.cs + + + IDocumentStoreListener.cs + + + Indexes\AbstractIndexCreationTask.cs + + + Indexes\ExpressionOperatorPrecedence.cs + + + Indexes\ExpressionOperatorPrecedenceExtension.cs + + + Indexes\IClientSideDatabase.cs + + + Indexes\IndexDefinition.cs + + + ISyncAdvancedSessionOperation.cs + + + ITransactionalDocumentSession.cs + + + Linq\DateTools.cs + + + Linq\DynamicQueryProviderProcessor.cs + + + Linq\DynamicRavenQueryable.cs + + + Linq\DynamicRavenQueryProvider.cs + + + Linq\ExpressionMemberInfo.cs + + + Linq\IRavenQueryable.cs + + + Linq\IRavenQueryProvider.cs + + + Linq\RavenQueryable.cs + + + Linq\RavenQueryProvider.cs + + + Linq\RavenQueryProviderProcessor.cs + + + Linq\RavenQueryStatistics.cs + + + Linq\TypeSystem.cs + + + RavenExtensions.cs + + + Shard\ShardedDocumentSession.cs + + + Shard\ShardedDocumentStore.cs + + + Shard\Shards.cs + + + Shard\ShardStrategy\IShardStrategy.cs + + + Shard\ShardStrategy\ShardAccess\IShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardAccess\SequentialShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardResolution\AllShardsResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\IShardResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\ShardResolutionStrategyData.cs + + + Shard\ShardStrategy\ShardSelection\IShardSelectionStrategy.cs + + + Shard\ShardStrategy\ShardStrategy.cs + + + StoredEntityEventArgs.cs + + + Util\Inflector.cs + + + Data\BatchResult.cs + + + Data\Attachment.cs + + + Commands\DeleteCommandData.cs + + + Data\DisposableAction.cs + + + Commands\ICommandData.cs + + + Data\IndexFailureInformation.cs + + + Data\IndexQuery.cs + + + Data\MetadataExtensions.cs + + + Data\MultiLoadResult.cs + + + Commands\PatchCommandData.cs + + + Commands\PutCommandData.cs + + + Data\QueryResult.cs + + + Data\SortedField.cs + + + Data\SpatialIndexQuery.cs + + + Exceptions\BadRequestException.cs + + + Exceptions\ConcurrencyException.cs + + + Exceptions\IndexDisabledException.cs + + + Exceptions\IndexDoesNotExistsException.cs + + + Exceptions\OperationVetoedException.cs + + + Extensions\ExpressionExtensions.cs + + + Data\Reference.cs + + + Extensions\StreamExtension.cs + + + Data\FieldIndexing.cs + + + Data\FieldStorage.cs + + + Data\IndexDefinition.cs + + + Linq\NumberUtil.cs + + + Data\SortOptions.cs + + + Data\JsonDocument.cs + + + Json\JsonEnumConverter.cs + + + Extensions\JsonExtensions.cs + + + Json\PatchCommandType.cs + + + Data\PatchRequest.cs + + + Data\PatchResult.cs + + + Data\PutResult.cs + + + Data\TransactionInformation.cs + + + + + + RavenDB.snk + + + +======= + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {FCAF4299-10DF-4ECF-A81E-28BA158174BF} + Library + Properties + Raven.Client + Raven.Client-3.5 + v3.5 + 512 + Client + + + true + full + false + bin\Debug\ + TRACE;DEBUG;CLIENT NET_3_5 + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE;CLIENT NET_3_5 + prompt + 4 + + + true + + + ..\Raven.Database\RavenDB.snk + + + + ..\SharedLibs\Newtonsoft.Json.dll + + + + + + + + + + + + + Data\ReplicationDestination.cs + + + Data\ReplicationDocument.cs + + + Client\Async\AsyncServerClient.cs + + + Client\Async\IAsyncDatabaseCommands.cs + + + Client\Async\WrapperAsyncData.cs + + + Client\HttpJsonRequest.cs + + + Client\IDatabaseCommands.cs + + + Client\JsonExtensions.cs + + + Client\JsonLuceneDateTimeConverter.cs + + + Client\RavenQuery.cs + + + Client\RavenTransactionAccessor.cs + + + Client\ReplicationInformer.cs + + + Client\SerializationHelper.cs + + + Client\ServerClient.cs + + + Client\WebRequestEventArgs.cs + + + Client\WebResponseExtensions.cs + + + Converters\GuidConverter.cs + + + Converters\Int32Converter.cs + + + Converters\Int64Converter.cs + + + Converters\ITypeConverter.cs + + + Document\Async\AsyncDocumentSession.cs + + + Document\Async\SyncronousLoadResult.cs + + + Document\DefaultRavenContractResolver.cs + + + Document\DocumentConvention.cs + + + Document\DocumentQuery.cs + + + Document\DocumentSession.cs + + + Document\DocumentStore.cs + + + Document\HiLoKeyGenerator.cs + + + Document\ILoaderWithInclude.cs + + + Document\InMemoryDocumentSessionOperations.cs + + + Document\MultiLoaderWithInclude.cs + + + Document\MultiTypeHiLoKeyGenerator.cs + + + Document\PromotableRavenClientEnlistment.cs + + + Document\RavenClientEnlistment.cs + + + Document\ReflectionUtil.cs + + + Document\ShardedDocumentQuery.cs + + + Document\SpatialDocumentQuery.cs + + + Document\EntityStored.cs + + + Document\EntityToDocument.cs + + + Exceptions\ConflictException.cs + + + Exceptions\NonAuthoritiveInformationException.cs + + + Exceptions\NonUniqueObjectException.cs + + + Exceptions\ReadVetoException.cs + + + IAdvancedDocumentSessionOperations.cs + + + IAsyncAdvancedSessionOperations.cs + + + IAsyncDocumentSession.cs + + + IDocumentDeleteListener.cs + + + IDocumentQuery.cs + + + IDocumentQueryCustomization.cs + + + IDocumentSession.cs + + + IDocumentStore.cs + + + IDocumentStoreListener.cs + + + Indexes\AbstractIndexCreationTask.cs + + + Indexes\ExpressionOperatorPrecedence.cs + + + Indexes\ExpressionOperatorPrecedenceExtension.cs + + + Indexes\IClientSideDatabase.cs + + + Indexes\IndexDefinition.cs + + + ISyncAdvancedSessionOperation.cs + + + ITransactionalDocumentSession.cs + + + Linq\DateTools.cs + + + Linq\DynamicQueryProviderProcessor.cs + + + Linq\DynamicRavenQueryable.cs + + + Linq\DynamicRavenQueryProvider.cs + + + Linq\ExpressionMemberInfo.cs + + + Linq\IRavenQueryable.cs + + + Linq\IRavenQueryProvider.cs + + + Linq\RavenQueryable.cs + + + Linq\RavenQueryProvider.cs + + + Linq\RavenQueryProviderProcessor.cs + + + Linq\RavenQueryStatistics.cs + + + Linq\TypeSystem.cs + + + RavenExtensions.cs + + + Shard\ShardedDocumentSession.cs + + + Shard\ShardedDocumentStore.cs + + + Shard\Shards.cs + + + Shard\ShardStrategy\IShardStrategy.cs + + + Shard\ShardStrategy\ShardAccess\IShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardAccess\SequentialShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardResolution\AllShardsResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\IShardResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\ShardResolutionStrategyData.cs + + + Shard\ShardStrategy\ShardSelection\IShardSelectionStrategy.cs + + + Shard\ShardStrategy\ShardStrategy.cs + + + StoredEntityEventArgs.cs + + + Util\Inflector.cs + + + Data\BatchResult.cs + + + Data\Attachment.cs + + + Commands\DeleteCommandData.cs + + + Data\DisposableAction.cs + + + Commands\ICommandData.cs + + + Data\IndexFailureInformation.cs + + + Data\IndexQuery.cs + + + Data\MetadataExtensions.cs + + + Data\MultiLoadResult.cs + + + Commands\PatchCommandData.cs + + + Commands\PutCommandData.cs + + + Data\QueryResult.cs + + + Data\SortedField.cs + + + Data\SpatialIndexQuery.cs + + + Exceptions\BadRequestException.cs + + + Exceptions\ConcurrencyException.cs + + + Exceptions\IndexDisabledException.cs + + + Exceptions\IndexDoesNotExistsException.cs + + + Exceptions\OperationVetoedException.cs + + + Extensions\ExpressionExtensions.cs + + + Data\Reference.cs + + + Extensions\StreamExtension.cs + + + Data\FieldIndexing.cs + + + Data\FieldStorage.cs + + + Data\IndexDefinition.cs + + + Linq\NumberUtil.cs + + + Data\SortOptions.cs + + + Data\JsonDocument.cs + + + Json\JsonEnumConverter.cs + + + Extensions\JsonExtensions.cs + + + Json\PatchCommandType.cs + + + Data\PatchRequest.cs + + + Data\PatchResult.cs + + + Data\PutResult.cs + + + Data\TransactionInformation.cs + + + + + + RavenDB.snk + + + +>>>>>>> 4547b78a1c464783091667d20936046eaf013294 + + \ No newline at end of file diff --git a/Raven.Client.Lightweight/Raven.Client.Lightweight.csproj.orig b/Raven.Client.Lightweight/Raven.Client.Lightweight.csproj.orig new file mode 100644 index 000000000000..10bb2d5bdcc9 --- /dev/null +++ b/Raven.Client.Lightweight/Raven.Client.Lightweight.csproj.orig @@ -0,0 +1,891 @@ +<<<<<<< HEAD + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {4E087ECB-E7CA-4891-AC3C-3C76702715B6} + Library + Properties + Raven.Client + Raven.Client.Lightweight + v4.0 + 512 + Client + + + true + full + false + bin\Debug\ + TRACE;DEBUG;CLIENT + prompt + 4 + true + bin\Debug\Raven.Client.Lightweight.XML + + + pdbonly + true + bin\Release\ + TRACE;CLIENT + prompt + 4 + + + true + + + ..\Raven.Database\RavenDB.snk + + + + + ..\SharedLibs\Newtonsoft.Json.dll + + + + + + + + + + + + + + Data\ReplicationDestination.cs + + + Data\ReplicationDocument.cs + + + Client\Async\AsyncServerClient.cs + + + Client\Async\IAsyncDatabaseCommands.cs + + + Client\Async\WrapperAsyncData.cs + + + Client\HttpJsonRequest.cs + + + Client\IDatabaseCommands.cs + + + Client\JsonExtensions.cs + + + Client\JsonLuceneDateTimeConverter.cs + + + Client\RavenQuery.cs + + + Client\RavenTransactionAccessor.cs + + + Client\ReplicationInformer.cs + + + Client\SerializationHelper.cs + + + Client\ServerClient.cs + + + Client\WebRequestEventArgs.cs + + + Client\WebResponseExtensions.cs + + + Document\Async\AsyncDocumentSession.cs + + + Document\Async\SyncronousLoadResult.cs + + + Document\DefaultRavenContractResolver.cs + + + Document\DocumentConvention.cs + + + Document\DocumentQuery.cs + + + Document\DocumentSession.cs + + + Document\DocumentStore.cs + + + Document\HiLoKeyGenerator.cs + + + Document\ILoaderWithInclude.cs + + + Document\InMemoryDocumentSessionOperations.cs + + + Document\MultiLoaderWithInclude.cs + + + Document\MultiTypeHiLoKeyGenerator.cs + + + Document\PromotableRavenClientEnlistment.cs + + + Document\RavenClientEnlistment.cs + + + Document\ReflectionUtil.cs + + + Document\ShardedDocumentQuery.cs + + + Document\SpatialDocumentQuery.cs + + + EntityStored.cs + + + EntityToDocument.cs + + + Exceptions\ConflictException.cs + + + Exceptions\NonAuthoritiveInformationException.cs + + + Exceptions\NonUniqueObjectException.cs + + + Exceptions\ReadVetoException.cs + + + IAdvancedDocumentSessionOperations.cs + + + IAsyncAdvancedSessionOperations.cs + + + IAsyncDocumentSession.cs + + + IDocumentDeleteListener.cs + + + IDocumentQuery.cs + + + IDocumentQueryCustomization.cs + + + IDocumentSession.cs + + + IDocumentStore.cs + + + IDocumentStoreListener.cs + + + Indexes\AbstractIndexCreationTask.cs + + + Indexes\ExpressionOperatorPrecedence.cs + + + Indexes\ExpressionOperatorPrecedenceExtension.cs + + + Indexes\ExpressionStringBuilder.cs + + + Indexes\IClientSideDatabase.cs + + + Indexes\IndexCreation.cs + + + Indexes\IndexDefinition.cs + + + ISyncAdvancedSessionOperation.cs + + + ITransactionalDocumentSession.cs + + + Linq\DateTools.cs + + + Linq\DynamicQueryProviderProcessor.cs + + + Linq\DynamicRavenQueryable.cs + + + Linq\DynamicRavenQueryProvider.cs + + + Linq\ExpressionMemberInfo.cs + + + Linq\IRavenQueryable.cs + + + Linq\IRavenQueryProvider.cs + + + Linq\RavenQueryable.cs + + + Linq\RavenQueryProvider.cs + + + Linq\RavenQueryProviderProcessor.cs + + + Linq\RavenQueryStatistics.cs + + + Linq\TypeSystem.cs + + + RavenExtensions.cs + + + Shard\ShardedDocumentSession.cs + + + Shard\ShardedDocumentStore.cs + + + Shard\Shards.cs + + + Shard\ShardStrategy\IShardStrategy.cs + + + Shard\ShardStrategy\ShardAccess\IShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardAccess\ParallelExtensions.cs + + + Shard\ShardStrategy\ShardAccess\ParallelShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardAccess\SequentialShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardResolution\AllShardsResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\IShardResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\ShardResolutionStrategyData.cs + + + Shard\ShardStrategy\ShardSelection\IShardSelectionStrategy.cs + + + Shard\ShardStrategy\ShardStrategy.cs + + + StoredEntityEventArgs.cs + + + Util\Inflector.cs + + + Data\BatchResult.cs + + + Data\Attachment.cs + + + Commands\DeleteCommandData.cs + + + Data\DisposableAction.cs + + + Commands\ICommandData.cs + + + Data\IndexFailureInformation.cs + + + Data\IndexQuery.cs + + + Data\MetadataExtensions.cs + + + Data\MultiLoadResult.cs + + + Commands\PatchCommandData.cs + + + Commands\PutCommandData.cs + + + Data\QueryResult.cs + + + Data\SortedField.cs + + + Data\SpatialIndexQuery.cs + + + Exceptions\BadRequestException.cs + + + Exceptions\ConcurrencyException.cs + + + Exceptions\IndexDisabledException.cs + + + Indexes\IndexDoesNotExistsException.cs + + + Exceptions\OperationVetoedException.cs + + + Extensions\ExpressionExtensions.cs + + + Data\Reference.cs + + + Extensions\StreamExtension.cs + + + Data\FieldIndexing.cs + + + Data\FieldStorage.cs + + + Data\IndexDefinition.cs + + + Linq\NumberUtil.cs + + + Data\SortOptions.cs + + + Data\JsonDocument.cs + + + Util\DynamicUtil.cs + + + Json\JsonDynamicConverter.cs + + + Json\JsonEnumConverter.cs + + + Extensions\JsonExtensions.cs + + + Json\PatchCommandType.cs + + + Data\PatchRequest.cs + + + Linq\DynamicJsonObject.cs + + + Data\PatchResult.cs + + + Data\PutResult.cs + + + Data\TransactionInformation.cs + + + + + + RavenDB.snk + + + +======= + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {4E087ECB-E7CA-4891-AC3C-3C76702715B6} + Library + Properties + Raven.Client + Raven.Client.Lightweight + v4.0 + 512 + Client + + + true + full + false + bin\Debug\ + TRACE;DEBUG;CLIENT + prompt + 4 + true + bin\Debug\Raven.Client.Lightweight.XML + + + pdbonly + true + bin\Release\ + TRACE;CLIENT + prompt + 4 + + + true + + + ..\Raven.Database\RavenDB.snk + + + + + ..\SharedLibs\Newtonsoft.Json.dll + + + + + + + + + + + + + + Data\ReplicationDestination.cs + + + Data\ReplicationDocument.cs + + + Client\Async\AsyncServerClient.cs + + + Client\Async\IAsyncDatabaseCommands.cs + + + Client\Async\WrapperAsyncData.cs + + + Client\HttpJsonRequest.cs + + + Client\IDatabaseCommands.cs + + + Client\JsonExtensions.cs + + + Client\JsonLuceneDateTimeConverter.cs + + + Client\RavenQuery.cs + + + Client\RavenTransactionAccessor.cs + + + Client\ReplicationInformer.cs + + + Client\SerializationHelper.cs + + + Client\ServerClient.cs + + + Client\WebRequestEventArgs.cs + + + Client\WebResponseExtensions.cs + + + Converters\GuidConverter.cs + + + Converters\Int32Converter.cs + + + Converters\Int64Converter.cs + + + Converters\ITypeConverter.cs + + + Document\Async\AsyncDocumentSession.cs + + + Document\Async\SyncronousLoadResult.cs + + + Document\DefaultRavenContractResolver.cs + + + Document\DocumentConvention.cs + + + Document\DocumentQuery.cs + + + Document\DocumentSession.cs + + + Document\DocumentStore.cs + + + Document\HiLoKeyGenerator.cs + + + Document\ILoaderWithInclude.cs + + + Document\InMemoryDocumentSessionOperations.cs + + + Document\MultiLoaderWithInclude.cs + + + Document\MultiTypeHiLoKeyGenerator.cs + + + Document\PromotableRavenClientEnlistment.cs + + + Document\RavenClientEnlistment.cs + + + Document\ReflectionUtil.cs + + + Document\ShardedDocumentQuery.cs + + + Document\SpatialDocumentQuery.cs + + + EntityStored.cs + + + EntityToDocument.cs + + + Exceptions\ConflictException.cs + + + Exceptions\NonAuthoritiveInformationException.cs + + + Exceptions\NonUniqueObjectException.cs + + + Exceptions\ReadVetoException.cs + + + IAdvancedDocumentSessionOperations.cs + + + IAsyncAdvancedSessionOperations.cs + + + IAsyncDocumentSession.cs + + + IDocumentDeleteListener.cs + + + IDocumentQuery.cs + + + IDocumentQueryCustomization.cs + + + IDocumentSession.cs + + + IDocumentStore.cs + + + IDocumentStoreListener.cs + + + Indexes\AbstractIndexCreationTask.cs + + + Indexes\ExpressionOperatorPrecedence.cs + + + Indexes\ExpressionOperatorPrecedenceExtension.cs + + + Indexes\ExpressionStringBuilder.cs + + + Indexes\IClientSideDatabase.cs + + + Indexes\IndexCreation.cs + + + Indexes\IndexDefinition.cs + + + ISyncAdvancedSessionOperation.cs + + + ITransactionalDocumentSession.cs + + + Linq\DateTools.cs + + + Linq\DynamicQueryProviderProcessor.cs + + + Linq\DynamicRavenQueryable.cs + + + Linq\DynamicRavenQueryProvider.cs + + + Linq\ExpressionMemberInfo.cs + + + Linq\IRavenQueryable.cs + + + Linq\IRavenQueryProvider.cs + + + Linq\RavenQueryable.cs + + + Linq\RavenQueryProvider.cs + + + Linq\RavenQueryProviderProcessor.cs + + + Linq\RavenQueryStatistics.cs + + + Linq\TypeSystem.cs + + + RavenExtensions.cs + + + Shard\ShardedDocumentSession.cs + + + Shard\ShardedDocumentStore.cs + + + Shard\Shards.cs + + + Shard\ShardStrategy\IShardStrategy.cs + + + Shard\ShardStrategy\ShardAccess\IShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardAccess\ParallelExtensions.cs + + + Shard\ShardStrategy\ShardAccess\ParallelShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardAccess\SequentialShardAccessStrategy.cs + + + Shard\ShardStrategy\ShardResolution\AllShardsResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\IShardResolutionStrategy.cs + + + Shard\ShardStrategy\ShardResolution\ShardResolutionStrategyData.cs + + + Shard\ShardStrategy\ShardSelection\IShardSelectionStrategy.cs + + + Shard\ShardStrategy\ShardStrategy.cs + + + StoredEntityEventArgs.cs + + + Util\Inflector.cs + + + Data\BatchResult.cs + + + Data\Attachment.cs + + + Commands\DeleteCommandData.cs + + + Data\DisposableAction.cs + + + Commands\ICommandData.cs + + + Data\IndexFailureInformation.cs + + + Data\IndexQuery.cs + + + Data\MetadataExtensions.cs + + + Data\MultiLoadResult.cs + + + Commands\PatchCommandData.cs + + + Commands\PutCommandData.cs + + + Data\QueryResult.cs + + + Data\SortedField.cs + + + Data\SpatialIndexQuery.cs + + + Exceptions\BadRequestException.cs + + + Exceptions\ConcurrencyException.cs + + + Exceptions\IndexDisabledException.cs + + + Indexes\IndexDoesNotExistsException.cs + + + Exceptions\OperationVetoedException.cs + + + Extensions\ExpressionExtensions.cs + + + Data\Reference.cs + + + Extensions\StreamExtension.cs + + + Data\FieldIndexing.cs + + + Data\FieldStorage.cs + + + Data\IndexDefinition.cs + + + Linq\NumberUtil.cs + + + Data\SortOptions.cs + + + Data\JsonDocument.cs + + + Util\DynamicUtil.cs + + + Json\JsonDynamicConverter.cs + + + Json\JsonEnumConverter.cs + + + Extensions\JsonExtensions.cs + + + Json\PatchCommandType.cs + + + Data\PatchRequest.cs + + + Linq\DynamicJsonObject.cs + + + Data\PatchResult.cs + + + Data\PutResult.cs + + + Data\TransactionInformation.cs + + + + + + RavenDB.snk + + + +>>>>>>> 4547b78a1c464783091667d20936046eaf013294 + + \ No newline at end of file diff --git a/Raven.Client.Tests/Bugs/CanUseNonStringsForId.cs b/Raven.Client.Tests/Bugs/CanUseNonStringsForId.cs index 82bce6d1ade0..8ec1745df5d6 100644 --- a/Raven.Client.Tests/Bugs/CanUseNonStringsForId.cs +++ b/Raven.Client.Tests/Bugs/CanUseNonStringsForId.cs @@ -1,69 +1,69 @@ -using System; -using Xunit; - -namespace Raven.Client.Tests.Bugs -{ - public class CanUseNonStringsForId : LocalClientTest - { - [Fact] - public void CanStoreAndLoadEntityWithIntKey() - { - using(var store = NewDocumentStore()) - { - using(var s = store.OpenSession()) - { - s.Store(new UserInt32 - { - Id = 3, - Name = "Ayende" - }); - s.SaveChanges(); - } - - using(var s = store.OpenSession()) - { - var userInt32 = s.Load("3"); - Assert.Equal(3, userInt32.Id); - Assert.Equal("Ayende", userInt32.Name); - } - } - } - - [Fact] - public void CanStoreAndLoadEntityWithGuidKey() - { - var id = Guid.NewGuid(); - using (var store = NewDocumentStore()) - { - using (var s = store.OpenSession()) - { - s.Store(new UserGuid() - { - Id = id, - Name = "Ayende" - }); - s.SaveChanges(); - } - - using (var s = store.OpenSession()) - { - var user = s.Load(id.ToString()); - Assert.Equal(id, user.Id); - Assert.Equal("Ayende", user.Name); - } - } - } - } - - public class UserGuid - { - public Guid Id { get; set; } - public string Name { get; set; } - } - - public class UserInt32 - { - public int Id { get; set; } - public string Name { get; set; } - } +using System; +using Xunit; + +namespace Raven.Client.Tests.Bugs +{ + public class CanUseNonStringsForId : LocalClientTest + { + [Fact] + public void CanStoreAndLoadEntityWithIntKey() + { + using(var store = NewDocumentStore()) + { + using(var s = store.OpenSession()) + { + s.Store(new UserInt32 + { + Id = 3, + Name = "Ayende" + }); + s.SaveChanges(); + } + + using(var s = store.OpenSession()) + { + var userInt32 = s.Load("3"); + Assert.Equal(3, userInt32.Id); + Assert.Equal("Ayende", userInt32.Name); + } + } + } + + [Fact] + public void CanStoreAndLoadEntityWithGuidKey() + { + var id = Guid.NewGuid(); + using (var store = NewDocumentStore()) + { + using (var s = store.OpenSession()) + { + s.Store(new UserGuid() + { + Id = id, + Name = "Ayende" + }); + s.SaveChanges(); + } + + using (var s = store.OpenSession()) + { + var user = s.Load(id.ToString()); + Assert.Equal(id, user.Id); + Assert.Equal("Ayende", user.Name); + } + } + } + } + + public class UserGuid + { + public Guid Id { get; set; } + public string Name { get; set; } + } + + public class UserInt32 + { + public int Id { get; set; } + public string Name { get; set; } + } } \ No newline at end of file diff --git a/Raven.Client.Tests/Bugs/ProjectionFromDynamicQuery.cs b/Raven.Client.Tests/Bugs/ProjectionFromDynamicQuery.cs index 45904c1e149e..3d25b0a3448f 100644 --- a/Raven.Client.Tests/Bugs/ProjectionFromDynamicQuery.cs +++ b/Raven.Client.Tests/Bugs/ProjectionFromDynamicQuery.cs @@ -1,162 +1,162 @@ -using Newtonsoft.Json.Linq; -using Xunit; -using System.Linq; - -namespace Raven.Client.Tests.Bugs -{ - public class ProjectionFromDynamicQuery : LocalClientTest - { - [Fact] - public void ProjectNameFromDynamicQueryUsingLucene() - { - using(var documentStore = NewDocumentStore()) - { - using(var s = documentStore.OpenSession()) - { - s.Store(new User{Name = "Ayende", Email = "Ayende@ayende.com"}); - s.SaveChanges(); - } - - using (var s = documentStore.OpenSession()) - { - var result = s.Advanced.DynamicLuceneQuery() - .WhereEquals("Name", "Ayende", isAnalyzed: true) - .SelectFields("Email") - .First(); - - Assert.Equal("Ayende@ayende.com", result.Value("Email")); - } - } - } - - [Fact] - public void ProjectNameFromDynamicQueryUsingLinq() - { - using (var documentStore = NewDocumentStore()) - { - using (var s = documentStore.OpenSession()) - { - s.Store(new User { Name = "Ayende", Email = "Ayende@ayende.com" }); - s.SaveChanges(); - } - - using (var s = documentStore.OpenSession()) - { - var result = from user in s.Query() - where user.Name == "Ayende" - select new { user.Email }; - - Assert.Equal("Ayende@ayende.com", result.First().Email); - } - } - } - - [Fact] - public void ProjectNameFromDynamicQueryUsingLuceneUsingNestedObject() - { - using (var documentStore = NewDocumentStore()) - { - using (var s = documentStore.OpenSession()) - { - s.Store(new Person() - { - Name = "Ayende", - BillingAddress = new Address - { - City = "Bologna" - } - }); - s.SaveChanges(); - } - - using (var s = documentStore.OpenSession()) - { - var result = s.Advanced.DynamicLuceneQuery() - .WhereEquals("Name", "Ayende", isAnalyzed: true) - .SelectFields("BillingAddress") - .First(); - - Assert.Equal("Bologna", result.Value("BillingAddress").Value("City")); - } - } - } - - [Fact] - public void ProjectNameFromDynamicQueryUsingLuceneUsingNestedProperty() - { - using (var documentStore = NewDocumentStore()) - { - using (var s = documentStore.OpenSession()) - { - s.Store(new Person() - { - Name = "Ayende", - BillingAddress = new Address - { - City = "Bologna" - } - }); - s.SaveChanges(); - } - - using (var s = documentStore.OpenSession()) - { - var result = s.Advanced.DynamicLuceneQuery() - .WhereEquals("Name", "Ayende", isAnalyzed: true) - .SelectFields("BillingAddress.City") - .First(); - - Assert.Equal("Bologna", result.Value("BillingAddress.City")); - } - } - - } - - [Fact] - public void ProjectNameFromDynamicQueryUsingLuceneUsingNestedArray() - { - using (var documentStore = NewDocumentStore()) - { - using (var s = documentStore.OpenSession()) - { - s.Store(new Person() - { - Name = "Ayende", - BillingAddress = new Address - { - City = "Bologna" - }, - Addresses = new Address[] - { - new Address {City = "Old York"}, - } - }); - s.SaveChanges(); - } - - using (var s = documentStore.OpenSession()) - { - var result = s.Advanced.DynamicLuceneQuery() - .WhereEquals("Name", "Ayende", isAnalyzed: true) - .SelectFields("Addresses[0].City") - .First(); - - Assert.Equal("Old York", result.Value("Addresses[0].City")); - } - } - } - - public class Person - { - public string Name { get; set; } - public Address BillingAddress { get; set; } - - public Address[] Addresses { get; set; } - } - - public class Address - { - public string City { get; set; } - } - } -} +using Newtonsoft.Json.Linq; +using Xunit; +using System.Linq; + +namespace Raven.Client.Tests.Bugs +{ + public class ProjectionFromDynamicQuery : LocalClientTest + { + [Fact] + public void ProjectNameFromDynamicQueryUsingLucene() + { + using(var documentStore = NewDocumentStore()) + { + using(var s = documentStore.OpenSession()) + { + s.Store(new User{Name = "Ayende", Email = "Ayende@ayende.com"}); + s.SaveChanges(); + } + + using (var s = documentStore.OpenSession()) + { + var result = s.Advanced.DynamicLuceneQuery() + .WhereEquals("Name", "Ayende", isAnalyzed: true) + .SelectFields("Email") + .First(); + + Assert.Equal("Ayende@ayende.com", result.Value("Email")); + } + } + } + + [Fact] + public void ProjectNameFromDynamicQueryUsingLinq() + { + using (var documentStore = NewDocumentStore()) + { + using (var s = documentStore.OpenSession()) + { + s.Store(new User { Name = "Ayende", Email = "Ayende@ayende.com" }); + s.SaveChanges(); + } + + using (var s = documentStore.OpenSession()) + { + var result = from user in s.Query() + where user.Name == "Ayende" + select new { user.Email }; + + Assert.Equal("Ayende@ayende.com", result.First().Email); + } + } + } + + [Fact] + public void ProjectNameFromDynamicQueryUsingLuceneUsingNestedObject() + { + using (var documentStore = NewDocumentStore()) + { + using (var s = documentStore.OpenSession()) + { + s.Store(new Person() + { + Name = "Ayende", + BillingAddress = new Address + { + City = "Bologna" + } + }); + s.SaveChanges(); + } + + using (var s = documentStore.OpenSession()) + { + var result = s.Advanced.DynamicLuceneQuery() + .WhereEquals("Name", "Ayende", isAnalyzed: true) + .SelectFields("BillingAddress") + .First(); + + Assert.Equal("Bologna", result.Value("BillingAddress").Value("City")); + } + } + } + + [Fact] + public void ProjectNameFromDynamicQueryUsingLuceneUsingNestedProperty() + { + using (var documentStore = NewDocumentStore()) + { + using (var s = documentStore.OpenSession()) + { + s.Store(new Person() + { + Name = "Ayende", + BillingAddress = new Address + { + City = "Bologna" + } + }); + s.SaveChanges(); + } + + using (var s = documentStore.OpenSession()) + { + var result = s.Advanced.DynamicLuceneQuery() + .WhereEquals("Name", "Ayende", isAnalyzed: true) + .SelectFields("BillingAddress.City") + .First(); + + Assert.Equal("Bologna", result.Value("BillingAddress.City")); + } + } + + } + + [Fact] + public void ProjectNameFromDynamicQueryUsingLuceneUsingNestedArray() + { + using (var documentStore = NewDocumentStore()) + { + using (var s = documentStore.OpenSession()) + { + s.Store(new Person() + { + Name = "Ayende", + BillingAddress = new Address + { + City = "Bologna" + }, + Addresses = new Address[] + { + new Address {City = "Old York"}, + } + }); + s.SaveChanges(); + } + + using (var s = documentStore.OpenSession()) + { + var result = s.Advanced.DynamicLuceneQuery() + .WhereEquals("Name", "Ayende", isAnalyzed: true) + .SelectFields("Addresses[0].City") + .First(); + + Assert.Equal("Old York", result.Value("Addresses[0].City")); + } + } + } + + public class Person + { + public string Name { get; set; } + public Address BillingAddress { get; set; } + + public Address[] Addresses { get; set; } + } + + public class Address + { + public string City { get; set; } + } + } +} diff --git a/Raven.Client.Tests/Raven.Client.Tests.csproj.orig b/Raven.Client.Tests/Raven.Client.Tests.csproj.orig new file mode 100644 index 000000000000..81c535674009 --- /dev/null +++ b/Raven.Client.Tests/Raven.Client.Tests.csproj.orig @@ -0,0 +1,504 @@ +<<<<<<< HEAD + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {36B31D69-508B-4594-8F8E-85774BAA7D3F} + Library + Properties + Raven.Client.Tests + Raven.Client.Tests + v4.0 + 512 + + + 3.5 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + AnyCPU + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + AnyCPU + + + true + + + ..\Raven.Database\RavenDB.snk + + + + False + ..\SharedLibs\log4net.dll + + + + + False + ..\SharedLibs\Newtonsoft.Json.dll + + + ..\SharedLibs\Rhino.Mocks.dll + + + + + 3.5 + + + + + 3.5 + + + 3.5 + + + + + False + ..\SharedLibs\xunit.dll + + + + + Spatial\SpatialIndexTestHelper.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {9F92FD36-60B6-4655-B8C6-00125B46AB6A} + Raven.Client + + + {212823CD-25E1-41AC-92D1-D6DF4D53FC85} + Raven.Database + + + {3B90EB20-AEA3-4972-8219-936F1A62768C} + Raven.Server + + + {212823CD-25E1-41AC-92D1-D6DF4D53FC85} + Raven.Database + + + {9DEE8674-D0CD-430D-BD9B-6CD95F3CAB22} + Raven.Storage.Esent + + + {DA99A419-E137-40DB-9495-0C363B479D4B} + Raven.Storage.Managed + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + RavenDB.snk + + + + +======= + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {36B31D69-508B-4594-8F8E-85774BAA7D3F} + Library + Properties + Raven.Client.Tests + Raven.Client.Tests + v4.0 + 512 + + + 3.5 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + AnyCPU + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + AnyCPU + + + true + + + ..\Raven.Database\RavenDB.snk + + + + False + ..\SharedLibs\log4net.dll + + + + + False + ..\SharedLibs\Newtonsoft.Json.dll + + + ..\SharedLibs\Rhino.Mocks.dll + + + + + 3.5 + + + + + 3.5 + + + 3.5 + + + + + False + ..\SharedLibs\xunit.dll + + + + + Spatial\SpatialIndexTestHelper.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {9F92FD36-60B6-4655-B8C6-00125B46AB6A} + Raven.Client + + + {212823CD-25E1-41AC-92D1-D6DF4D53FC85} + Raven.Database + + + {3B90EB20-AEA3-4972-8219-936F1A62768C} + Raven.Server + + + {212823CD-25E1-41AC-92D1-D6DF4D53FC85} + Raven.Database + + + {9DEE8674-D0CD-430D-BD9B-6CD95F3CAB22} + Raven.Storage.Esent + + + {DA99A419-E137-40DB-9495-0C363B479D4B} + Raven.Storage.Managed + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + RavenDB.snk + + + + +>>>>>>> 4547b78a1c464783091667d20936046eaf013294 + + \ No newline at end of file diff --git a/Raven.Client/Converters/GuidConverter.cs b/Raven.Client/Converters/GuidConverter.cs index 5246226ae5c9..c2588b6a8359 100644 --- a/Raven.Client/Converters/GuidConverter.cs +++ b/Raven.Client/Converters/GuidConverter.cs @@ -1,48 +1,48 @@ -using System; - -namespace Raven.Client.Converters -{ - /// - /// Covnert strings from / to guids - /// - public class GuidConverter : ITypeConverter - { - /// - /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context. - /// - /// - /// true if this converter can perform the conversion; otherwise, false. - /// - /// A that represents the type you want to convert from. - /// - public bool CanConvertFrom(Type sourceType) - { - return sourceType == typeof(Guid); - } - - /// - /// Converts the given object to the type of this converter, using the specified context and culture information. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - /// The conversion cannot be performed. - public string ConvertFrom(object value) - { - return value.ToString(); - } - - /// - /// Converts the given value object to the specified type, using the specified context and culture information. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - public object ConvertTo(string value) - { - return new Guid(value.ToString()); - } - } +using System; + +namespace Raven.Client.Converters +{ + /// + /// Covnert strings from / to guids + /// + public class GuidConverter : ITypeConverter + { + /// + /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context. + /// + /// + /// true if this converter can perform the conversion; otherwise, false. + /// + /// A that represents the type you want to convert from. + /// + public bool CanConvertFrom(Type sourceType) + { + return sourceType == typeof(Guid); + } + + /// + /// Converts the given object to the type of this converter, using the specified context and culture information. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + /// The conversion cannot be performed. + public string ConvertFrom(object value) + { + return value.ToString(); + } + + /// + /// Converts the given value object to the specified type, using the specified context and culture information. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + public object ConvertTo(string value) + { + return new Guid(value.ToString()); + } + } } \ No newline at end of file diff --git a/Raven.Client/Converters/ITypeConverter.cs b/Raven.Client/Converters/ITypeConverter.cs index b209c612c149..df7f1edb571d 100644 --- a/Raven.Client/Converters/ITypeConverter.cs +++ b/Raven.Client/Converters/ITypeConverter.cs @@ -1,40 +1,40 @@ -using System; - -namespace Raven.Client.Converters -{ - /// - /// Interface for performing type conversions. - /// We couldn't use te builtin TypeConverter because it is too big an interface for people to build on. - /// - public interface ITypeConverter - { - /// - /// Returns whether this converter can convert an object of the given type to the type of this converter. - /// - /// - /// true if this converter can perform the conversion; otherwise, false. - /// - /// A that represents the type you want to convert from. - /// - bool CanConvertFrom(Type sourceType); - - /// - /// Converts the given object to the type of this converter. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - /// The conversion cannot be performed. - string ConvertFrom(object value); - - /// - /// Converts the given value object to the specified type, using the specified context and culture information. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - object ConvertTo(string value); - } +using System; + +namespace Raven.Client.Converters +{ + /// + /// Interface for performing type conversions. + /// We couldn't use te builtin TypeConverter because it is too big an interface for people to build on. + /// + public interface ITypeConverter + { + /// + /// Returns whether this converter can convert an object of the given type to the type of this converter. + /// + /// + /// true if this converter can perform the conversion; otherwise, false. + /// + /// A that represents the type you want to convert from. + /// + bool CanConvertFrom(Type sourceType); + + /// + /// Converts the given object to the type of this converter. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + /// The conversion cannot be performed. + string ConvertFrom(object value); + + /// + /// Converts the given value object to the specified type, using the specified context and culture information. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + object ConvertTo(string value); + } } \ No newline at end of file diff --git a/Raven.Client/Converters/Int32Converter.cs b/Raven.Client/Converters/Int32Converter.cs index 121d5c97cb75..3f1969849872 100644 --- a/Raven.Client/Converters/Int32Converter.cs +++ b/Raven.Client/Converters/Int32Converter.cs @@ -1,48 +1,48 @@ -using System; - -namespace Raven.Client.Converters -{ - /// - /// Covnert strings from / to int32 - /// - public class Int32Converter : ITypeConverter - { - /// - /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context. - /// - /// - /// true if this converter can perform the conversion; otherwise, false. - /// - /// A that represents the type you want to convert from. - /// - public bool CanConvertFrom(Type sourceType) - { - return sourceType == typeof (int); - } - - /// - /// Converts the given object to the type of this converter, using the specified context and culture information. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - /// The conversion cannot be performed. - public string ConvertFrom(object value) - { - return value.ToString(); - } - - /// - /// Converts the given value object to the specified type, using the specified context and culture information. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - public object ConvertTo(string value) - { - return int.Parse(value.ToString()); - } - } +using System; + +namespace Raven.Client.Converters +{ + /// + /// Covnert strings from / to int32 + /// + public class Int32Converter : ITypeConverter + { + /// + /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context. + /// + /// + /// true if this converter can perform the conversion; otherwise, false. + /// + /// A that represents the type you want to convert from. + /// + public bool CanConvertFrom(Type sourceType) + { + return sourceType == typeof (int); + } + + /// + /// Converts the given object to the type of this converter, using the specified context and culture information. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + /// The conversion cannot be performed. + public string ConvertFrom(object value) + { + return value.ToString(); + } + + /// + /// Converts the given value object to the specified type, using the specified context and culture information. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + public object ConvertTo(string value) + { + return int.Parse(value.ToString()); + } + } } \ No newline at end of file diff --git a/Raven.Client/Converters/Int64Converter.cs b/Raven.Client/Converters/Int64Converter.cs index 3829aad8e359..35f93aeca63e 100644 --- a/Raven.Client/Converters/Int64Converter.cs +++ b/Raven.Client/Converters/Int64Converter.cs @@ -1,48 +1,48 @@ -using System; - -namespace Raven.Client.Converters -{ - /// - /// Covnert strings from / to int64 - /// - public class Int64Converter : ITypeConverter - { - /// - /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context. - /// - /// - /// true if this converter can perform the conversion; otherwise, false. - /// - /// A that represents the type you want to convert from. - /// - public bool CanConvertFrom(Type sourceType) - { - return sourceType == typeof(long); - } - - /// - /// Converts the given object to the type of this converter, using the specified context and culture information. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - /// The conversion cannot be performed. - public string ConvertFrom(object value) - { - return value.ToString(); - } - - /// - /// Converts the given value object to the specified type, using the specified context and culture information. - /// - /// - /// An that represents the converted value. - /// - /// The to convert. - public object ConvertTo(string value) - { - return long.Parse(value.ToString()); - } - } +using System; + +namespace Raven.Client.Converters +{ + /// + /// Covnert strings from / to int64 + /// + public class Int64Converter : ITypeConverter + { + /// + /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context. + /// + /// + /// true if this converter can perform the conversion; otherwise, false. + /// + /// A that represents the type you want to convert from. + /// + public bool CanConvertFrom(Type sourceType) + { + return sourceType == typeof(long); + } + + /// + /// Converts the given object to the type of this converter, using the specified context and culture information. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + /// The conversion cannot be performed. + public string ConvertFrom(object value) + { + return value.ToString(); + } + + /// + /// Converts the given value object to the specified type, using the specified context and culture information. + /// + /// + /// An that represents the converted value. + /// + /// The to convert. + public object ConvertTo(string value) + { + return long.Parse(value.ToString()); + } + } } \ No newline at end of file diff --git a/Raven.Client/Document/DocumentConvention.cs b/Raven.Client/Document/DocumentConvention.cs index a0347b427c02..63ead28ec1d9 100644 --- a/Raven.Client/Document/DocumentConvention.cs +++ b/Raven.Client/Document/DocumentConvention.cs @@ -1,181 +1,181 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; -using System.Runtime.Serialization.Formatters; -using System.Text; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using Raven.Client.Converters; -using Raven.Client.Util; -using System.Linq; -using Raven.Database.Json; - -namespace Raven.Client.Document -{ - /// - /// The set of conventions used by the which allow the users to customize - /// the way the Raven client API behaves - /// - public class DocumentConvention - { - /// - /// Initializes a new instance of the class. - /// - public DocumentConvention() - { - IdentityTypeConvertors = new List - { - new Converters.GuidConverter(), - new Converters.Int32Converter(), - new Converters.Int64Converter(), - }; - FindIdentityProperty = q => q.Name == "Id"; - FindTypeTagName = t => DefaultTypeTagName(t); - IdentityPartsSeparator = "/"; - JsonContractResolver = new DefaultRavenContractResolver(shareCache: true) - { - DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance - }; - MaxNumberOfRequestsPerSession = 30; - CustomizeJsonSerializer = serializer => { }; - } - - /// - /// Register an action to customize the json serializer used by the - /// - public Action CustomizeJsonSerializer { get; set; } - - /// - /// A list of type convertors that can be used to translate the document key (string) - /// to whatever type it is that is used on the entity, if the type isn't already a string - /// - public List IdentityTypeConvertors { get; set; } - - /// - /// Gets or sets the identity parts separator used by the hilo generators - /// - /// The identity parts separator. - public string IdentityPartsSeparator { get; set; } - - /// - /// Gets or sets the default max number of requests per session. - /// - /// The max number of requests per session. - public int MaxNumberOfRequestsPerSession { get; set; } - - /// - /// Generates the document key using identity. - /// - /// The conventions. - /// The entity. - /// - public static string GenerateDocumentKeyUsingIdentity(DocumentConvention conventions, object entity) - { - return conventions.FindTypeTagName(entity.GetType()).ToLowerInvariant() + "/"; - } - - /// - /// Get the default tag name for the specified type. - /// - /// The t. - /// - public static string DefaultTypeTagName(Type t) - { - if(t.IsGenericType) - { - var name = t.GetGenericTypeDefinition().Name; - if(name.Contains("`")) - { - name = name.Substring(0, name.IndexOf("`")); - } - var sb = new StringBuilder(Inflector.Pluralize(name)); - foreach (var argument in t.GetGenericArguments()) - { - sb.Append("Of") - .Append(DefaultTypeTagName(argument)); - } - return sb.ToString(); - } - return Inflector.Pluralize(t.Name); - } - - /// - /// Gets the name of the type tag. - /// - /// The type. - /// - public string GetTypeTagName(Type type) - { - return FindTypeTagName(type) ?? DefaultTypeTagName(type); - } - - /// - /// Generates the document key. - /// - /// The entity. - /// - public string GenerateDocumentKey(object entity) - { - return DocumentKeyGenerator(entity); - } - - /// - /// Gets the identity property. - /// - /// The type. - /// - public PropertyInfo GetIdentityProperty(Type type) - { - return type.GetProperties().FirstOrDefault(FindIdentityProperty); - } - - /// - /// Gets or sets the json contract resolver. - /// - /// The json contract resolver. - public IContractResolver JsonContractResolver { get; set; } - - /// - /// Gets or sets the function to find the type tag. - /// - /// The name of the find type tag. - public Func FindTypeTagName { get; set; } - /// - /// Gets or sets the function to find the identity property. - /// - /// The find identity property. - public Func FindIdentityProperty { get; set; } - - /// - /// Gets or sets the document key generator. - /// - /// The document key generator. - public Func DocumentKeyGenerator { get; set; } - - /// - /// Creates the serializer. - /// - /// - public JsonSerializer CreateSerializer() - { - var jsonSerializer = new JsonSerializer - { - ContractResolver = JsonContractResolver, - TypeNameHandling = TypeNameHandling.Auto, - TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple, - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - Converters = - { - new JsonEnumConverter(), - new JsonLuceneDateTimeConverter(), -#if !NET_3_5 - new JsonDynamicConverter() -#endif - } - }; - CustomizeJsonSerializer(jsonSerializer); - return jsonSerializer; - } - } -} +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Reflection; +using System.Runtime.Serialization.Formatters; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Raven.Client.Converters; +using Raven.Client.Util; +using System.Linq; +using Raven.Database.Json; + +namespace Raven.Client.Document +{ + /// + /// The set of conventions used by the which allow the users to customize + /// the way the Raven client API behaves + /// + public class DocumentConvention + { + /// + /// Initializes a new instance of the class. + /// + public DocumentConvention() + { + IdentityTypeConvertors = new List + { + new Converters.GuidConverter(), + new Converters.Int32Converter(), + new Converters.Int64Converter(), + }; + FindIdentityProperty = q => q.Name == "Id"; + FindTypeTagName = t => DefaultTypeTagName(t); + IdentityPartsSeparator = "/"; + JsonContractResolver = new DefaultRavenContractResolver(shareCache: true) + { + DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance + }; + MaxNumberOfRequestsPerSession = 30; + CustomizeJsonSerializer = serializer => { }; + } + + /// + /// Register an action to customize the json serializer used by the + /// + public Action CustomizeJsonSerializer { get; set; } + + /// + /// A list of type convertors that can be used to translate the document key (string) + /// to whatever type it is that is used on the entity, if the type isn't already a string + /// + public List IdentityTypeConvertors { get; set; } + + /// + /// Gets or sets the identity parts separator used by the hilo generators + /// + /// The identity parts separator. + public string IdentityPartsSeparator { get; set; } + + /// + /// Gets or sets the default max number of requests per session. + /// + /// The max number of requests per session. + public int MaxNumberOfRequestsPerSession { get; set; } + + /// + /// Generates the document key using identity. + /// + /// The conventions. + /// The entity. + /// + public static string GenerateDocumentKeyUsingIdentity(DocumentConvention conventions, object entity) + { + return conventions.FindTypeTagName(entity.GetType()).ToLowerInvariant() + "/"; + } + + /// + /// Get the default tag name for the specified type. + /// + /// The t. + /// + public static string DefaultTypeTagName(Type t) + { + if(t.IsGenericType) + { + var name = t.GetGenericTypeDefinition().Name; + if(name.Contains("`")) + { + name = name.Substring(0, name.IndexOf("`")); + } + var sb = new StringBuilder(Inflector.Pluralize(name)); + foreach (var argument in t.GetGenericArguments()) + { + sb.Append("Of") + .Append(DefaultTypeTagName(argument)); + } + return sb.ToString(); + } + return Inflector.Pluralize(t.Name); + } + + /// + /// Gets the name of the type tag. + /// + /// The type. + /// + public string GetTypeTagName(Type type) + { + return FindTypeTagName(type) ?? DefaultTypeTagName(type); + } + + /// + /// Generates the document key. + /// + /// The entity. + /// + public string GenerateDocumentKey(object entity) + { + return DocumentKeyGenerator(entity); + } + + /// + /// Gets the identity property. + /// + /// The type. + /// + public PropertyInfo GetIdentityProperty(Type type) + { + return type.GetProperties().FirstOrDefault(FindIdentityProperty); + } + + /// + /// Gets or sets the json contract resolver. + /// + /// The json contract resolver. + public IContractResolver JsonContractResolver { get; set; } + + /// + /// Gets or sets the function to find the type tag. + /// + /// The name of the find type tag. + public Func FindTypeTagName { get; set; } + /// + /// Gets or sets the function to find the identity property. + /// + /// The find identity property. + public Func FindIdentityProperty { get; set; } + + /// + /// Gets or sets the document key generator. + /// + /// The document key generator. + public Func DocumentKeyGenerator { get; set; } + + /// + /// Creates the serializer. + /// + /// + public JsonSerializer CreateSerializer() + { + var jsonSerializer = new JsonSerializer + { + ContractResolver = JsonContractResolver, + TypeNameHandling = TypeNameHandling.Auto, + TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple, + ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, + Converters = + { + new JsonEnumConverter(), + new JsonLuceneDateTimeConverter(), +#if !NET_3_5 + new JsonDynamicConverter() +#endif + } + }; + CustomizeJsonSerializer(jsonSerializer); + return jsonSerializer; + } + } +} diff --git a/Raven.Client/Document/InMemoryDocumentSessionOperations.cs b/Raven.Client/Document/InMemoryDocumentSessionOperations.cs index d9541ec1f2a0..8002335510d7 100644 --- a/Raven.Client/Document/InMemoryDocumentSessionOperations.cs +++ b/Raven.Client/Document/InMemoryDocumentSessionOperations.cs @@ -1,761 +1,761 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Reflection; -using System.Transactions; -using Newtonsoft.Json.Linq; -using Raven.Client.Client; -using Raven.Client.Exceptions; -using Raven.Database; -using Raven.Database.Data; - -#if !NET_3_5 -using System.Dynamic; -using Microsoft.CSharp.RuntimeBinder; -using Raven.Database.Exceptions; -using Raven.Database.Linq; - -#endif - -namespace Raven.Client.Document -{ - /// - /// Abstract implementation for in memory session operations - /// - public abstract class InMemoryDocumentSessionOperations : IDisposable - { - private const string RavenEntityName = "Raven-Entity-Name"; - /// - /// The entities waiting to be deleted - /// - protected readonly HashSet deletedEntities = new HashSet(); - - private bool hasEnlisted; - - /// - /// hold the data required to manage the data for RavenDB's Unit of Work - /// - protected readonly Dictionary entitiesAndMetadata = - new Dictionary(); - - /// - /// Translate between a key and its associated entity - /// - protected readonly Dictionary entitiesByKey = new Dictionary(StringComparer.InvariantCultureIgnoreCase); - /// - /// The document store associated with this session - /// - protected DocumentStore documentStore; - - /// - /// Gets the number of requests for this session - /// - /// - public int NumberOfRequests { get; private set; } - - private readonly IDocumentDeleteListener[] deleteListeners; - private readonly IDocumentStoreListener[] storeListeners; - - /// - /// Initializes a new instance of the class. - /// - /// The document store. - /// The store listeners. - /// The delete listeners. - protected InMemoryDocumentSessionOperations(DocumentStore documentStore, IDocumentStoreListener[] storeListeners, IDocumentDeleteListener[] deleteListeners) - { - this.documentStore = documentStore; - this.deleteListeners = deleteListeners; - this.storeListeners = storeListeners; - ResourceManagerId = documentStore.ResourceManagerId; - UseOptimisticConcurrency = false; - AllowNonAuthoritiveInformation = true; - NonAuthoritiveInformationTimeout = TimeSpan.FromSeconds(15); - MaxNumberOfRequestsPerSession = documentStore.Conventions.MaxNumberOfRequestsPerSession; - } - - /// - /// Gets or sets the timeout to wait for authoritive information if encountered non authoritive document. - /// - /// - public TimeSpan NonAuthoritiveInformationTimeout { get; set; } - - /// - /// Gets the store identifier for this session. - /// The store identifier is the identifier for the particular RavenDB instance. - /// This is mostly useful when using sharding. - /// - /// The store identifier. - public string StoreIdentifier - { - get { return documentStore.Identifier; } - } - - /// - /// Gets the conventions used by this session - /// - /// The conventions. - /// - /// This instance is shared among all sessions, changes to the should be done - /// via the instance, not on a single session. - /// - public DocumentConvention Conventions - { - get { return documentStore.Conventions; } - } - - /// - /// The transaction resource manager identifer - /// - public Guid ResourceManagerId { get; private set; } - - - /// - /// Gets or sets the max number of requests per session. - /// If the rise above , an exception will be thrown. - /// - /// The max number of requests per session. - public int MaxNumberOfRequestsPerSession { get; set; } - - /// - /// Gets or sets a value indicating whether the session should use optimistic concurrency. - /// When set to true, a check is made so that a change made behind the session back would fail - /// and raise . - /// - /// - public bool UseOptimisticConcurrency { get; set; } - /// - /// Occurs when an entity is stored in the session - /// - public virtual event EntityStored Stored; - /// - /// Occurs when an entity is converted to a document and metadata. - /// Changes made to the document / metadata instances passed to this event will be persisted. - /// - public virtual event EntityToDocument OnEntityConverted; - - /// - /// Gets the metadata for the specified entity. - /// - /// - /// The instance. - /// - public JObject GetMetadataFor(T instance) - { - DocumentSession.DocumentMetadata value; - if (entitiesAndMetadata.TryGetValue(instance, out value) == false) - { - string id; - if(TryGetIdFromInstance(instance, out id) -#if !NET_3_5 - || (instance is IDynamicMetaObjectProvider && - TryGetIdFromDynamic(instance, out id) ) -#endif - ) - { - var jsonDocument = GetJsonDocument(id); - entitiesByKey[id] = instance; - entitiesAndMetadata[instance] = value = new DocumentSession.DocumentMetadata - { - ETag = UseOptimisticConcurrency ? (Guid?)Guid.Empty : null, - Key = id, - OriginalMetadata = jsonDocument.Metadata, - Metadata = new JObject(jsonDocument.Metadata), - OriginalValue = new JObject() - }; - } - else - { - throw new InvalidOperationException("Could not find the document key for " + instance); - } - } - return value.Metadata; - } - - /// - /// Get the json document by key from the store - /// - protected abstract JsonDocument GetJsonDocument(string documentKey); - - /// - /// Gets the document id. - /// - /// The instance. - /// - public string GetDocumentId(object instance) - { - DocumentSession.DocumentMetadata value; - if (entitiesAndMetadata.TryGetValue(instance, out value) == false) - return null; - return value.Key; - } - /// - /// Gets a value indicating whether any of the entities tracked by the session has changes. - /// - /// - public bool HasChanges - { - get - { - return deletedEntities.Count > 0 || - entitiesAndMetadata.Where(pair => EntityChanged(pair.Key, pair.Value)).Any(); - } - } - - - /// - /// Determines whether the specified entity has changed. - /// - /// The entity. - /// - /// true if the specified entity has changed; otherwise, false. - /// - public bool HasChanged(object entity) - { - DocumentSession.DocumentMetadata value; - if (entitiesAndMetadata.TryGetValue(entity, out value) == false) - return false; - return EntityChanged(entity, value); - } - - internal void DecrementRequestCount() - { - --NumberOfRequests; - } - - internal void IncrementRequestCount() - { - if (++NumberOfRequests > MaxNumberOfRequestsPerSession) - throw new InvalidOperationException( - string.Format( - @"The maximum number of requests ({0}) allowed for this session has been reached. -Raven limits the number of remote calls that a session is allowed to make as an early warning system. Sessions are expected to be short lived, and -Raven provides facilities like Load(string[] keys) to load multiple documents at once and batch saves. -You can increase the limit by setting DocumentConvention.MaxNumberOfRequestsPerSession or DocumentSession.MaxNumberOfRequestsPerSession, but it is -advisable that you'll look into reducing the number of remote calls first, since that will speed up your application signficantly and result in a -more responsive application. -", - MaxNumberOfRequestsPerSession)); - } - - /// - /// Tracks the entity inside the unit of work - /// - /// - /// The document found. - /// - protected T TrackEntity(JsonDocument documentFound) - { - if (documentFound.Metadata.Property("@etag") == null) - { - documentFound.Metadata.Add("@etag", new JValue(documentFound.Etag.ToString())); - } - if(documentFound.NonAuthoritiveInformation && AllowNonAuthoritiveInformation == false) - { - throw new NonAuthoritiveInformationException("Document " + documentFound.Key + - " returned Non Authoritive Information (probably modified by a transaction in progress) and AllowNonAuthoritiveInformation is set to false"); - } - return TrackEntity(documentFound.Key, documentFound.DataAsJson, documentFound.Metadata); - } - - /// - /// Tracks the entity. - /// - /// - /// The key. - /// The document. - /// The metadata. - /// - public T TrackEntity(string key, JObject document, JObject metadata) - { - object entity; - if (entitiesByKey.TryGetValue(key, out entity) == false) - { - entity = ConvertToEntity(key, document, metadata); - } - else - { - // the local instnace may have been changed, we adhere to the current Unit of Work - // instance, and return that, ignoring anything new. - return (T) entity; - } - var etag = metadata.Value("@etag"); - document.Remove("@metadata"); - if(metadata.Value("Non-Authoritive-Information") && - AllowNonAuthoritiveInformation == false) - { - throw new NonAuthoritiveInformationException("Document " + key + - " returned Non Authoritive Information (probably modified by a transaction in progress) and AllowNonAuthoritiveInformation is set to false"); - } - entitiesAndMetadata[entity] = new DocumentSession.DocumentMetadata - { - OriginalValue = document, - Metadata = metadata, - OriginalMetadata = new JObject(metadata), - ETag = new Guid(etag), - Key = key - }; - entitiesByKey[key] = entity; - return (T) entity; - } - - /// - /// Gets or sets a value indicating whether non authoritive information is allowed. - /// Non authoritive information is document that has been modified by a transaction that hasn't been committed. - /// The server provides the latest committed version, but it is known that attempting to write to a non authoritive document - /// will fail, because it is already modified. - /// If set to false, the session will wait for the transaction to commit to get an - /// authoritive information. If the wait is longer than , is thrown. - /// - /// - /// true if non authoritive information is allowed; otherwise, false. - /// - public bool AllowNonAuthoritiveInformation { get; set; } - - /// - /// Marks the specified entity for deletion. The entity will be deleted when is called. - /// - /// - /// The entity. - public void Delete(T entity) - { - if(entitiesAndMetadata.ContainsKey(entity)==false) - throw new InvalidOperationException(entity+" is not associated with the session, cannot delete unknown entity instance"); - deletedEntities.Add(entity); - } - - /// - /// Converts the json document to an entity. - /// - /// - /// The id. - /// The document found. - /// The metadata. - /// - protected object ConvertToEntity(string id, JObject documentFound, JObject metadata) - { - var entity = default(T); - EnsureNotReadVetoed(metadata); - var documentType = metadata.Value("Raven-Clr-Type"); - if (documentType != null) - { - var type = Type.GetType(documentType); - if (type != null) - entity = (T) documentFound.Deserialize(type, Conventions); - } - if (Equals(entity, default(T))) - { - entity = documentFound.Deserialize(Conventions); -#if !NET_3_5 - var document = entity as JObject; - if (document != null) - { - entity = (T)(object)(new DynamicJsonObject(document)); - } -#endif - } - TrySetIdentity(entity, id); - return entity; - } - - /// - /// Tries to set the identity property - /// - /// - /// The entity. - /// The id. - protected internal void TrySetIdentity(T entity, string id) - { - var identityProperty = documentStore.Conventions.GetIdentityProperty(entity.GetType()); - if (identityProperty != null && identityProperty.CanWrite) - { - if (identityProperty.PropertyType == typeof(string)) - { - identityProperty.SetValue(entity, id, null); - } - else // need converting - { - var converter = Conventions.IdentityTypeConvertors.FirstOrDefault(x=>x.CanConvertFrom(identityProperty.PropertyType)); - if(converter == null) - throw new ArgumentException("Could not convert identity to type " + identityProperty.PropertyType + " because there is not matching type converter registered in the conventions' IdentityTypeConvertors"); - - identityProperty.SetValue(entity, converter.ConvertTo(id), null); - } - } - } - - private static void EnsureNotReadVetoed(JObject metadata) - { - var readVetoAsString = metadata.Value("Raven-Read-Veto"); - if (readVetoAsString == null) - return; - - var readVeto = JObject.Parse(readVetoAsString); - - var s = readVeto.Value("Reason"); - throw new ReadVetoException( - "Document could not be read because of a read veto."+Environment.NewLine + - "The read was vetoed by: " + readVeto.Value("Trigger") + Environment.NewLine + - "Veto reason: " + s - ); - } - - /// - /// Stores the specified entity in the session. The entity will be saved when is called. - /// - /// The entity. - public void Store(object entity) - { - if (null == entity) - throw new ArgumentNullException("entity"); - - string id = null; -#if !NET_3_5 - if (entity is IDynamicMetaObjectProvider) - { - if(TryGetIdFromDynamic(entity,out id) == false) - { - id = Conventions.DocumentKeyGenerator(entity); - - if (id != null) - { - // Store it back into the Id field so the client has access to to it - ((dynamic) entity).Id = id; - } - } - } - else -#endif - { - id = GetOrGenerateDocumentKey(entity); - - TrySetIdentity(entity, id); - } - - // we make the check here even if we just generated the key - // users can override the key generation behavior, and we need - // to detect if they generate duplicates. - if (id != null && - id.EndsWith("/") == false // not a prefix id - && entitiesByKey.ContainsKey(id)) - { - if (ReferenceEquals(entitiesByKey[id], entity)) - return; // calling Store twice on the same reference is a no-op - throw new NonUniqueObjectException("Attempted to associated a different object with id '" + id + "'."); - } - - var tag = documentStore.Conventions.GetTypeTagName(entity.GetType()); - entitiesAndMetadata.Add(entity, new DocumentSession.DocumentMetadata - { - Key = id, - Metadata = new JObject(new JProperty(RavenEntityName, new JValue(tag))), - OriginalMetadata = new JObject(), - ETag = UseOptimisticConcurrency ? (Guid?)Guid.Empty : null, - OriginalValue = new JObject() - }); - if (id != null) - entitiesByKey[id] = entity; - } - - /// - /// Tries to get the identity. - /// - /// The entity. - /// - protected string GetOrGenerateDocumentKey(object entity) - { - string id; - TryGetIdFromInstance(entity, out id); - - if (id == null) - { - // Generate the key up front - id = Conventions.GenerateDocumentKey(entity); - - } - return id; - } - - private bool TryGetIdFromInstance(object entity, out string id) - { - var identityProperty = GetIdentityProperty(entity.GetType()); - if (identityProperty != null) - { - var value = identityProperty.GetValue(entity, null); - id = value as string; - if(id == null && value != null) // need convertion - { - var converter = Conventions.IdentityTypeConvertors.FirstOrDefault(x => x.CanConvertFrom(value.GetType())); - if(converter == null) - throw new ArgumentException("Cannot use type " + value.GetType() + " as an identity without having a type converter registered for it in the conventions' IdentityTypeConvertors"); - id = converter.ConvertFrom(value); - } - return true; - } - id = null; - return false; - } - -#if !NET_3_5 - private static bool TryGetIdFromDynamic(dynamic entity, out string id) - { - try - { - id = entity.Id; - return true; - } - catch (RuntimeBinderException) - { - id = null; - return false; - } - } -#endif - - /// - /// Creates the put entity command. - /// - /// The entity. - /// The document metadata. - /// - protected ICommandData CreatePutEntityCommand(object entity, DocumentSession.DocumentMetadata documentMetadata) - { - var json = ConvertEntityToJson(entity, documentMetadata.Metadata); - - var etag = UseOptimisticConcurrency ? documentMetadata.ETag : null; - - return new PutCommandData - { - Document = json, - Etag = etag, - Key = documentMetadata.Key, - Metadata = documentMetadata.Metadata, - }; - } - - private PropertyInfo GetIdentityProperty(Type entityType) - { - return documentStore.Conventions.GetIdentityProperty(entityType); - } - - /// - /// Updates the batch results. - /// - /// The batch results. - /// The entities. - protected void UpdateBatchResults(IList batchResults, IList entities) - { - var stored = Stored; - for (var i = 0; i < batchResults.Count; i++) - { - var batchResult = batchResults[i]; - if (batchResult.Method != "PUT") - continue; - - var entity = entities[i]; - DocumentSession.DocumentMetadata documentMetadata; - if (entitiesAndMetadata.TryGetValue(entity, out documentMetadata) == false) - continue; - - batchResult.Metadata["@etag"] = new JValue(batchResult.Etag.ToString()); - entitiesByKey[batchResult.Key] = entity; - documentMetadata.ETag = batchResult.Etag; - documentMetadata.Key = batchResult.Key; - documentMetadata.OriginalMetadata = new JObject(batchResult.Metadata); - documentMetadata.Metadata = batchResult.Metadata; - documentMetadata.OriginalValue = ConvertEntityToJson(entity, documentMetadata.Metadata); - - TrySetIdentity(entity, batchResult.Key); - - if (stored != null) - stored(entity); - - foreach (var documentStoreListener in storeListeners) - { - documentStoreListener.AfterStore(batchResult.Key, entity, batchResult.Metadata); - } - } - } - - /// - /// Prepares for save changes. - /// - /// - protected DocumentSession.SaveChangesData PrepareForSaveChanges() - { - var result = new DocumentSession.SaveChangesData - { - Entities = new List(), - Commands = new List() - }; - TryEnlistInAmbientTransaction(); - DocumentSession.DocumentMetadata value = null; - foreach (var key in (from deletedEntity in deletedEntities - where entitiesAndMetadata.TryGetValue(deletedEntity, out value) - select value.Key)) - { - Guid? etag = null; - object existingEntity; - DocumentSession.DocumentMetadata metadata = null; - if (entitiesByKey.TryGetValue(key, out existingEntity)) - { - if (entitiesAndMetadata.TryGetValue(existingEntity, out metadata)) - etag = metadata.ETag; - entitiesAndMetadata.Remove(existingEntity); - entitiesByKey.Remove(key); - } - - etag = UseOptimisticConcurrency ? etag : null; - result.Entities.Add(existingEntity); - - foreach (var deleteListener in deleteListeners) - { - deleteListener.BeforeDelete(key, existingEntity, metadata != null ? metadata.Metadata : null); - } - - result.Commands.Add(new DeleteCommandData - { - Etag = etag, - Key = key, - }); - } - deletedEntities.Clear(); - foreach (var entity in entitiesAndMetadata.Where(pair => EntityChanged(pair.Key, pair.Value))) - { - foreach (var documentStoreListener in storeListeners) - { - documentStoreListener.BeforeStore(entity.Value.Key, entity.Key, entity.Value.Metadata); - } - result.Entities.Add(entity.Key); - if (entity.Value.Key != null) - entitiesByKey.Remove(entity.Value.Key); - result.Commands.Add(CreatePutEntityCommand(entity.Key, entity.Value)); - } - - return result; - } - - private void TryEnlistInAmbientTransaction() - { - if (hasEnlisted || Transaction.Current == null) - return; - - - var transactionalSession = (ITransactionalDocumentSession)this; - if (documentStore.DatabaseCommands.SupportsPromotableTransactions == false || - Transaction.Current.EnlistPromotableSinglePhase(new PromotableRavenClientEnlistment(transactionalSession)) == false) - { - Transaction.Current.EnlistDurable( - ResourceManagerId, - new RavenClientEnlistment(transactionalSession), - EnlistmentOptions.None); - } - hasEnlisted = true; - } - - /// - /// Determines if the entity have changed. - /// - /// The entity. - /// The document metadata. - /// - protected bool EntityChanged(object entity, DocumentSession.DocumentMetadata documentMetadata) - { - if (documentMetadata == null) - return true; - var newObj = ConvertEntityToJson(entity, documentMetadata.Metadata); - var equalityComparer = new JTokenEqualityComparer(); - return equalityComparer.Equals(newObj, documentMetadata.OriginalValue) == false || - equalityComparer.Equals(documentMetadata.Metadata, documentMetadata.OriginalMetadata) == false; - } - - private JObject ConvertEntityToJson(object entity, JObject metadata) - { - var entityType = entity.GetType(); - var identityProperty = documentStore.Conventions.GetIdentityProperty(entityType); - - var objectAsJson = GetObjectAsJson(entity); - if (identityProperty != null) - { - objectAsJson.Remove(identityProperty.Name); - } - - metadata["Raven-Clr-Type"] = JToken.FromObject(ReflectionUtil.GetFullNameWithoutVersionInformation(entityType)); - - var entityConverted = OnEntityConverted; - if (entityConverted != null) - entityConverted(entity, objectAsJson, metadata); - - return objectAsJson; - } - - private JObject GetObjectAsJson(object entity) - { - return JObject.FromObject(entity, Conventions.CreateSerializer()); - } - - - - /// - /// Evicts the specified entity from the session. - /// Remove the entity from the delete queue and stops tracking changes for this entity. - /// - /// - /// The entity. - public void Evict(T entity) - { - DocumentSession.DocumentMetadata value; - if (entitiesAndMetadata.TryGetValue(entity, out value)) - { - entitiesAndMetadata.Remove(entity); - entitiesByKey.Remove(value.Key); - } - deletedEntities.Remove(entity); - } - - /// - /// Clears this instance. - /// Remove all entities from the delete queue and stops tracking changes for all entities. - /// - public void Clear() - { - entitiesAndMetadata.Clear(); - deletedEntities.Clear(); - entitiesByKey.Clear(); - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public virtual void Dispose() - { - - } - - /// - /// Commits the specified tx id. - /// - /// The tx id. - public abstract void Commit(Guid txId); - /// - /// Rollbacks the specified tx id. - /// - /// The tx id. - public abstract void Rollback(Guid txId); - /// - /// Promotes the transaction. - /// - /// From tx id. - /// - public abstract byte[] PromoteTransaction(Guid fromTxId); - - /// - /// Clears the enlistment. - /// - protected void ClearEnlistment() - { - hasEnlisted = false; - } - } -} +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Reflection; +using System.Transactions; +using Newtonsoft.Json.Linq; +using Raven.Client.Client; +using Raven.Client.Exceptions; +using Raven.Database; +using Raven.Database.Data; + +#if !NET_3_5 +using System.Dynamic; +using Microsoft.CSharp.RuntimeBinder; +using Raven.Database.Exceptions; +using Raven.Database.Linq; + +#endif + +namespace Raven.Client.Document +{ + /// + /// Abstract implementation for in memory session operations + /// + public abstract class InMemoryDocumentSessionOperations : IDisposable + { + private const string RavenEntityName = "Raven-Entity-Name"; + /// + /// The entities waiting to be deleted + /// + protected readonly HashSet deletedEntities = new HashSet(); + + private bool hasEnlisted; + + /// + /// hold the data required to manage the data for RavenDB's Unit of Work + /// + protected readonly Dictionary entitiesAndMetadata = + new Dictionary(); + + /// + /// Translate between a key and its associated entity + /// + protected readonly Dictionary entitiesByKey = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + /// + /// The document store associated with this session + /// + protected DocumentStore documentStore; + + /// + /// Gets the number of requests for this session + /// + /// + public int NumberOfRequests { get; private set; } + + private readonly IDocumentDeleteListener[] deleteListeners; + private readonly IDocumentStoreListener[] storeListeners; + + /// + /// Initializes a new instance of the class. + /// + /// The document store. + /// The store listeners. + /// The delete listeners. + protected InMemoryDocumentSessionOperations(DocumentStore documentStore, IDocumentStoreListener[] storeListeners, IDocumentDeleteListener[] deleteListeners) + { + this.documentStore = documentStore; + this.deleteListeners = deleteListeners; + this.storeListeners = storeListeners; + ResourceManagerId = documentStore.ResourceManagerId; + UseOptimisticConcurrency = false; + AllowNonAuthoritiveInformation = true; + NonAuthoritiveInformationTimeout = TimeSpan.FromSeconds(15); + MaxNumberOfRequestsPerSession = documentStore.Conventions.MaxNumberOfRequestsPerSession; + } + + /// + /// Gets or sets the timeout to wait for authoritive information if encountered non authoritive document. + /// + /// + public TimeSpan NonAuthoritiveInformationTimeout { get; set; } + + /// + /// Gets the store identifier for this session. + /// The store identifier is the identifier for the particular RavenDB instance. + /// This is mostly useful when using sharding. + /// + /// The store identifier. + public string StoreIdentifier + { + get { return documentStore.Identifier; } + } + + /// + /// Gets the conventions used by this session + /// + /// The conventions. + /// + /// This instance is shared among all sessions, changes to the should be done + /// via the instance, not on a single session. + /// + public DocumentConvention Conventions + { + get { return documentStore.Conventions; } + } + + /// + /// The transaction resource manager identifer + /// + public Guid ResourceManagerId { get; private set; } + + + /// + /// Gets or sets the max number of requests per session. + /// If the rise above , an exception will be thrown. + /// + /// The max number of requests per session. + public int MaxNumberOfRequestsPerSession { get; set; } + + /// + /// Gets or sets a value indicating whether the session should use optimistic concurrency. + /// When set to true, a check is made so that a change made behind the session back would fail + /// and raise . + /// + /// + public bool UseOptimisticConcurrency { get; set; } + /// + /// Occurs when an entity is stored in the session + /// + public virtual event EntityStored Stored; + /// + /// Occurs when an entity is converted to a document and metadata. + /// Changes made to the document / metadata instances passed to this event will be persisted. + /// + public virtual event EntityToDocument OnEntityConverted; + + /// + /// Gets the metadata for the specified entity. + /// + /// + /// The instance. + /// + public JObject GetMetadataFor(T instance) + { + DocumentSession.DocumentMetadata value; + if (entitiesAndMetadata.TryGetValue(instance, out value) == false) + { + string id; + if(TryGetIdFromInstance(instance, out id) +#if !NET_3_5 + || (instance is IDynamicMetaObjectProvider && + TryGetIdFromDynamic(instance, out id) ) +#endif + ) + { + var jsonDocument = GetJsonDocument(id); + entitiesByKey[id] = instance; + entitiesAndMetadata[instance] = value = new DocumentSession.DocumentMetadata + { + ETag = UseOptimisticConcurrency ? (Guid?)Guid.Empty : null, + Key = id, + OriginalMetadata = jsonDocument.Metadata, + Metadata = new JObject(jsonDocument.Metadata), + OriginalValue = new JObject() + }; + } + else + { + throw new InvalidOperationException("Could not find the document key for " + instance); + } + } + return value.Metadata; + } + + /// + /// Get the json document by key from the store + /// + protected abstract JsonDocument GetJsonDocument(string documentKey); + + /// + /// Gets the document id. + /// + /// The instance. + /// + public string GetDocumentId(object instance) + { + DocumentSession.DocumentMetadata value; + if (entitiesAndMetadata.TryGetValue(instance, out value) == false) + return null; + return value.Key; + } + /// + /// Gets a value indicating whether any of the entities tracked by the session has changes. + /// + /// + public bool HasChanges + { + get + { + return deletedEntities.Count > 0 || + entitiesAndMetadata.Where(pair => EntityChanged(pair.Key, pair.Value)).Any(); + } + } + + + /// + /// Determines whether the specified entity has changed. + /// + /// The entity. + /// + /// true if the specified entity has changed; otherwise, false. + /// + public bool HasChanged(object entity) + { + DocumentSession.DocumentMetadata value; + if (entitiesAndMetadata.TryGetValue(entity, out value) == false) + return false; + return EntityChanged(entity, value); + } + + internal void DecrementRequestCount() + { + --NumberOfRequests; + } + + internal void IncrementRequestCount() + { + if (++NumberOfRequests > MaxNumberOfRequestsPerSession) + throw new InvalidOperationException( + string.Format( + @"The maximum number of requests ({0}) allowed for this session has been reached. +Raven limits the number of remote calls that a session is allowed to make as an early warning system. Sessions are expected to be short lived, and +Raven provides facilities like Load(string[] keys) to load multiple documents at once and batch saves. +You can increase the limit by setting DocumentConvention.MaxNumberOfRequestsPerSession or DocumentSession.MaxNumberOfRequestsPerSession, but it is +advisable that you'll look into reducing the number of remote calls first, since that will speed up your application signficantly and result in a +more responsive application. +", + MaxNumberOfRequestsPerSession)); + } + + /// + /// Tracks the entity inside the unit of work + /// + /// + /// The document found. + /// + protected T TrackEntity(JsonDocument documentFound) + { + if (documentFound.Metadata.Property("@etag") == null) + { + documentFound.Metadata.Add("@etag", new JValue(documentFound.Etag.ToString())); + } + if(documentFound.NonAuthoritiveInformation && AllowNonAuthoritiveInformation == false) + { + throw new NonAuthoritiveInformationException("Document " + documentFound.Key + + " returned Non Authoritive Information (probably modified by a transaction in progress) and AllowNonAuthoritiveInformation is set to false"); + } + return TrackEntity(documentFound.Key, documentFound.DataAsJson, documentFound.Metadata); + } + + /// + /// Tracks the entity. + /// + /// + /// The key. + /// The document. + /// The metadata. + /// + public T TrackEntity(string key, JObject document, JObject metadata) + { + object entity; + if (entitiesByKey.TryGetValue(key, out entity) == false) + { + entity = ConvertToEntity(key, document, metadata); + } + else + { + // the local instnace may have been changed, we adhere to the current Unit of Work + // instance, and return that, ignoring anything new. + return (T) entity; + } + var etag = metadata.Value("@etag"); + document.Remove("@metadata"); + if(metadata.Value("Non-Authoritive-Information") && + AllowNonAuthoritiveInformation == false) + { + throw new NonAuthoritiveInformationException("Document " + key + + " returned Non Authoritive Information (probably modified by a transaction in progress) and AllowNonAuthoritiveInformation is set to false"); + } + entitiesAndMetadata[entity] = new DocumentSession.DocumentMetadata + { + OriginalValue = document, + Metadata = metadata, + OriginalMetadata = new JObject(metadata), + ETag = new Guid(etag), + Key = key + }; + entitiesByKey[key] = entity; + return (T) entity; + } + + /// + /// Gets or sets a value indicating whether non authoritive information is allowed. + /// Non authoritive information is document that has been modified by a transaction that hasn't been committed. + /// The server provides the latest committed version, but it is known that attempting to write to a non authoritive document + /// will fail, because it is already modified. + /// If set to false, the session will wait for the transaction to commit to get an + /// authoritive information. If the wait is longer than , is thrown. + /// + /// + /// true if non authoritive information is allowed; otherwise, false. + /// + public bool AllowNonAuthoritiveInformation { get; set; } + + /// + /// Marks the specified entity for deletion. The entity will be deleted when is called. + /// + /// + /// The entity. + public void Delete(T entity) + { + if(entitiesAndMetadata.ContainsKey(entity)==false) + throw new InvalidOperationException(entity+" is not associated with the session, cannot delete unknown entity instance"); + deletedEntities.Add(entity); + } + + /// + /// Converts the json document to an entity. + /// + /// + /// The id. + /// The document found. + /// The metadata. + /// + protected object ConvertToEntity(string id, JObject documentFound, JObject metadata) + { + var entity = default(T); + EnsureNotReadVetoed(metadata); + var documentType = metadata.Value("Raven-Clr-Type"); + if (documentType != null) + { + var type = Type.GetType(documentType); + if (type != null) + entity = (T) documentFound.Deserialize(type, Conventions); + } + if (Equals(entity, default(T))) + { + entity = documentFound.Deserialize(Conventions); +#if !NET_3_5 + var document = entity as JObject; + if (document != null) + { + entity = (T)(object)(new DynamicJsonObject(document)); + } +#endif + } + TrySetIdentity(entity, id); + return entity; + } + + /// + /// Tries to set the identity property + /// + /// + /// The entity. + /// The id. + protected internal void TrySetIdentity(T entity, string id) + { + var identityProperty = documentStore.Conventions.GetIdentityProperty(entity.GetType()); + if (identityProperty != null && identityProperty.CanWrite) + { + if (identityProperty.PropertyType == typeof(string)) + { + identityProperty.SetValue(entity, id, null); + } + else // need converting + { + var converter = Conventions.IdentityTypeConvertors.FirstOrDefault(x=>x.CanConvertFrom(identityProperty.PropertyType)); + if(converter == null) + throw new ArgumentException("Could not convert identity to type " + identityProperty.PropertyType + " because there is not matching type converter registered in the conventions' IdentityTypeConvertors"); + + identityProperty.SetValue(entity, converter.ConvertTo(id), null); + } + } + } + + private static void EnsureNotReadVetoed(JObject metadata) + { + var readVetoAsString = metadata.Value("Raven-Read-Veto"); + if (readVetoAsString == null) + return; + + var readVeto = JObject.Parse(readVetoAsString); + + var s = readVeto.Value("Reason"); + throw new ReadVetoException( + "Document could not be read because of a read veto."+Environment.NewLine + + "The read was vetoed by: " + readVeto.Value("Trigger") + Environment.NewLine + + "Veto reason: " + s + ); + } + + /// + /// Stores the specified entity in the session. The entity will be saved when is called. + /// + /// The entity. + public void Store(object entity) + { + if (null == entity) + throw new ArgumentNullException("entity"); + + string id = null; +#if !NET_3_5 + if (entity is IDynamicMetaObjectProvider) + { + if(TryGetIdFromDynamic(entity,out id) == false) + { + id = Conventions.DocumentKeyGenerator(entity); + + if (id != null) + { + // Store it back into the Id field so the client has access to to it + ((dynamic) entity).Id = id; + } + } + } + else +#endif + { + id = GetOrGenerateDocumentKey(entity); + + TrySetIdentity(entity, id); + } + + // we make the check here even if we just generated the key + // users can override the key generation behavior, and we need + // to detect if they generate duplicates. + if (id != null && + id.EndsWith("/") == false // not a prefix id + && entitiesByKey.ContainsKey(id)) + { + if (ReferenceEquals(entitiesByKey[id], entity)) + return; // calling Store twice on the same reference is a no-op + throw new NonUniqueObjectException("Attempted to associated a different object with id '" + id + "'."); + } + + var tag = documentStore.Conventions.GetTypeTagName(entity.GetType()); + entitiesAndMetadata.Add(entity, new DocumentSession.DocumentMetadata + { + Key = id, + Metadata = new JObject(new JProperty(RavenEntityName, new JValue(tag))), + OriginalMetadata = new JObject(), + ETag = UseOptimisticConcurrency ? (Guid?)Guid.Empty : null, + OriginalValue = new JObject() + }); + if (id != null) + entitiesByKey[id] = entity; + } + + /// + /// Tries to get the identity. + /// + /// The entity. + /// + protected string GetOrGenerateDocumentKey(object entity) + { + string id; + TryGetIdFromInstance(entity, out id); + + if (id == null) + { + // Generate the key up front + id = Conventions.GenerateDocumentKey(entity); + + } + return id; + } + + private bool TryGetIdFromInstance(object entity, out string id) + { + var identityProperty = GetIdentityProperty(entity.GetType()); + if (identityProperty != null) + { + var value = identityProperty.GetValue(entity, null); + id = value as string; + if(id == null && value != null) // need convertion + { + var converter = Conventions.IdentityTypeConvertors.FirstOrDefault(x => x.CanConvertFrom(value.GetType())); + if(converter == null) + throw new ArgumentException("Cannot use type " + value.GetType() + " as an identity without having a type converter registered for it in the conventions' IdentityTypeConvertors"); + id = converter.ConvertFrom(value); + } + return true; + } + id = null; + return false; + } + +#if !NET_3_5 + private static bool TryGetIdFromDynamic(dynamic entity, out string id) + { + try + { + id = entity.Id; + return true; + } + catch (RuntimeBinderException) + { + id = null; + return false; + } + } +#endif + + /// + /// Creates the put entity command. + /// + /// The entity. + /// The document metadata. + /// + protected ICommandData CreatePutEntityCommand(object entity, DocumentSession.DocumentMetadata documentMetadata) + { + var json = ConvertEntityToJson(entity, documentMetadata.Metadata); + + var etag = UseOptimisticConcurrency ? documentMetadata.ETag : null; + + return new PutCommandData + { + Document = json, + Etag = etag, + Key = documentMetadata.Key, + Metadata = documentMetadata.Metadata, + }; + } + + private PropertyInfo GetIdentityProperty(Type entityType) + { + return documentStore.Conventions.GetIdentityProperty(entityType); + } + + /// + /// Updates the batch results. + /// + /// The batch results. + /// The entities. + protected void UpdateBatchResults(IList batchResults, IList entities) + { + var stored = Stored; + for (var i = 0; i < batchResults.Count; i++) + { + var batchResult = batchResults[i]; + if (batchResult.Method != "PUT") + continue; + + var entity = entities[i]; + DocumentSession.DocumentMetadata documentMetadata; + if (entitiesAndMetadata.TryGetValue(entity, out documentMetadata) == false) + continue; + + batchResult.Metadata["@etag"] = new JValue(batchResult.Etag.ToString()); + entitiesByKey[batchResult.Key] = entity; + documentMetadata.ETag = batchResult.Etag; + documentMetadata.Key = batchResult.Key; + documentMetadata.OriginalMetadata = new JObject(batchResult.Metadata); + documentMetadata.Metadata = batchResult.Metadata; + documentMetadata.OriginalValue = ConvertEntityToJson(entity, documentMetadata.Metadata); + + TrySetIdentity(entity, batchResult.Key); + + if (stored != null) + stored(entity); + + foreach (var documentStoreListener in storeListeners) + { + documentStoreListener.AfterStore(batchResult.Key, entity, batchResult.Metadata); + } + } + } + + /// + /// Prepares for save changes. + /// + /// + protected DocumentSession.SaveChangesData PrepareForSaveChanges() + { + var result = new DocumentSession.SaveChangesData + { + Entities = new List(), + Commands = new List() + }; + TryEnlistInAmbientTransaction(); + DocumentSession.DocumentMetadata value = null; + foreach (var key in (from deletedEntity in deletedEntities + where entitiesAndMetadata.TryGetValue(deletedEntity, out value) + select value.Key)) + { + Guid? etag = null; + object existingEntity; + DocumentSession.DocumentMetadata metadata = null; + if (entitiesByKey.TryGetValue(key, out existingEntity)) + { + if (entitiesAndMetadata.TryGetValue(existingEntity, out metadata)) + etag = metadata.ETag; + entitiesAndMetadata.Remove(existingEntity); + entitiesByKey.Remove(key); + } + + etag = UseOptimisticConcurrency ? etag : null; + result.Entities.Add(existingEntity); + + foreach (var deleteListener in deleteListeners) + { + deleteListener.BeforeDelete(key, existingEntity, metadata != null ? metadata.Metadata : null); + } + + result.Commands.Add(new DeleteCommandData + { + Etag = etag, + Key = key, + }); + } + deletedEntities.Clear(); + foreach (var entity in entitiesAndMetadata.Where(pair => EntityChanged(pair.Key, pair.Value))) + { + foreach (var documentStoreListener in storeListeners) + { + documentStoreListener.BeforeStore(entity.Value.Key, entity.Key, entity.Value.Metadata); + } + result.Entities.Add(entity.Key); + if (entity.Value.Key != null) + entitiesByKey.Remove(entity.Value.Key); + result.Commands.Add(CreatePutEntityCommand(entity.Key, entity.Value)); + } + + return result; + } + + private void TryEnlistInAmbientTransaction() + { + if (hasEnlisted || Transaction.Current == null) + return; + + + var transactionalSession = (ITransactionalDocumentSession)this; + if (documentStore.DatabaseCommands.SupportsPromotableTransactions == false || + Transaction.Current.EnlistPromotableSinglePhase(new PromotableRavenClientEnlistment(transactionalSession)) == false) + { + Transaction.Current.EnlistDurable( + ResourceManagerId, + new RavenClientEnlistment(transactionalSession), + EnlistmentOptions.None); + } + hasEnlisted = true; + } + + /// + /// Determines if the entity have changed. + /// + /// The entity. + /// The document metadata. + /// + protected bool EntityChanged(object entity, DocumentSession.DocumentMetadata documentMetadata) + { + if (documentMetadata == null) + return true; + var newObj = ConvertEntityToJson(entity, documentMetadata.Metadata); + var equalityComparer = new JTokenEqualityComparer(); + return equalityComparer.Equals(newObj, documentMetadata.OriginalValue) == false || + equalityComparer.Equals(documentMetadata.Metadata, documentMetadata.OriginalMetadata) == false; + } + + private JObject ConvertEntityToJson(object entity, JObject metadata) + { + var entityType = entity.GetType(); + var identityProperty = documentStore.Conventions.GetIdentityProperty(entityType); + + var objectAsJson = GetObjectAsJson(entity); + if (identityProperty != null) + { + objectAsJson.Remove(identityProperty.Name); + } + + metadata["Raven-Clr-Type"] = JToken.FromObject(ReflectionUtil.GetFullNameWithoutVersionInformation(entityType)); + + var entityConverted = OnEntityConverted; + if (entityConverted != null) + entityConverted(entity, objectAsJson, metadata); + + return objectAsJson; + } + + private JObject GetObjectAsJson(object entity) + { + return JObject.FromObject(entity, Conventions.CreateSerializer()); + } + + + + /// + /// Evicts the specified entity from the session. + /// Remove the entity from the delete queue and stops tracking changes for this entity. + /// + /// + /// The entity. + public void Evict(T entity) + { + DocumentSession.DocumentMetadata value; + if (entitiesAndMetadata.TryGetValue(entity, out value)) + { + entitiesAndMetadata.Remove(entity); + entitiesByKey.Remove(value.Key); + } + deletedEntities.Remove(entity); + } + + /// + /// Clears this instance. + /// Remove all entities from the delete queue and stops tracking changes for all entities. + /// + public void Clear() + { + entitiesAndMetadata.Clear(); + deletedEntities.Clear(); + entitiesByKey.Clear(); + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public virtual void Dispose() + { + + } + + /// + /// Commits the specified tx id. + /// + /// The tx id. + public abstract void Commit(Guid txId); + /// + /// Rollbacks the specified tx id. + /// + /// The tx id. + public abstract void Rollback(Guid txId); + /// + /// Promotes the transaction. + /// + /// From tx id. + /// + public abstract byte[] PromoteTransaction(Guid fromTxId); + + /// + /// Clears the enlistment. + /// + protected void ClearEnlistment() + { + hasEnlisted = false; + } + } +} diff --git a/Raven.Client/Raven.Client.csproj.orig b/Raven.Client/Raven.Client.csproj.orig new file mode 100644 index 000000000000..951f823f54d3 --- /dev/null +++ b/Raven.Client/Raven.Client.csproj.orig @@ -0,0 +1,431 @@ +<<<<<<< HEAD + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {9F92FD36-60B6-4655-B8C6-00125B46AB6A} + Library + Properties + Raven.Client + Raven.Client + v4.0 + 512 + + + 3.5 + + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + AnyCPU + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + + + true + + + ..\Raven.Database\RavenDB.snk + + + + + False + ..\SharedLibs\Newtonsoft.Json.dll + + + + + + 3.5 + + + + + 3.5 + + + 3.5 + + + + + + + Data\ReplicationDestination.cs + + + Data\ReplicationDocument.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {212823CD-25E1-41AC-92D1-D6DF4D53FC85} + Raven.Database + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + RavenDB.snk + + + +======= + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {9F92FD36-60B6-4655-B8C6-00125B46AB6A} + Library + Properties + Raven.Client + Raven.Client + v4.0 + 512 + + + 3.5 + + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + AnyCPU + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + + + true + + + ..\Raven.Database\RavenDB.snk + + + + + False + ..\SharedLibs\Newtonsoft.Json.dll + + + + + + 3.5 + + + + + 3.5 + + + 3.5 + + + + + + + Data\ReplicationDestination.cs + + + Data\ReplicationDocument.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {212823CD-25E1-41AC-92D1-D6DF4D53FC85} + Raven.Database + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + RavenDB.snk + + + +>>>>>>> 4547b78a1c464783091667d20936046eaf013294 + + \ No newline at end of file diff --git a/RavenDB.nuspec b/RavenDB.nuspec index fa33e4c08d6f..afbe50fa10c9 100644 --- a/RavenDB.nuspec +++ b/RavenDB.nuspec @@ -1,13 +1,13 @@ - - - - RavenDB - 1.0 - - Hibernating Rhinos (http://hiberantingrhinos.com) - - Raven is a document database for the .NET/Windows platform, offering a flexible data model design to fit the needs of real world systems. - en-US - http://www.ravendb.net/licensing - + + + + RavenDB + 1.0 + + Hibernating Rhinos (http://hiberantingrhinos.com) + + Raven is a document database for the .NET/Windows platform, offering a flexible data model design to fit the needs of real world systems. + en-US + http://www.ravendb.net/licensing + \ No newline at end of file diff --git a/default.ps1 b/default.ps1 index f071e49f5c22..356cdfc7540f 100644 --- a/default.ps1 +++ b/default.ps1 @@ -234,16 +234,16 @@ task CreateNupack { $nupack = [xml](get-content $base_dir\RavenDB.nuspec) $nupack.package.metadata.version = "$version.$env:buildlabel" - - $writerSettings = new-object System.Xml.XmlWriterSettings - $writerSettings.OmitXmlDeclaration = $true - $writerSettings.NewLineOnAttributes = $true - $writerSettings.Indent = $true - - $writer = [System.Xml.XmlWriter]::Create("$build_dir\Nupack\RavenDB.nuspec", $writerSettings) - - $nupack.WriteTo($writer) - $writer.Flush() + + $writerSettings = new-object System.Xml.XmlWriterSettings + $writerSettings.OmitXmlDeclaration = $true + $writerSettings.NewLineOnAttributes = $true + $writerSettings.Indent = $true + + $writer = [System.Xml.XmlWriter]::Create("$build_dir\Nupack\RavenDB.nuspec", $writerSettings) + + $nupack.WriteTo($writer) + $writer.Flush() $writer.Close() cp $build_dir\Newtonsoft.Json.dll $build_dir\NuPack\Lib\3.5