Skip to content

CSHARP-5453: Add builder for CSFLE schemas #1631

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

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
063694d
CSHARP-5453: Improve field encryption usability with attributes/API
papafe Mar 7, 2025
8ded4b4
Small corrections
papafe Mar 7, 2025
7102d52
Fixed stub
papafe Mar 11, 2025
5dfcdb0
Small fix
papafe Mar 11, 2025
6f73eba
Various improvements
papafe Mar 12, 2025
9fa8148
Conversion to records
papafe Mar 12, 2025
35809be
Various improvements
papafe Mar 12, 2025
e080d05
Fixed API
papafe Mar 12, 2025
fea7090
Small comment
papafe Mar 12, 2025
0f02af0
Fix to naming
papafe Mar 13, 2025
5427433
Several improvements
papafe Mar 19, 2025
a716c09
Removed unused
papafe Mar 19, 2025
0f46107
First improvement
papafe Mar 20, 2025
7970958
Removed old things
papafe Apr 9, 2025
f397825
Improvements
papafe Apr 14, 2025
f4e687b
Some simplifications
papafe Apr 14, 2025
d432224
Simplified
papafe Apr 14, 2025
83c83e2
Improved API
papafe Apr 14, 2025
04d3b82
Small fix
papafe Apr 14, 2025
9b6d5f8
Fixing schema builder
papafe Apr 30, 2025
695d669
Various improvements plus fixed tests
papafe May 1, 2025
3f5d366
Small fix
papafe May 1, 2025
f793c27
Added first basic test
papafe May 2, 2025
5f4732c
Corrections plus more tests
papafe May 2, 2025
5d691c7
Corrected order
papafe May 2, 2025
e6b69f1
Improved tests
papafe May 2, 2025
00819ef
Added exceptions and improved testing
papafe May 5, 2025
678dcb2
Moved builder to encryption project and removed CsfleEncryptionEnum (…
papafe May 5, 2025
d0eecc5
Put bsontypes to be nullable and removed unsupported bsonTypes
papafe May 5, 2025
f192112
Corrected test naming
papafe May 5, 2025
48299f7
Fixed API for overloads
papafe May 5, 2025
4282c10
Added exception for empty schema
papafe May 5, 2025
d1cf820
Added docs
papafe May 5, 2025
9c03b9e
Small fix
papafe May 5, 2025
6a02a6e
Fix
papafe May 5, 2025
43c6419
Removed unnecessary
papafe May 5, 2025
3311f84
Name fix
papafe May 5, 2025
d2e7489
Removed unnecessaty
papafe May 5, 2025
ca05ccf
Added common method BsonType --> string and removed unnecessary files.
papafe Jun 18, 2025
7c2ee81
Small fix to work better with Optional
papafe Jul 16, 2025
5dc49f3
Moved extension file.
papafe Jul 16, 2025
48ef7c3
Removed extension
papafe Jul 21, 2025
bc5131c
Revert "Removed extension"
papafe Jul 22, 2025
d8e2033
Rename
papafe Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/MongoDB.Bson/ObjectModel/BsonTypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;

namespace MongoDB.Bson
{
/// <summary>
/// A static class containing extension methods for <see cref="BsonType"/>.
/// </summary>
public static class BsonTypeExtensions
{
/// <summary>
/// Maps a <see cref="BsonType"/> to its corresponding server string representation.
/// </summary>
/// <param name="type">The input type to map.</param>
public static string ToServerString(this BsonType type)
{
return type switch
{
BsonType.Array => "array",
BsonType.Binary => "binData",
BsonType.Boolean => "bool",
BsonType.DateTime => "date",
BsonType.Decimal128 => "decimal",
BsonType.Document => "object",
BsonType.Double => "double",
BsonType.Int32 => "int",
BsonType.Int64 => "long",
BsonType.JavaScript => "javascript",
BsonType.JavaScriptWithScope => "javascriptWithScope",
BsonType.MaxKey => "maxKey",
BsonType.MinKey => "minKey",
BsonType.Null => "null",
BsonType.ObjectId => "objectId",
BsonType.RegularExpression => "regex",
BsonType.String => "string",
BsonType.Symbol => "symbol",
BsonType.Timestamp => "timestamp",
BsonType.Undefined => "undefined",
_ => throw new ArgumentException($"Unexpected BSON type: {type}.", nameof(type))
};
}
}
}
Loading