Skip to content

Commit

Permalink
Feature/uplift (#8)
Browse files Browse the repository at this point in the history
* build yaml tweaks

* try quotes

* try different quotes

* remove primary_branch

* Use single quotes

* Remove framework

* upload v4

* All built in actions to v4

* Support Release Candidate branches

* Don't use variable in branch list

* Port to xunit and other package updates

* Fix bad test

* File scoped namespaces

* .NET 8 and latest language

---------

Co-authored-by: Martin Smith <[email protected]>
  • Loading branch information
martinsmith1968 and cb-martinsmith authored Aug 20, 2024
1 parent c158f92 commit e8ae6e7
Show file tree
Hide file tree
Showing 11 changed files with 1,149 additions and 1,051 deletions.
18 changes: 15 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ csharp_style_expression_bodied_accessors = true:none
csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion
csharp_style_pattern_matching_over_as_with_null_check = true : suggestion
csharp_style_inlined_variable_declaration = true : suggestion
csharp_style_throw_expression = true : suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true : suggestion

# Newline settings
Expand All @@ -97,7 +97,7 @@ csharp_indent_labels = flush
csharp_indent_switch_labels = true
csharp_new_line_between_query_expression_clauses = true
csharp_prefer_braces = true:silent
csharp_prefer_simple_default_expression = true : suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = true : suggestion
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
Expand All @@ -114,11 +114,13 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_style_pattern_local_over_anonymous_function = true : suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion


# XML and Config style settings:
Expand Down Expand Up @@ -196,3 +198,13 @@ dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
49 changes: 31 additions & 18 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
name: CI Build
run-name: CIBuild_${{ github.event_name }}_${{ github.ref_name }}_${{ github.run_number }}${{ github.run_attempt }}
run-name: CIBuild_${{ github.event_name }}_${{ github.ref_name }}_${{ github.run_number }}.${{ github.run_attempt }}

env:
PKG_MAJOR_VERSION: '1.1'
PROJECT_NAME: 'DNX.Extensions'
DOTNET_VERSION: 6.0.x
DOTNET_VERSION: 8.0.x
NUGET_VERSION: 5.x
BUILD_CONFIG: Release
BUILD_PLATFORM: Any CPU
PACK_PARAMETERS: ''
NUGET_OUTPUT_FOLDER: nupkgs
BRANCH_RELEASE_CANDIDATE: rc/**

on:
push:
branches:
- main
- 'feature/**'
- 'task/**'
- 'spike/**'
- rc/**
- feature/**
- task/**
- spike/**

pull_request:
branches:
Expand All @@ -26,6 +28,8 @@ on:
workflow_dispatch:

jobs:
##########################################################
## Pipeline Configuration and Setup
setup:
name: Setup Pipeline

Expand All @@ -39,7 +43,7 @@ jobs:
- name: Set Package Suffix
id: package_suffix
run: |
branch='${{ github.ref }}'
branch="${{ github.ref }}"
package_suffix=''
if [ "$branch" != "refs/heads/main" ]
Expand All @@ -57,7 +61,10 @@ jobs:
if [ "${{ github.event_name }}" == "pull_request" ]
then
should_publish=true
elif [ "${{ github.ref }}" == 'refs/heads/main' ]
elif [ "${{ github.ref }}" == "refs/heads/main" ]
then
should_publish=true
elif [[ "${{ github.ref }}" == ${{ env.BRANCH_RELEASE_CANDIDATE }}* ]]
then
should_publish=true
fi
Expand All @@ -83,7 +90,7 @@ jobs:
should_publish: ${{ env.should_publish }}

##########################################################
## Bulid DotNet projects
## Build DotNet projects
build:
name: Build .NET

Expand All @@ -93,21 +100,21 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore NuGet packages
run: dotnet restore

- name: Build
run: dotnet build --configuration ${{ env.BUILD_CONFIG }} /p:"Platform=${{ env.BUILD_PLATFORM }}" /p:"Version=${{ needs.setup.outputs.product_version }}" /p:"AssemblyVersion=${{ needs.setup.outputs.assembly_version }}" --no-restore
run: dotnet build --no-restore --configuration ${{ env.BUILD_CONFIG }} /p:"Platform=${{ env.BUILD_PLATFORM }}" /p:"Version=${{ needs.setup.outputs.product_version }}" /p:"AssemblyVersion=${{ needs.setup.outputs.assembly_version }}"

- name: Test
run: dotnet test --configuration ${{ env.BUILD_CONFIG }} --no-restore --no-build --verbosity normal --collect:"XPlat Code Coverage"
run: dotnet test --no-restore --no-build --configuration ${{ env.BUILD_CONFIG }} --verbosity normal --collect:"XPlat Code Coverage"

- name: Code Coverage Report
uses: irongut/[email protected]
Expand All @@ -133,14 +140,14 @@ jobs:
run: dotnet pack --configuration ${{ env.BUILD_CONFIG }} /p:"Platform=${{ env.BUILD_PLATFORM }}" /p:"PackageVersion=${{ needs.setup.outputs.package_version }}" --no-restore --output "${{ env.NUGET_OUTPUT_FOLDER }}"

- name: Upload Build Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build_output
path: "**/${{ env.PROJECT_NAME }}/bin/${{ env.BUILD_CONFIG }}/**"
if-no-files-found: error

- name: Upload NuGet Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nuget_output
path: "${{ env.NUGET_OUTPUT_FOLDER }}/**"
Expand All @@ -152,13 +159,15 @@ jobs:
name: Create GitHub Release
if: github.ref == 'refs/heads/main' && success()

needs: [setup, build]
needs:
- setup
- build

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build Changelog
id: build_changelog
Expand All @@ -172,6 +181,7 @@ jobs:
tag: v${{ needs.setup.outputs.assembly_version }}
name: Release ${{ needs.setup.outputs.assembly_version }}
body: ${{ steps.build_changelog.outputs.changelog }}
artifacts: '**/*.nupkg'

- name: Tag git
uses: pkgdeps/[email protected]
Expand All @@ -188,7 +198,10 @@ jobs:
name: Publish to NuGet
if: needs.setup.outputs.should_publish == 'true'

needs: [setup, build, release]
needs:
- setup
- build
- release

runs-on: ubuntu-latest

Expand All @@ -201,7 +214,7 @@ jobs:

- name: Download NuGet Output
id: download_nuget
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: nuget_output
path: ${{ env.NUGET_OUTPUT_FOLDER }}
Expand Down
2 changes: 2 additions & 0 deletions src/DNX.Extensions/DNX.Extensions.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<LangVersion>Latest</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>disable</Nullable>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/DNX.Extensions/DNX.Extensions.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<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:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">Latest</s:String></wpf:ResourceDictionary>
51 changes: 25 additions & 26 deletions src/DNX.Extensions/Enumerations/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;

namespace DNX.Extensions.Enumerations
namespace DNX.Extensions.Enumerations;

public static class EnumerableExtensions
{
public static class EnumerableExtensions
/// <summary>
/// Determines whether the specified enumerable has any elements and is not null
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerable">The enumerable.</param>
/// <returns><c>true</c> if the specified enumerable has any elements; otherwise, <c>false</c>.</returns>
/// <remarks>Also available as an extension method</remarks>
public static bool HasAny<T>(this IEnumerable<T> enumerable)
{
/// <summary>
/// Determines whether the specified enumerable has any elements and is not null
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerable">The enumerable.</param>
/// <returns><c>true</c> if the specified enumerable has any elements; otherwise, <c>false</c>.</returns>
/// <remarks>Also available as an extension method</remarks>
public static bool HasAny<T>(this IEnumerable<T> enumerable)
{
return enumerable != null && enumerable.Any();
}
return enumerable != null && enumerable.Any();
}

/// <summary>
/// Determines whether the specified enumerable has any elements that match the predicate and is not null
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerable">The enumerable.</param>
/// <param name="predicate">The predicate.</param>
/// <returns><c>true</c> if the specified predicate has any elements that match the predicate; otherwise, <c>false</c>.</returns>
/// <remarks>Also available as an extension method</remarks>
public static bool HasAny<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
{
return enumerable != null && enumerable.Any(predicate);
}
/// <summary>
/// Determines whether the specified enumerable has any elements that match the predicate and is not null
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerable">The enumerable.</param>
/// <param name="predicate">The predicate.</param>
/// <returns><c>true</c> if the specified predicate has any elements that match the predicate; otherwise, <c>false</c>.</returns>
/// <remarks>Also available as an extension method</remarks>
public static bool HasAny<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
{
return enumerable != null && enumerable.Any(predicate);
}
}
27 changes: 13 additions & 14 deletions src/DNX.Extensions/Strings/SplitDelimiterType.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
namespace DNX.Extensions.Strings
namespace DNX.Extensions.Strings;

/// <summary>
/// How the delimiter is to be treated when splitting text
/// </summary>
public enum SplitDelimiterType
{
/// <summary>
/// How the delimiter is to be treated when splitting text
/// Any specified value can be a delimiter
/// </summary>
public enum SplitDelimiterType
{
/// <summary>
/// Any specified value can be a delimiter
/// </summary>
Any = 0,
Any = 0,

/// <summary>
/// All specified values are the delimiter
/// </summary>
All
}
}
/// <summary>
/// All specified values are the delimiter
/// </summary>
All
}
Loading

0 comments on commit e8ae6e7

Please sign in to comment.