Releases: mongodb/mongo-csharp-analyzer
v1.5.0
MongoDB .NET Analyzer 1.5.0 Release Notes
This is the general availability release for the 1.5.0 version of the analyzer.
The main new features in 1.5.0 include:
VS-141 New analysis rules introduced: EFCore to MQL:
The new analysis rules enable displaying MQL for MongoDB Entity Framework Core Provider expressions in compile time.
For example:
var mongoClient = new MongoClient("mongodb://localhost:27017");
var db = MoviesDbContext.Create(mongoClient.GetDatabase("movies"));
// LINQ filter query (analyzer provides MQL as an information message)
var movies = await db.Movies
.Where(m =>
m.Genre == genre &&
m.Score >= minScore &&
m.Title.Contains(titleSearchTerm))
.OrderBy(m => m.Score)
.ToListAsync();
public class MoviesDbContext : DbContext
{
public DbSet<Movie> Movies { get; set; }
public static MoviesDbContext Create(IMongoDatabase database) =>
new(new DbContextOptionsBuilder<MoviesDbContext>()
.UseMongoDB(database.Client, database.DatabaseNamespace.DatabaseName)
.Options);
public MoviesDbContext(DbContextOptions options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
Will display the following MQL for the db.Movies
query:
db.coll.Aggregate([{ "$match" : { "Genre" : genre, "Score" : { "$gte" : minScore }, "Title" : /titleSearchTerm/s } }, { "$sort" : { "Score" : 1 } }])
VS-156 Support for strong named 2.28 driver.
VS-146 Support fully qualified names for data models.
The full list of JIRA issues resolved in this release is available here.
v1.4.0
MongoDB .NET Analyzer 1.4.0 Release Notes
This is the general availability release for the 1.4.0 version of the analyzer.
The main new features in 1.4.0 include:
- VS-140 Support of builders definition defined by variables
For example:
var movieFilterBuilder = Builders<Movie>.Filter;
var filterReviews = movieFilterBuilder.Size(p => p.Reviews, 5);
Expression movieFilterBuilder.Size(p => p.Reviews, 5);
will be analyzed.
- VS-124 Implement signing of NuGet packages
- Multiple bug fixes and improvements.
The full list of JIRA issues resolved in this release is available here.
v1.3.0
MongoDB .NET Analyzer 1.3.0 Release Notes
This is the general availability release for the 1.3.0 version of the analyzer.
The main new features in 1.3.0 include:
New analysis rules introduced: POCO to JSON
The new analysis rules allow to display the driver serialization result for a POCO in compiler time.
This can be used to validate correctness of BSON attributes setup and get a driver JSON representation shape.
For example:
public class Address
{
[BsonElement("street")]
public string StreetName { get; set; }
[BsonIgnore]
public string City { get; set; }
public string Province { get; set; }
[BsonElement("zip")]
public string ZipCode { get; set; }
}
Will display the following JSON representation: { "street" : "Maplewood Lane", "Province" : "Lombardy", "zip" : "60601" }
.
Notice that BsonElement
and BsonIgnore
attributes are accounted for.
Support for BSON serialization attributes
BSON serialization attributes like BsonElement
, BsonIgnore
, BsonIgnoreIfNull
and other attributes are supported in POCO, LINQ and Builders analysis.
Additional main improvements in 1.3.0:
VS-93 introduces support for expressions with enums in tupples
VS-97 introduces better support for nullables
The full list of JIRA issues resolved in this release is available here.
v1.2.0
MongoDB .NET Analyzer 1.2.0 Release Notes
This is the general availability release for the 1.2.0 version of the analyzer.
The main new features in 1.2.0 include:
Builders for Atlas Search limited support
// Search definition (analyzer provides mql as information message)
var searchTitle = Builders<Movie>.Search.Wildcard(p => p.Title, "Green D*");
// MQL is displayed for 'searchTitle' variable
moviesCollection.Aggregate().Search(searchTitle)
Support for default LINQ3 provider in 2.19.0 and higher driver versions
Default LINQ provider version is set automatically to V2 in 2.18.0 and lower versions and to V3 in 2.19.0 and higher versions.
For more information see DefaultLinqVersion
option in Analyzer configuration.
Main bug fixes in 1.2.0 include:
VS-79 LINQ expressions are not analyzed without "using MongoDB.Driver.Linq;"
The full list of JIRA issues resolved in this release is available here.
v1.1.0
MongoDB .NET Analyzer 1.1.0 Release Notes
This is the general availability release for the 1.1.0 version of the analyzer.
The main new features in 1.1.0 include:
Builders variables tracking and composition
var filterScore = Builders<Movie>.Filter.Gt(p => p.Score, 5);
var filterTitle = Builders<Movie>.Filter.Regex(p => p.Title, "Summer");
var filterGenre = Builders<Movie>.Filter.Eq(p => p.Genre, Genre.Comedy);
// MQL is dispalyed for each filter variable
var filterCombined = filterTitle | filterScore | filterGenre;
// MQL for the combined filter is displayed
moviesCollection.Find(filterCombined);
Fluent API support
// MQL is displayed for the Fluent API methods
_ = moviesCollection
.Find(u => u.Producer.Contains("Nolan"))
.SortBy(u => u.Score)
.ThenBy(u => u.Title);
LINQ Query syntax support
// MQL is displayed for LINQ expressions using query syntax
var queryable = from movie in moviesCollection
group movie by movie.Genre into g
select g;
Builders IndexKeys support
// IndexKeys builder is analyzed
_ = Builders<User>.IndexKeys.Ascending(x => x.Age);
_ = Builders<Shape>.IndexKeys.Geo2D(u => u.Point);
Builders Projections support
// Projection builder is analyzed
_ = Builders<User>.Projection.Include(u => u.Age);
_ = Builders<Person>.Projection.Expression(u => u.Address);
The full list of JIRA issues resolved in this release is available at:
https://jira.mongodb.org/issues/?jql=project%20%3D%20VS%20AND%20fixVersion%20%3D%201.1.0