Skip to content

Commit

Permalink
Merge pull request #53 from cake-contrib/release/0.5.0
Browse files Browse the repository at this point in the history
Release/0.5.0
  • Loading branch information
nils-a committed Oct 27, 2020
2 parents a5549e2 + 610f8a7 commit f50419d
Show file tree
Hide file tree
Showing 22 changed files with 712 additions and 27 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/dependabot-cake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Run dependabot for cake
on:
workflow_dispatch:
schedule:
# run everyday at 6
- cron: '0 6 * * *'

jobs:
dependabot-cake:
runs-on: ubuntu-latest # linux, because this is a docker-action
steps:
- name: check/update cake dependencies
uses: nils-org/dependabot-cake-action@v1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ docs/input/tasks/*

# Wyam related
config.wyam.*

# JetBrains Rider
.idea/
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ To have consistency in code-style among the different tools/plugins the use of A

Example-Files can be found at:

* [`stylecop.json`](./examples/StyleCopJson.md)
* [`.editorconfig`](./examples/Editorconfig.md)
* [`stylecop.json`](./examples/StyleCopJson)
* [`.editorconfig`](./examples/Editorconfig)

## Related rules

Expand Down
55 changes: 55 additions & 0 deletions docs/input/guidelines/TargetFramework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
Order: 4
Title: Target Frameworks
---

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Goals](#goals)
- [Required / Suggested versions](#required--suggested-versions)
- [Related rules](#related-rules)
- [Usage](#usage)
- [Settings](#settings)
- [Opt-Out](#opt-out)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Goals

As .NET Framework < 4.7.2 has issues with running .NET Standard assemblies, and Cake itself can run on .NET Framework 4.6.1 it is suggested to multi-target addins to `netstandard2.0` and `net461` to have the maximum compatibility.

### Required / Suggested versions

Depending on the referenced `Cake.Core`-version different target versions are required and/or suggested.
Missing a required target version will raise [CCG0007](../rules/ccg0007) as an error
while missing a suggested target version will raise [CCG0007](../rules/ccg0007) as a warning.

* Cake.Core <= 0.33.0
* Required: `netstandard2.0`
* Suggested: `net461`
* alternative: `net46`

## Related rules

* [CCG0007](../rules/ccg0007)

## Usage

Using this package automatically enables this guideline.

## Settings

### Opt-Out

It it possible to opt-out of the check for target framework using the following setting:

(*Keep in mind, though that it is not recommended to opt-out of this feature*)

```xml
<ItemGroup>
<CakeContribGuidelinesOmitTargetFramework Include="netstandard2.0" />
<CakeContribGuidelinesOmitTargetFramework Include="net461" />
</ItemGroup>
```
13 changes: 6 additions & 7 deletions docs/input/rules/ccg0006.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Title: CCG0006
Description: Missing recommended configuraion-file
---

> No reference to `.editorconfig` found. Usage of `.editorconfig` is strongly recommended.
> No reference to `[fileName]` found. Usage of `[fileName]` is strongly recommended.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
Expand All @@ -23,20 +23,19 @@ This warning is raised, when a recommended configuration-file (i.e. `stylecop.js

## Description

Code-Formatting and layout should be properly configured. This is done using
blah and blah.
Code-Formatting and layout should be properly configured. This is done using `.editorconfig` and `stylecop.json`.

## How to fix violations

Add a balh and blah to the project.
Add the required files to the project.

Example-Files can be found at:

* [`stylecop.json`](../guidelines/examples/StyleCopJson.md)
* [`.editorconfig`](../guidelines/examples/Editorconfig.md)
* [`stylecop.json`](../guidelines/examples/StyleCopJson)
* [`.editorconfig`](../guidelines/examples/Editorconfig)

(Or opt-out of this rule, by setting `CakeContribGuidelinesOmitRecommendedConfigFile`)

## Related guidelines

* [Usage of Analysers](../guidelines/Analysers)
* [Recommended References](../guidelines/RecommendedReferences)
43 changes: 43 additions & 0 deletions docs/input/rules/ccg0007.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
Order: 7
Title: CCG0007
Description: Missing recommended target
---

> Missing required target: netstandard2.0
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Cause](#cause)
- [Description](#description)
- [How to fix violations](#how-to-fix-violations)
- [Related guidelines](#related-guidelines)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Cause

This warning is raised, when the addin is not targeted to a recommended target version.
Also, This could be raised as an error, if a required target version is not set.

## Description

Addins should be multi-targeted to `netstandard2.0` and `net461` to have the maximum compatibility.

## How to fix violations

Add the recommended target(s) to the project:

```xml
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
</PropertyGroup>
```

(Or opt-out of this rule, by setting `CakeContribGuidelinesOmitTargetFramework`)

## Related guidelines

* [Target Frameworks](../guidelines/TargetFramework)
2 changes: 1 addition & 1 deletion recipe.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#load nuget:?package=Cake.Recipe&version=2.0.0
#load nuget:?package=Cake.Recipe&version=2.0.1

Environment.SetVariableNames();

Expand Down
6 changes: 6 additions & 0 deletions src/CakeContrib.Guidelines.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
1 change: 1 addition & 0 deletions src/Guidelines/build/CakeContrib.Guidelines.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<Import Project="$(MSBuildThisFileDirectory)PrivateAssets.targets" />
<Import Project="$(MSBuildThisFileDirectory)RequiredReferences.targets" />
<Import Project="$(MSBuildThisFileDirectory)RequiredFiles.targets" />
<Import Project="$(MSBuildThisFileDirectory)TargetFrameworkVersions.targets" />
</Project>
21 changes: 21 additions & 0 deletions src/Guidelines/build/TargetFrameworkVersions.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<UsingTask
TaskName="$(CakeContribGuidelinesCustomTasksNamespace).TargetFrameworkVersions"
AssemblyFile="$(CakeContribGuidelinesCustomTasksAssembly)" />

<Target
Name="_CheckTargetFrameworkVersions"
AfterTargets="BeforeBuild"
BeforeTargets="CoreBuild">
<!-- All other rules have some "configuration" here, this rules required/suggested targets are hard-coded in the task. Sadly. -->

<TargetFrameworkVersions
References="@(Reference)"
TargetFramework="$(TargetFramework)"
TargetFrameworks="$(TargetFrameworks)"
Omitted="@(CakeContribGuidelinesOmitTargetFramework)"
ProjectFile="$(MSBuildProjectFullPath)" />
</Target>
</Project>
34 changes: 32 additions & 2 deletions src/Tasks.IntegrationTests/E2eTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.IO;

using CakeContrib.Guidelines.Tasks.Tests.Fixtures;
using CakeContrib.Guidelines.Tasks.IntegrationTests.Fixtures;

using FluentAssertions;

using Xunit;
using Xunit.Abstractions;

namespace CakeContrib.Guidelines.Tasks.Tests
namespace CakeContrib.Guidelines.Tasks.IntegrationTests
{
// TODO: Writing things to disk is not deterministic...
// TODO: Running Code-Coverage on the integration-tests breaks all tests
Expand Down Expand Up @@ -194,5 +194,35 @@ public void Missing_file_editorconfig_results_in_CCG0006_warning()
result.WarningLines.Should().Contain(l => l.IndexOf("CCG0006", StringComparison.Ordinal) > -1);
result.WarningLines.Should().Contain(l => l.IndexOf(".editorconfig", StringComparison.Ordinal) > -1);
}

[Fact]
public void Missing_Required_Target_results_in_CCG0007_error()
{
// given
fixture.WithTargetFrameworks("net47");

// when
var result = fixture.Run();

// then
result.IsErrorExitCode.Should().BeTrue();
result.ErrorLines.Should().Contain(l => l.IndexOf("CCG0007", StringComparison.Ordinal) > -1);
result.ErrorLines.Should().Contain(l => l.IndexOf("netstandard2.0", StringComparison.Ordinal) > -1);
}

[Fact]
public void Missing_Suggested_Target_results_in_CCG0007_warning()
{
// given
fixture.WithTargetFrameworks("netstandard2.0");

// when
var result = fixture.Run();

// then
result.IsErrorExitCode.Should().BeFalse();
result.WarningLines.Should().Contain(l => l.IndexOf("CCG0007", StringComparison.Ordinal) > -1);
result.WarningLines.Should().Contain(l => l.IndexOf("net461", StringComparison.Ordinal) > -1);
}
}
}
15 changes: 11 additions & 4 deletions src/Tasks.IntegrationTests/Fixtures/E2eTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using Xunit.Abstractions;

namespace CakeContrib.Guidelines.Tasks.Tests.Fixtures
namespace CakeContrib.Guidelines.Tasks.IntegrationTests.Fixtures
{
public class E2eTestFixture : IDisposable
{
Expand All @@ -18,7 +18,8 @@ public class E2eTestFixture : IDisposable
private bool hasStylecopJson = true;
private bool hasStylecopReference = true;
private bool hasEditorConfig = true;
private List<string> customContent = new List<string>();
private readonly List<string> customContent = new List<string>();
private string targetFrameworks = "netstandard2.0;net461";

public E2eTestFixture(string tempFolder, ITestOutputHelper logger)
{
Expand All @@ -41,7 +42,7 @@ private string WriteProject()
<Import Project=""{0}"" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>{5}</TargetFrameworks>
{2}
</PropertyGroup>
Expand Down Expand Up @@ -95,7 +96,8 @@ private string WriteProject()
targets.Item2,
string.Join(Environment.NewLine, properties),
string.Join(Environment.NewLine, items),
string.Join(Environment.NewLine, customContent)));
string.Join(Environment.NewLine, customContent),
targetFrameworks));

return csproj;
}
Expand Down Expand Up @@ -135,6 +137,11 @@ internal void WithoutFileEditorconfig()
hasEditorConfig = false;
}

internal void WithTargetFrameworks(string targetFrameworks)
{
this.targetFrameworks = targetFrameworks;
}

private Tuple<string, string> GetTargetsToImport()
{
var codeBase = typeof(E2eTestFixture).Assembly.CodeBase;
Expand Down
3 changes: 1 addition & 2 deletions src/Tasks.IntegrationTests/Tasks.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.14.6" />
<PackageReference Include="Moq" Version="4.14.7" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="12.2.1" />
<PackageReference Include="Text.Analyzers" Version="2.6.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks.Tests/CheckPrivateAssetsOnReferencesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Should_Error_If_Package_Has_Not_PrivateAssets()
{
// given
var fixture = new CheckPrivateAssetsOnReferencesFixture();
fixture.WithReferencedPackage("Cake.Core", "");
fixture.WithReferencedPackage("Cake.Core");
fixture.WithPackageToCheck("Cake.Core");

// when
Expand All @@ -60,7 +60,7 @@ public void Should_Log_Correct_ErrorCode_On_Error()
{
// given
var fixture = new CheckPrivateAssetsOnReferencesFixture();
fixture.WithReferencedPackage("Cake.Core", "");
fixture.WithReferencedPackage("Cake.Core");
fixture.WithPackageToCheck("Cake.Core");

// when
Expand All @@ -78,7 +78,7 @@ public void Should_Log_Correct_ErrorSourceFile_On_Error_With_Given_ProjectFile()
// given
const string projectFileName = "some.project.csproj";
var fixture = new CheckPrivateAssetsOnReferencesFixture();
fixture.WithReferencedPackage("Cake.Core", "");
fixture.WithReferencedPackage("Cake.Core");
fixture.WithPackageToCheck("Cake.Core");
fixture.WithProjectFile(projectFileName);

Expand Down
Loading

0 comments on commit f50419d

Please sign in to comment.