Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches: [ master ]

env:
# Stop wasting time caching packages
# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
Expand All @@ -20,45 +20,46 @@ env:
GITHUB_USER: iancooper
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- run: dotnet --info
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: Linux-nuget-${{ hashFiles('**/Directory.Packages.props') }}
restore-keys: |
Linux-nuget-
- name: Build
run: dotnet build -c Release
- name: Core Tests
run: dotnet test -c Release --no-restore --no-build --verbosity d
- name: Upload packages as artifacts
uses: actions/upload-artifact@v4
with:
name: nuget packages
path: "**/*.nupkg"
- name: Push to GitHub Feed
if: ${{ github.event_name != 'pull_request' }}
run: dotnet nuget push **/*.nupkg --source https://nuget.pkg.github.com/${REPOSITORY_OWNER}/index.json --api-key ${GITHUB_TOKEN} --skip-duplicate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_OWNER: ${{ github.repository_owner }}

- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- run: dotnet --info
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: Linux-nuget-${{ hashFiles('**/Directory.Packages.props') }}
restore-keys: |
Linux-nuget-
- name: Install MAUI workloads
run: dotnet workload install maui
- name: Install Required Workloads
run: dotnet workload restore
- name: Build
run: dotnet build ./test/Paramore.Darker.Tests/Paramore.Darker.Tests.csproj -c Release
- name: Core Tests
run: dotnet test ./test/Paramore.Darker.Tests/Paramore.Darker.Tests.csproj -c Release --no-restore --no-build --verbosity d
- name: Upload packages as artifacts
uses: actions/upload-artifact@v4
with:
name: nuget packages
path: "**/*.nupkg"
- name: Push to GitHub Feed
if: ${{ github.event_name != 'pull_request' }}
run: dotnet nuget push **/*.nupkg --source https://nuget.pkg.github.com/${REPOSITORY_OWNER}/index.json --api-key ${GITHUB_TOKEN} --skip-duplicate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_OWNER: ${{ github.repository_owner }}

release:
if: startsWith(github.ref, 'refs/tags')
Expand All @@ -71,5 +72,4 @@ jobs:
with:
name: nuget packages
- name: Push generated package to NuGet
run: dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate

run: dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate
47 changes: 47 additions & 0 deletions Darker.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
appveyor.yml = appveyor.yml
Directory.Build.props = Directory.Build.props
src\Directory.Build.props = src\Directory.Build.props
Directory.Packages.props = Directory.Packages.props
README.md = README.md
Set-Version.psm1 = Set-Version.psm1
EndProjectSection
Expand Down Expand Up @@ -39,6 +40,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Paramore.Darker.Testing.Por
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleMinimalApi", "samples\SampleMinimalApi\SampleMinimalApi.csproj", "{F383C752-9039-494E-9545-5E2555EE9747}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paramore.Darker.Tests.AOT", "test\Paramore.Darker.Tests.AOT\Paramore.Darker.Tests.AOT.csproj", "{9FD661C0-DE31-4FED-A98D-123B476BB3D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleMauiTestApp", "SampleMauiTestApp\SampleMauiTestApp.csproj", "{46919655-7708-45F0-AB90-FD662ED8D4F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paramore.Test.Helpers", "test\Paramore.Test.Helpers\Paramore.Test.Helpers.csproj", "{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -181,6 +188,43 @@ Global
{F383C752-9039-494E-9545-5E2555EE9747}.Release|x64.Build.0 = Release|Any CPU
{F383C752-9039-494E-9545-5E2555EE9747}.Release|x86.ActiveCfg = Release|Any CPU
{F383C752-9039-494E-9545-5E2555EE9747}.Release|x86.Build.0 = Release|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Debug|x64.ActiveCfg = Debug|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Debug|x64.Build.0 = Debug|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Debug|x86.ActiveCfg = Debug|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Debug|x86.Build.0 = Debug|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Release|Any CPU.Build.0 = Release|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Release|x64.ActiveCfg = Release|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Release|x64.Build.0 = Release|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Release|x86.ActiveCfg = Release|Any CPU
{9FD661C0-DE31-4FED-A98D-123B476BB3D8}.Release|x86.Build.0 = Release|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Debug|x64.ActiveCfg = Debug|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Debug|x64.Build.0 = Debug|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Debug|x86.ActiveCfg = Debug|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Debug|x86.Build.0 = Debug|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Release|Any CPU.Build.0 = Release|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Release|x64.ActiveCfg = Release|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Release|x64.Build.0 = Release|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Release|x86.ActiveCfg = Release|Any CPU
{46919655-7708-45F0-AB90-FD662ED8D4F7}.Release|x86.Build.0 = Release|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Debug|x64.ActiveCfg = Debug|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Debug|x64.Build.0 = Debug|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Debug|x86.ActiveCfg = Debug|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Debug|x86.Build.0 = Debug|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Release|Any CPU.Build.0 = Release|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Release|x64.ActiveCfg = Release|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Release|x64.Build.0 = Release|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Release|x86.ActiveCfg = Release|Any CPU
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -197,6 +241,9 @@ Global
{6EB80459-3AE8-4832-BD6F-F0DE5A59337B} = {1D9F464E-31FB-4275-8332-F1083911F830}
{BAE5E3C9-D7A6-4C4C-8291-1141031E4215} = {1D9F464E-31FB-4275-8332-F1083911F830}
{F383C752-9039-494E-9545-5E2555EE9747} = {75225A8D-3180-4D86-9D4D-0E85C8AF7810}
{9FD661C0-DE31-4FED-A98D-123B476BB3D8} = {1D9F464E-31FB-4275-8332-F1083911F830}
{46919655-7708-45F0-AB90-FD662ED8D4F7} = {75225A8D-3180-4D86-9D4D-0E85C8AF7810}
{134B22A6-D079-4FB3-5E89-2F3E6E3FE9F7} = {1D9F464E-31FB-4275-8332-F1083911F830}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88623A3A-C685-437C-B399-435FB5B24FE9}
Expand Down
2 changes: 2 additions & 0 deletions Darker.sln.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/CodeStyle/Naming/CSharpNaming/Abbreviations/=AOT/@EntryIndexedValue">AOT</s:String></wpf:ResourceDictionary>
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
14 changes: 14 additions & 0 deletions SampleMauiTestApp/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SampleMauiTestApp"
x:Class="SampleMauiTestApp.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
15 changes: 15 additions & 0 deletions SampleMauiTestApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SampleMauiTestApp
{
public partial class App : Application
{
public App()
{
InitializeComponent();
}

protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new AppShell());
}
}
}
15 changes: 15 additions & 0 deletions SampleMauiTestApp/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="SampleMauiTestApp.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SampleMauiTestApp"
Shell.FlyoutBehavior="Flyout"
Title="SampleMauiTestApp">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
10 changes: 10 additions & 0 deletions SampleMauiTestApp/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SampleMauiTestApp
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
39 changes: 39 additions & 0 deletions SampleMauiTestApp/DarkerSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Paramore.Darker.Policies;
using Polly;
using Polly.Registry;
using SampleMauiTestApp.Domain;

namespace SampleMauiTestApp;

public class DarkerSettings
{
public const string SomethingWentTerriblyWrongCircuitBreakerName = "SomethingWentTerriblyWrongCircuitBreaker";

public static IPolicyRegistry<string> ConfigurePolicies()
{
var defaultRetryPolicy = Policy
.Handle<Exception>()
.WaitAndRetryAsync(new[]
{
TimeSpan.FromMilliseconds(50),
TimeSpan.FromMilliseconds(100),
TimeSpan.FromMilliseconds(150)
});

var circuitBreakerPolicy = Policy
.Handle<Exception>()
.CircuitBreakerAsync(1, TimeSpan.FromMilliseconds(500));

var circuitBreakTheWorstCaseScenario = Policy
.Handle<SomethingWentTerriblyWrongException>()
.CircuitBreakerAsync(1, TimeSpan.FromSeconds(5));

var policyRegistry = new PolicyRegistry
{
{Constants.RetryPolicyName, defaultRetryPolicy},
{Constants.CircuitBreakerPolicyName, circuitBreakerPolicy},
{SomethingWentTerriblyWrongCircuitBreakerName, circuitBreakTheWorstCaseScenario}
};
return policyRegistry;
}
}
45 changes: 45 additions & 0 deletions SampleMauiTestApp/Domain/PersonRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace SampleMauiTestApp.Domain
{
public sealed class PersonRepository
{
private static readonly IReadOnlyDictionary<int, string> Db = new Dictionary<int, string>
{
{1, "Alan Turing"},
{2, "Donald Knuth"},
{3, "Edsger W. Dijkstra"},
{4, "John von Neumann"},
{5, "Dennis Ritchie"},
{6, "Ken Thompson"},
{7, "Tim Berners-Lee"},
{8, "Claude Shannon"}
};

public async Task<IReadOnlyDictionary<int, string>> GetAll(CancellationToken cancellationToken = new())
{
// fake some io-bound activity. Need to call ConfigureAwait(false) to avoid deadlocks in UI thread.
await FakeSomeActivity(cancellationToken).ConfigureAwait(false);

return Db;
}

public async Task<string> GetNameById(int id, CancellationToken cancellationToken = new())
{
// fake some io-bound activity. Need to call ConfigureAwait(false) to avoid deadlocks in UI thread.
await FakeSomeActivity(cancellationToken).ConfigureAwait(false);

return Db[id];
}

private async Task FakeSomeActivity(CancellationToken cancellationToken = new())
{
var random = new Random();

// fake some io-bound activity. Need to call ConfigureAwait(false) to avoid deadlocks in UI thread.
await Task.Delay(random.Next(50, 150), cancellationToken).ConfigureAwait(false);

// there is a 10% chance that something goes terribly wrong
if (random.NextDouble() < 0.10)
throw new SomethingWentTerriblyWrongException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace SampleMauiTestApp.Domain
{
public sealed class SomethingWentTerriblyWrongException : Exception
Copy link

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding standard exception constructors (e.g. parameterless, message, and inner exception overloads) to improve error reporting and usability.

Copilot uses AI. Check for mistakes.
{
}
}
31 changes: 31 additions & 0 deletions SampleMauiTestApp/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SampleMauiTestApp.MainPage"
Title="Darker Sample Application">

<ScrollView>
<StackLayout Padding="20">
<StackLayout Orientation="Horizontal" Padding="5">
<Entry x:Name="numberEntry"
Placeholder="Enter a ID for Person"
Keyboard="Numeric"
HorizontalOptions="Start"/>
<Label Padding="5" HorizontalOptions="Start"></Label>
<Button Text="Find Person"
Clicked="OnPersonButtonClicked"
HorizontalOptions="Start" />
<Label Padding="5" HorizontalOptions="Start"></Label>
<Button Padding="10, 0" Text="Find All People"
Clicked="OnAllPeopleButtonClicked"
HorizontalOptions="Start" />
</StackLayout>
<Label x:Name="resultLabel"
Text="Result will be displayed here"
Padding="10"
HorizontalOptions="Start"
VerticalOptions="Center" />
</StackLayout>
</ScrollView>

</ContentPage>
Loading
Loading