-
Notifications
You must be signed in to change notification settings - Fork 25
Replace the use of dynamic with Reflection to support AOT #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4d10112
Validation tests for AOT support
SteveBush b0c7bc5
MAUI TestApp
SteveBush 8c98e7a
Update SampleMauiTestApp.csproj
SteveBush 155893d
Remove use of dynamic
SteveBush 22cf26f
Refactor test helper into Paramare.Test.Helpers project. Fix some aw…
SteveBush 8601b93
fix: upgrade to net8 and net9 and fix package dependencies
iancooper 43b8643
chore: update dependencies
iancooper 628accd
Merge branch 'master' into NetworkVisor-dev-removedynamic
iancooper eecf46f
chore: add maui workloads
iancooper 7e9e0fc
chore: update GHA for maui build
iancooper 79340d8
chore: exclude Maui sample from the linux based build
iancooper de64344
chore: remove maui from build path
iancooper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace SampleMauiTestApp | ||
| { | ||
| public partial class AppShell : Shell | ||
| { | ||
| public AppShell() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
SampleMauiTestApp/Domain/SomethingWentTerriblyWrongException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace SampleMauiTestApp.Domain | ||
| { | ||
| public sealed class SomethingWentTerriblyWrongException : Exception | ||
| { | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.