File-scoped namespaces

This commit is contained in:
Shay Rojansky
2022-05-17 14:44:27 +02:00
parent 5e2f346a8b
commit d876e7e4ca
17 changed files with 1358 additions and 1375 deletions

View File

@@ -14,8 +14,8 @@ using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Xunit; using Xunit;
namespace EFCore.NamingConventions.Test namespace EFCore.NamingConventions.Test;
{
public class NameRewritingConventionTest public class NameRewritingConventionTest
{ {
[Fact] [Fact]
@@ -562,4 +562,3 @@ namespace EFCore.NamingConventions.Test
public int OwnedProperty { get; set; } public int OwnedProperty { get; set; }
} }
} }
}

View File

@@ -2,8 +2,8 @@ using System.Globalization;
using EFCore.NamingConventions.Internal; using EFCore.NamingConventions.Internal;
using Xunit; using Xunit;
namespace EFCore.NamingConventions.Test namespace EFCore.NamingConventions.Test;
{
public class RewriterTest public class RewriterTest
{ {
[Fact] [Fact]
@@ -31,4 +31,3 @@ namespace EFCore.NamingConventions.Test
=> Assert.Equal("FULLNAME", => Assert.Equal("FULLNAME",
new UpperCaseNameRewriter(CultureInfo.InvariantCulture).RewriteName("FullName")); new UpperCaseNameRewriter(CultureInfo.InvariantCulture).RewriteName("FullName"));
} }
}

View File

@@ -7,8 +7,8 @@ using Microsoft.EntityFrameworkCore.Sqlite.Diagnostics.Internal;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.TestUtilities namespace Microsoft.EntityFrameworkCore.TestUtilities;
{
public class SqliteTestHelpers : TestHelpers public class SqliteTestHelpers : TestHelpers
{ {
protected SqliteTestHelpers() protected SqliteTestHelpers()
@@ -27,4 +27,3 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities
public override LoggingDefinitions LoggingDefinitions { get; } = new SqliteLoggingDefinitions(); public override LoggingDefinitions LoggingDefinitions { get; } = new SqliteLoggingDefinitions();
#pragma warning restore EF1001 #pragma warning restore EF1001
} }
}

View File

@@ -6,8 +6,8 @@ using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore namespace Microsoft.EntityFrameworkCore;
{
[DebuggerStepThrough] [DebuggerStepThrough]
internal static class Check internal static class Check
{ {
@@ -107,4 +107,3 @@ namespace Microsoft.EntityFrameworkCore
return value; return value;
} }
} }
}

View File

@@ -1,8 +1,8 @@
using System; using System;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace JetBrains.Annotations namespace JetBrains.Annotations;
{
[AttributeUsage( [AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Parameter |
AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Property | AttributeTargets.Delegate |
@@ -105,4 +105,3 @@ namespace JetBrains.Annotations
Members = 2, Members = 2,
WithMembers = Itself | Members WithMembers = Itself | Members
} }
}

View File

@@ -1,7 +1,7 @@
using System.Globalization; using System.Globalization;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class CamelCaseNameRewriter : INameRewriter public class CamelCaseNameRewriter : INameRewriter
{ {
private readonly CultureInfo _culture; private readonly CultureInfo _culture;
@@ -11,4 +11,3 @@ namespace EFCore.NamingConventions.Internal
public string RewriteName(string name) => public string RewriteName(string name) =>
string.IsNullOrEmpty(name) ? name: char.ToLower(name[0], _culture) + name.Substring(1); string.IsNullOrEmpty(name) ? name: char.ToLower(name[0], _culture) + name.Substring(1);
} }
}

View File

@@ -1,7 +1,6 @@
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public interface INameRewriter public interface INameRewriter
{ {
string RewriteName(string name); string RewriteName(string name);
} }
}

View File

@@ -1,7 +1,7 @@
using System.Globalization; using System.Globalization;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class LowerCaseNameRewriter : INameRewriter public class LowerCaseNameRewriter : INameRewriter
{ {
private readonly CultureInfo _culture; private readonly CultureInfo _culture;
@@ -9,4 +9,3 @@ namespace EFCore.NamingConventions.Internal
public LowerCaseNameRewriter(CultureInfo culture) => _culture = culture; public LowerCaseNameRewriter(CultureInfo culture) => _culture = culture;
public string RewriteName(string name) => name.ToLower(_culture); public string RewriteName(string name) => name.ToLower(_culture);
} }
}

View File

