-
Notifications
You must be signed in to change notification settings - Fork 524
Query: Adds support for System.Text LINQ Custom Serializer #4138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
microsoft-github-policy-service
merged 58 commits into
master
from
users/mayapainter/LinqCustomSerialization
Jan 5, 2024
Merged
Changes from 55 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
0094685
initial commit
Maya-Painter 5ab7959
add more tests
Maya-Painter 260a6fc
cleanup
Maya-Painter 2583c8e
camel case fix
Maya-Painter 3fe6006
fix precidence and add test
Maya-Painter 6ebafd2
cleanup
Maya-Painter 61082f5
cleanup
Maya-Painter 28a08c1
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter ce9b2a8
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter 3ad6110
Implement serializers
Maya-Painter a0da2c3
clenaup and bugfix
Maya-Painter 656c278
cleanup constructors
Maya-Painter 32ba80d
fix baseline
Maya-Painter 74e2410
updates
Maya-Painter 573b1e4
cleanup
Maya-Painter d6b6f9a
removed requirement to decorate enums
Maya-Painter 0dec53d
nit PR comments
Maya-Painter 6a2d26a
bug fix and api updates
Maya-Painter 6821838
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter ab6be11
Pr comments
Maya-Painter 7e9f1ea
remove datacontract and newtonsoft serializer types
Maya-Painter 739e914
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter 4e34878
Pr comments and adding tests
Maya-Painter 36c5e67
updates
Maya-Painter 238bcdd
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter 0c2bc46
Aggregate tests and new serializer member
Maya-Painter e45c2a2
More tests and cleanup
Maya-Painter be90c91
PR comments
Maya-Painter 3186741
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter 22e05dd
PR comments
Maya-Painter 4b52602
PR comments - internal options class
Maya-Painter a62eb58
Update Program.cs
Maya-Painter dead02e
comment fixes
Maya-Painter 1f23678
PR comments
Maya-Painter 436573e
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter 0a3a7fc
Add preview flag
Maya-Painter 981b56c
API changes
Maya-Painter c1f2737
new serialization interface
Maya-Painter 86c4515
Update API and serializer updates
Maya-Painter 5593fd0
API fix
Maya-Painter ad38065
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter 125198d
cleanup
Maya-Painter dc0afd3
PR comments
Maya-Painter be43ed6
update interface
Maya-Painter ed82751
fix
Maya-Painter 81e29e2
API
Maya-Painter 6684fc8
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter 7eba850
Update Microsoft.Azure.Cosmos/src/Serializer/ICosmosLinqSerializer.cs
Maya-Painter 10ed71e
Some PR comments
Maya-Painter 0bd4a26
adding sample code
Maya-Painter 4153a5e
Enum rename and interfact to abstract class
Maya-Painter 7055cf5
Merge branch 'master' into users/mayapainter/LinqCustomSerialization
Maya-Painter ee3afe8
PR comments
Maya-Painter ad1a222
PR comments
Maya-Painter 8efedf1
Remove CosmosLinqSerializerType
Maya-Painter fa402f9
last one (hopefully)
Maya-Painter 7e2bbd5
Update Microsoft.Azure.Cosmos/src/Linq/TranslationContext.cs
Maya-Painter 090642a
Update Microsoft.Azure.Cosmos/src/Linq/TranslationContext.cs
Maya-Painter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Microsoft.Azure.Cosmos/src/Linq/CustomCosmosLinqSerializer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| //------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| //------------------------------------------------------------ | ||
| namespace Microsoft.Azure.Cosmos.Linq | ||
| { | ||
| using System; | ||
| using System.Globalization; | ||
| using System.IO; | ||
| using System.Linq.Expressions; | ||
| using System.Reflection; | ||
|
|
||
| internal class CustomCosmosLinqSerializer : ICosmosLinqSerializerInternal | ||
| { | ||
| private readonly CosmosLinqSerializer CustomCosmosSerializer; | ||
|
|
||
| public CustomCosmosLinqSerializer(CosmosLinqSerializer customCosmosLinqSerializer) | ||
| { | ||
| this.CustomCosmosSerializer = customCosmosLinqSerializer; | ||
| } | ||
|
|
||
| public bool RequiresCustomSerialization(MemberExpression memberExpression, Type memberType) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| public string Serialize(object value, MemberExpression memberExpression, Type memberType) | ||
| { | ||
| return this.SerializeWithCustomSerializer(value); | ||
| } | ||
|
|
||
| public string SerializeScalarExpression(ConstantExpression inputExpression) | ||
| { | ||
| return this.SerializeWithCustomSerializer(inputExpression.Value); | ||
| } | ||
|
|
||
| public string SerializeMemberName(MemberInfo memberInfo) | ||
| { | ||
| return this.CustomCosmosSerializer.SerializeMemberName(memberInfo); | ||
| } | ||
|
|
||
| private string SerializeWithCustomSerializer(object value) | ||
| { | ||
| StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); | ||
|
|
||
| using (Stream stream = this.CustomCosmosSerializer.ToStream(value)) | ||
| { | ||
| using (StreamReader streamReader = new StreamReader(stream)) | ||
| { | ||
| string propertyValue = streamReader.ReadToEnd(); | ||
| writer.Write(propertyValue); | ||
| return writer.ToString(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.