Skip to content

Commit 076dc05

Browse files
authored
Convert to file-scoped namespaces (#575)
+semver:patch
1 parent 0d3e0f8 commit 076dc05

File tree

1,169 files changed

+70003
-71172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,169 files changed

+70003
-71172
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ indent_size = 2
1313
[*.cs]
1414
indent_style = space
1515
indent_size = 4
16+
insert_final_newline = true
17+
18+
csharp_style_namespace_declarations = file_scoped
19+
20+
dotnet_diagnostic.IDE0161.severity = warning
1621

1722
[*.cake]
1823
indent_style = space
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
using FluentNHibernate.Conventions;
22
using FluentNHibernate.Conventions.Instances;
33

4-
namespace Examples.FirstAutomappedProject
4+
namespace Examples.FirstAutomappedProject;
5+
6+
/// <summary>
7+
/// This is a convention that will be applied to all entities in your application. What this particular
8+
/// convention does is to specify that many-to-one, one-to-many, and many-to-many relationships will all
9+
/// have their Cascade option set to All.
10+
/// </summary>
11+
class CascadeConvention : IReferenceConvention, IHasManyConvention, IHasManyToManyConvention
512
{
6-
/// <summary>
7-
/// This is a convention that will be applied to all entities in your application. What this particular
8-
/// convention does is to specify that many-to-one, one-to-many, and many-to-many relationships will all
9-
/// have their Cascade option set to All.
10-
/// </summary>
11-
class CascadeConvention : IReferenceConvention, IHasManyConvention, IHasManyToManyConvention
13+
public void Apply(IManyToOneInstance instance)
1214
{
13-
public void Apply(IManyToOneInstance instance)
14-
{
15-
instance.Cascade.All();
16-
}
15+
instance.Cascade.All();
16+
}
1717

18-
public void Apply(IOneToManyCollectionInstance instance)
19-
{
20-
instance.Cascade.All();
21-
}
18+
public void Apply(IOneToManyCollectionInstance instance)
19+
{
20+
instance.Cascade.All();
21+
}
2222

23-
public void Apply(IManyToManyCollectionInstance instance)
24-
{
25-
instance.Cascade.All();
26-
}
23+
public void Apply(IManyToManyCollectionInstance instance)
24+
{
25+
instance.Cascade.All();
2726
}
28-
}
27+
}
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
namespace Examples.FirstAutomappedProject.Entities
1+
namespace Examples.FirstAutomappedProject.Entities;
2+
3+
public class Employee
24
{
3-
public class Employee
4-
{
5-
public virtual int Id { get; protected set; }
6-
public virtual string FirstName { get; set; }
7-
public virtual string LastName { get; set; }
8-
public virtual Store Store { get; set; }
9-
}
10-
}
5+
public virtual int Id { get; protected set; }
6+
public virtual string FirstName { get; set; }
7+
public virtual string LastName { get; set; }
8+
public virtual Store Store { get; set; }
9+
}
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
namespace Examples.FirstAutomappedProject.Entities
1+
namespace Examples.FirstAutomappedProject.Entities;
2+
3+
public class Location
24
{
3-
public class Location
4-
{
5-
public virtual int Aisle { get; set; }
6-
public virtual int Shelf { get; set; }
7-
}
8-
}
5+
public virtual int Aisle { get; set; }
6+
public virtual int Shelf { get; set; }
7+
}
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
using System.Collections.Generic;
22

3-
namespace Examples.FirstAutomappedProject.Entities
3+
namespace Examples.FirstAutomappedProject.Entities;
4+
5+
public class Product
46
{
5-
public class Product
6-
{
7-
public virtual int Id { get; protected set; }
8-
public virtual string Name { get; set; }
9-
public virtual double Price { get; set; }
10-
public virtual Location Location { get; set; }
11-
public virtual IList<Store> StoresStockedIn { get; set; }
7+
public virtual int Id { get; protected set; }
8+
public virtual string Name { get; set; }
9+
public virtual double Price { get; set; }
10+
public virtual Location Location { get; set; }
11+
public virtual IList<Store> StoresStockedIn { get; set; }
1212

13-
public Product()
14-
{
15-
StoresStockedIn = new List<Store>();
16-
}
13+
public Product()
14+
{
15+
StoresStockedIn = new List<Store>();
1716
}
18-
}
17+
}
Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
using System.Collections.Generic;
22