@@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Conventions;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class NameRewritingConvention : public class NameRewritingConvention :
IEntityTypeAddedConvention, IEntityTypeAddedConvention,
IEntityTypeAnnotationChangedConvention, IEntityTypeAnnotationChangedConvention,
@@ -279,4 +279,3 @@ namespace EFCore.NamingConventions.Internal
} }
} }
} }
}

View File

@@ -1,5 +1,5 @@
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public enum NamingConvention public enum NamingConvention
{ {
None, None,
@@ -9,4 +9,3 @@ namespace EFCore.NamingConventions.Internal
UpperCase, UpperCase,
UpperSnakeCase UpperSnakeCase
} }
}

View File

@@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class NamingConventionSetPlugin : IConventionSetPlugin public class NamingConventionSetPlugin : IConventionSetPlugin
{ {
private readonly IDbContextOptions _options; private readonly IDbContextOptions _options;
@@ -45,4 +45,3 @@ namespace EFCore.NamingConventions.Internal
return conventionSet; return conventionSet;
} }
} }
}

View File

@@ -6,8 +6,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class NamingConventionsOptionsExtension : IDbContextOptionsExtension public class NamingConventionsOptionsExtension : IDbContextOptionsExtension
{ {
private DbContextOptionsExtensionInfo _info; private DbContextOptionsExtensionInfo _info;
@@ -146,4 +146,3 @@ namespace EFCore.NamingConventions.Internal
} }
} }
} }
}

View File

@@ -2,8 +2,8 @@ using System;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class SnakeCaseNameRewriter : INameRewriter public class SnakeCaseNameRewriter : INameRewriter
{ {
private readonly CultureInfo _culture; private readonly CultureInfo _culture;
@@ -72,4 +72,3 @@ namespace EFCore.NamingConventions.Internal
return builder.ToString(); return builder.ToString();
} }
} }
}

View File

@@ -1,7 +1,7 @@
using System.Globalization; using System.Globalization;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class UpperCaseNameRewriter : INameRewriter public class UpperCaseNameRewriter : INameRewriter
{ {
private readonly CultureInfo _culture; private readonly CultureInfo _culture;
@@ -9,4 +9,3 @@ namespace EFCore.NamingConventions.Internal
public UpperCaseNameRewriter(CultureInfo culture) => _culture = culture; public UpperCaseNameRewriter(CultureInfo culture) => _culture = culture;
public string RewriteName(string name) => name.ToUpper(_culture); public string RewriteName(string name) => name.ToUpper(_culture);
} }
}

View File

@@ -1,7 +1,7 @@
using System.Globalization; using System.Globalization;
namespace EFCore.NamingConventions.Internal namespace EFCore.NamingConventions.Internal;
{
public class UpperSnakeCaseNameRewriter : SnakeCaseNameRewriter public class UpperSnakeCaseNameRewriter : SnakeCaseNameRewriter
{ {
private readonly CultureInfo _culture; private readonly CultureInfo _culture;
@@ -10,4 +10,3 @@ namespace EFCore.NamingConventions.Internal
public override string RewriteName(string name) => base.RewriteName(name).ToUpper(_culture); public override string RewriteName(string name) => base.RewriteName(name).ToUpper(_culture);
} }
}

View File

@@ -4,8 +4,8 @@ using JetBrains.Annotations;
using EFCore.NamingConventions.Internal; using EFCore.NamingConventions.Internal;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore namespace Microsoft.EntityFrameworkCore;
{
public static class NamingConventionsExtensions public static class NamingConventionsExtensions
{ {
public static DbContextOptionsBuilder UseSnakeCaseNamingConvention( public static DbContextOptionsBuilder UseSnakeCaseNamingConvention(
@@ -103,4 +103,3 @@ namespace Microsoft.EntityFrameworkCore
where TContext : DbContext where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>)UseCamelCaseNamingConvention((DbContextOptionsBuilder)optionsBuilder, culture); => (DbContextOptionsBuilder<TContext>)UseCamelCaseNamingConvention((DbContextOptionsBuilder)optionsBuilder, culture);
} }
}

View File

@@ -5,8 +5,8 @@ using EFCore.NamingConventions.Internal;
using JetBrains.Annotations; using JetBrains.Annotations;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection namespace Microsoft.Extensions.DependencyInjection;
{
/// <summary> /// <summary>
/// Extension methods for <see cref="Microsoft.Extensions.DependencyInjection.IServiceCollection" />. /// Extension methods for <see cref="Microsoft.Extensions.DependencyInjection.IServiceCollection" />.
/// </summary> /// </summary>
@@ -39,4 +39,3 @@ namespace Microsoft.Extensions.DependencyInjection
return serviceCollection; return serviceCollection;
} }
} }
}