Skip to content

How to Contribute and Build

Kenny Pflug edited this page Aug 6, 2018 · 13 revisions

You thought of an assertion that you'd like to add to Light.GuardClauses? That's awesome! Here is how you can add your ideas to the project:

  1. Create an issue: before doing anything else, please create an issue where you describe what you have in mind. This way you and I can discuss and coordinate the implementation of your idea.
  2. Get the source code: fork and clone the repository. Get accustomed to the way Light.GuardClauses is structured and how the functional and performance tests are written.
  3. Create a branch for each feature: besides the actual implementation, each feature should be tested functionally (in the Light.GuardClauses.Tests project) and performance-wise (in the Light.GuardClauses.Performance project).
  4. Send me a pull request for each feature: please keep your pull requests as small as possible. Don't put two or more features in the same pull request. I think small pull requests take considerably less time to evaluate.

And that's it - I hope to see a lot of feedback and PRs from you! Let's get into the nitty-gritty details of setting your machine up.

Building the source code

Visual Studio and MSBuild

Light.GuardClauses uses the MSBuild 15 csproj format that allows multi-targeting different framework versions. Thus you should have a version of Visual Studio or MSBuild that supports this "new" csproj format (15.6 or later). Personally, I encourage you to use the latest RTM version of VS / MSBuild as this is normally the one that I use myself.

Overview of the different projects

The source code contains two solution (sln) files that hold a different amount of projects: Light.GuardClauses.sln only contains the production code (Light.GuardClauses.csproj) as well as the functional test project (Light.GuardClauses.Tests.csproj). The second solution Light.GuardClauses.AllProjects contains four additional projects: the performance test project (Light.GuardClauses.Performance.csproj), two analyzer projects that are used to check XML comments, as well as a small unit test project specifically for .NET 3.5 Compact Framework.

Here is a small listing of the different projects:

  • Light.GuardClauses: contains the actual production code. Is built against the following frameworks: netstandard2.0;netstandard1.0;net45;net40;sl5;net35;net35-cf
  • Light.GuardClauses.Tests: contains the functional tests for the production code. Based on xUnit.net and FluentAssertions. Is built against the following frameworks: netcoreapp2.1;netcoreapp1.1;net47
  • Light.GuardClauses.Performance: contains performance tests using Benchmark.NET. Built against netcoreapp2.1;net47.
  • Light.GuardClauses.Tests.Net35CompactFramework: contains functional tests especially for the .NET 3.5 Compact Framework. Based on Nunit3 CF. Built against net35-cf.
  • Light.GuardClauses.InternalRoslynAnalyzers: contains analyzers that check if some of the XML comments are always structured in the same way. Built against netstandard2.0.
  • Light.GuardClauses.InternalRoslynAnalyzers.Tests: contains functional tests for the analyzers. Built against netcoreapp2.1.

Changing the TargetFrameworks for your local development machine

Light.GuardClauses supports a wide range of .NET framework versions. Some of these might not be present on your local development machine (especially the more exotic ones like old .NET versions or Silverlight 5). You can customize which target frameworks should be used for the Light.GuardClauses.csproj and Light.GuardClauses.Tests.csproj projects.

To achive that, create a text file named TargetFrameworks.props that resides alongside the corresponding csproj file, just like this:

Example of TargetFramework.props

In this file, you can specify which TargetFrameworks should be used like this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
      <TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
  </PropertyGroup>
</Project>

Be careful: Light.GuardClauses only supports the mentioned frameworks in the list above. If you use any other target frameworks that are not listed, there is no guarantee that the source code will compile.

Clone this wiki locally