3-
namespace Examples.FirstAutomappedProject.Entities
3+
namespace Examples.FirstAutomappedProject.Entities;
4+
5+
public class Store
46
{
5-
public class Store
6-
{
7-
public virtual int Id { get; protected set; }
8-
public virtual string Name { get; set; }
9-
public virtual IList<Product> Products { get; set; }
10-
public virtual IList<Employee> Staff { get; set; }
7+
public virtual int Id { get; protected set; }
8+
public virtual string Name { get; set; }
9+
public virtual IList<Product> Products { get; set; }
10+
public virtual IList<Employee> Staff { get; set; }
1111

12-
public Store()
13-
{
14-
Products = new List<Product>();
15-
Staff = new List<Employee>();
16-
}
12+
public Store()
13+
{
14+
Products = new List<Product>();
15+
Staff = new List<Employee>();
16+
}
1717

18-
public virtual void AddProduct(Product product)
19-
{
20-
product.StoresStockedIn.Add(this);
21-
Products.Add(product);
22-
}
18+
public virtual void AddProduct(Product product)
19+
{
20+
product.StoresStockedIn.Add(this);
21+
Products.Add(product);
22+
}
2323

24-
public virtual void AddEmployee(Employee employee)
25-
{
26-
employee.Store = this;
27-
Staff.Add(employee);
28-
}
24+
public virtual void AddEmployee(Employee employee)
25+
{
26+
employee.Store = this;
27+
Staff.Add(employee);
2928
}
30-
}
29+
}

src/Examples.FirstAutomappedProject/ExampleAutomappingConfiguration.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@
22
using Examples.FirstAutomappedProject.Entities;
33
using FluentNHibernate.Automapping;
44

5-
namespace Examples.FirstAutomappedProject
5+
namespace Examples.FirstAutomappedProject;
6+
7+
/// <summary>
8+
/// This is an example automapping configuration. You should create your own that either
9+
/// implements IAutomappingConfiguration directly, or inherits from DefaultAutomappingConfiguration.
10+
/// Overriding methods in this class will alter how the automapper behaves.
11+
/// </summary>
12+
class ExampleAutomappingConfiguration : DefaultAutomappingConfiguration
613
{
7-
/// <summary>
8-
/// This is an example automapping configuration. You should create your own that either
9-
/// implements IAutomappingConfiguration directly, or inherits from DefaultAutomappingConfiguration.
10-
/// Overriding methods in this class will alter how the automapper behaves.
11-
/// </summary>
12-
class ExampleAutomappingConfiguration : DefaultAutomappingConfiguration
14+
public override bool ShouldMap(Type type)
1315
{
14-
public override bool ShouldMap(Type type)
15-
{
16-
// specify the criteria that types must meet in order to be mapped
17-
// any type for which this method returns false will not be mapped.
18-
return type.Namespace == "Examples.FirstAutomappedProject.Entities";
19-
}
16+
// specify the criteria that types must meet in order to be mapped
17+
// any type for which this method returns false will not be mapped.
18+
return type.Namespace == "Examples.FirstAutomappedProject.Entities";
19+
}
2020

21-
public override bool IsComponent(Type type)
22-
{
23-
// override this method to specify which types should be treated as components
24-
// if you have a large list of types, you should consider maintaining a list of them
25-
// somewhere or using some form of conventional and/or attribute design
26-
return type == typeof(Location);
27-
}
21+
public override bool IsComponent(Type type)
22+
{
23+
// override this method to specify which types should be treated as components
24+
// if you have a large list of types, you should consider maintaining a list of them
25+
// somewhere or using some form of conventional and/or attribute design
26+
return type == typeof(Location);
2827
}
29-
}
28+
}

0 commit comments

Comments
 (0)