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 Xunit;
namespace EFCore.NamingConventions.Test
{
namespace EFCore.NamingConventions.Test;
public class NameRewritingConventionTest
{
[Fact]
@@ -562,4 +562,3 @@ namespace EFCore.NamingConventions.Test
public int OwnedProperty { get; set; }
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
using System.Globalization;
namespace EFCore.NamingConventions.Internal
{
namespace EFCore.NamingConventions.Internal;
public class CamelCaseNameRewriter : INameRewriter
{
private readonly CultureInfo _culture;
@@ -11,4 +11,3 @@ namespace EFCore.NamingConventions.Internal
public string RewriteName(string name) =>
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
{
string RewriteName(string name);
}
}

View File

@@ -1,7 +1,7 @@
using System.Globalization;
namespace EFCore.NamingConventions.Internal
{
namespace EFCore.NamingConventions.Internal;
public class LowerCaseNameRewriter : INameRewriter
{
private readonly CultureInfo _culture;
@@ -9,4 +9,3 @@ namespace EFCore.NamingConventions.Internal
public LowerCaseNameRewriter(CultureInfo culture) => _culture = 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.Conventions;
namespace EFCore.NamingConventions.Internal
{
namespace EFCore.NamingConventions.Internal;
public class NameRewritingConvention :
IEntityTypeAddedConvention,
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
{
None,
@@ -9,4 +9,3 @@ namespace EFCore.NamingConventions.Internal
UpperCase,
UpperSnakeCase
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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