Skip to content

Assembly Conventions

Andrew Best edited this page May 8, 2018 · 5 revisions

Assembly conventions work with the csproj files that comprise a solution. They can be used to enforce project composition specifics, such as ensuring a set of files are always marked as embedded resources.

All assembly conventions derive from AssemblyConventionSpecification

Configuration

Assembly conventions need to know the root path in which to begin searching for the project files they will apply to. To do this, simply set your solution root, and let Conventional do a recursive search from there for the first .sln file it can find

KnownPaths.SolutionRoot = @"c:\projects\MySolutionRoot"

Sample Usage

Strongly typed

typeof(MyType)
	.Assembly
	.MustConformTo(Convention.MustNotReferenceDllsFromTransientOrSdkDirectories)
    .WithFailureAssertion(Assert.Fail);

Pattern matched single assembly

TheAssembly
	.WithNameMatching("MySolution.MyProject")
	.MustConformTo(Convention.MustNotReferenceDllsFromTransientOrSdkDirectories)
    .WithFailureAssertion(Assert.Fail);

Pattern matched multiple assemblies

AllAssemblies
	.WithNamesMatching("*")
	.MustConformTo(Convention.MustNotReferenceDllsFromTransientOrSdkDirectories)
    .WithFailureAssertion(Assert.Fail);

Supplied Assembly Conventions

  • Must not reference dlls from transient or sdk directories
  • Must have all files be embedded resources
  • Must include all matching files in folder