Skip to content

Commit 2baa370

Browse files
authored
Convert SqlCompilerConfiguration to readonly struct (#389)
* Convert `SqlCompilerConfiguration` to `readonly struct` * in
1 parent 7e8e40c commit 2baa370

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Orm/Xtensive.Orm/Sql/Compiler/SqlCompilerConfiguration.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ namespace Xtensive.Sql.Compiler
1717
/// <summary>
1818
/// A various options for <see cref="SqlCompiler"/>.
1919
/// </summary>
20-
public sealed class SqlCompilerConfiguration
20+
public readonly struct SqlCompilerConfiguration()
2121
{
2222
/// <summary>
2323
/// Gets or sets the parameter prefix.
2424
/// </summary>
25-
public string ParameterNamePrefix { get; set; }
25+
public string ParameterNamePrefix { get; init; }
2626

2727
/// <summary>
2828
/// Always use database-qualified objects in generated SQL.
2929
/// This option could be enabled if and only if
3030
/// server supports <see cref="QueryFeatures.MultidatabaseQueries"/>.
3131
/// </summary>
32-
public bool DatabaseQualifiedObjects { get; set; }
32+
public bool DatabaseQualifiedObjects { get; init; }
3333

3434
/// <summary>
3535
/// Insert Placeholder nodes instead of real schema names
3636
/// Allows to share compiled query over multiple schemas.
3737
/// </summary>
38-
public bool ParametrizeSchemaNames { get; set; }
38+
public bool ParametrizeSchemaNames { get; init; }
3939

4040
/// <summary>
4141
/// Gets or sets comment location.
4242
/// </summary>
43-
public SqlCommentLocation CommentLocation { get; set; } = SqlCommentLocation.Nowhere;
43+
public SqlCommentLocation CommentLocation { get; init; } = SqlCommentLocation.Nowhere;
4444

4545
/// <summary>
4646
/// Clones this instance.

Orm/Xtensive.Orm/Sql/SqlDriver.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ public SqlCompilationResult Compile(ISqlCompileUnit statement)
7272
/// <param name="configuration">The options of compilation.</param>
7373
/// <param name="typeIdRegistry">TypeId registry.</param>
7474
/// <returns>Result of compilation.</returns>
75-
public SqlCompilationResult Compile(ISqlCompileUnit statement, SqlCompilerConfiguration configuration, TypeIdRegistry typeIdRegistry = null)
75+
public SqlCompilationResult Compile(ISqlCompileUnit statement, in SqlCompilerConfiguration configuration, TypeIdRegistry typeIdRegistry = null)
7676
{
77-
ArgumentNullException.ThrowIfNull(statement);
78-
ArgumentNullException.ThrowIfNull(configuration);
7977
ValidateCompilerConfiguration(configuration);
8078
return CreateCompiler().Compile(statement, configuration);
8179
}
@@ -471,7 +469,7 @@ private async Task<Extractor> BuildExtractorAsync(SqlConnection connection, Canc
471469
return extractor;
472470
}
473471

474-
private void ValidateCompilerConfiguration(SqlCompilerConfiguration configuration)
472+
private void ValidateCompilerConfiguration(in SqlCompilerConfiguration configuration)
475473
{
476474
var supported = ServerInfo.Query.Features.Supports(QueryFeatures.MultidatabaseQueries);
477475
var requested = configuration.DatabaseQualifiedObjects;

0 commit comments

Comments
 (0)