Created
May 24, 2012 14:38
-
-
Save anonymous/2781949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <Name>UI layer shouldn't use directly DB types</Name> | |
warnif count > 0 | |
// UI layer is made of types in namespaces using a UI framework | |
let uiTypes = Application.Namespaces.UsingAny( | |
Assemblies.WithNameIn("PresentationFramework", "System.Windows", | |
"System.Windows.Forms", "System.Web") | |
).ChildTypes() | |
// You can easily customize this line to define what are DB types. | |
let dbTypes = ThirdParty.Assemblies.WithNameIn("System.Data", "EntityFramework", | |
"NHibernate").ChildTypes() | |
// Ideally even DataSet and associated, usage should be forbidden from UI layer: | |
// http://stackoverflow.com/questions/1708690/is-list-better-than-dataset-for-ui-layer-in-asp-net | |
.Except(Types.WithNameIn("DataSet", "DataTable", "DataRow")) | |
from uiType in uiTypes.UsingAny(dbTypes) | |
let dbTypesUsed = dbTypes.Intersect(uiType.TypesUsed) | |
select new { uiType, dbTypesUsed } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment