diff --git a/.claude/agents/developer.md b/.claude/agents/developer.md index 4ea599e..5b2199a 100644 --- a/.claude/agents/developer.md +++ b/.claude/agents/developer.md @@ -1,6 +1,6 @@ --- name: developer -model: haiku +model: sonnet color: green description: > Writes minimal production code to make failing tests pass (TDD Green phase) @@ -26,8 +26,9 @@ You will receive: - Follow existing patterns (file-scoped namespaces, `readonly struct` where appropriate) - New or changed `public` API in non-test projects must be declared in `PublicAPI.Unshipped.txt` (enforced by RS0016 — the error includes the exact signature to copy) 5. Run `dotnet build src/ 2>&1 | grep -E 'warning (IDE|CS)'` — fix **all** warnings. Common culprits: block-scoped namespace, `var`, missing braces, `new T()` instead of `new()`. -6. Run `dotnet test src/ --filter "FullyQualifiedName~"` — all targeted tests must pass. -7. Run `dotnet test src/` — no regressions. +6. Run `dotnet format --include --exclude-diagnostics IDE0130` for all changed `.cs` and fix any incorrect formatting. +7. Run `dotnet test src/ --filter "FullyQualifiedName~"` — all targeted tests must pass. +8. Run `dotnet test src/` — no regressions. ## Code Style Quick Reference @@ -59,3 +60,4 @@ Report: - Implement only what the tests demand — resist anticipating future tests - Do not add `public` API surface beyond what the tests reference - If a reviewer FIX_IMPLEMENTATION verdict was provided, address each finding while keeping all tests green +- Prefer one type (class, record, interface etc) per file diff --git a/.claude/agents/reviewer.md b/.claude/agents/reviewer.md index 2a8e9ef..90803c3 100644 --- a/.claude/agents/reviewer.md +++ b/.claude/agents/reviewer.md @@ -1,6 +1,6 @@ --- name: reviewer -model: haiku +model: sonnet color: blue description: > Read-only code quality reviewer for the Conjecture .NET project. @@ -19,6 +19,11 @@ You will receive one or more of: - Test results from the preceding Green phase - Reviewer findings from a previous iteration (if this is a loop retry) +## Steps + +1. Run `dotnet format --include --exclude-diagnostics IDE0130 --verify-no-changes` for all changed `.cs` files — all formatting must be correct. If this fails, report it as a FIX_IMPLEMENTATION finding. +2. Review the changed production files for reuse, quality, and efficiency issues (see "What to look for" section below). + ## Output format Always end your response with a structured verdict block: @@ -51,6 +56,9 @@ If there are both implementation issues and missing tests, pick the one that is - Leaky abstractions (exposing internals, breaking encapsulation) - Unnecessary comments (explaining WHAT, not WHY — flag for removal) - Stringly-typed code where constants or enums already exist +- Unneccassary warning suppression +- One file per type unless they are nested +- One test class per SUT or feature ### Efficiency - Unnecessary repeated work or redundant computations diff --git a/.claude/agents/test-developer.md b/.claude/agents/test-developer.md index 768155e..7147b78 100644 --- a/.claude/agents/test-developer.md +++ b/.claude/agents/test-developer.md @@ -30,7 +30,8 @@ You will receive: - Follow code style: file-scoped namespaces, no `var`, braces on all control flow, `new()` when type is apparent 4. If given a reviewer ADD_TEST verdict, add the missing tests the reviewer identified. 5. Run `dotnet build src/ 2>&1 | grep -E 'warning (IDE|CS)'` — fix any style warnings in the test file itself. -6. Run `dotnet build src/` — must fail (missing production types) or tests must fail. If green, the tests cover nothing new; revise them. +6. Run `dotnet format --include --exclude-diagnostics IDE0130` for all changed `.cs` and fix any incorrect formatting. +7. Run `dotnet build src/` — must fail (missing production types) or tests must fail. If green, the tests cover nothing new; revise them. ## Output @@ -46,3 +47,5 @@ Report: - Prefer `Assert.Equal` / `Assert.True` over `Assert.NotNull` unless null-safety is the behavior under test - Avoid mocking framework internals; test at the public API surface - Match production namespace with `.Tests` appended +- Prefer one test class per file +- Prefer one test class per subject under test diff --git a/.editorconfig b/.editorconfig index 19d803f..ec94750 100644 --- a/.editorconfig +++ b/.editorconfig @@ -88,55 +88,56 @@ dotnet_code_quality_unused_parameters = all:suggestion dotnet_remove_unnecessary_suppression_exclusions = none # Enforce naming rules at build time (requires EnforceCodeStyleInBuild=true in Directory.Build.props) -dotnet_diagnostic.IDE0073.severity = warning # File header -dotnet_diagnostic.IDE1006.severity = warning +dotnet_diagnostic.IDE0073.severity = error # File header +dotnet_diagnostic.IDE1006.severity = error # Enforce suggestion-level rules at build time -dotnet_diagnostic.IDE0011.severity = warning # Braces -dotnet_diagnostic.IDE0016.severity = warning # Throw expressions -dotnet_diagnostic.IDE0017.severity = warning # Object initializers -dotnet_diagnostic.IDE0018.severity = warning # Inlined variable declaration -dotnet_diagnostic.IDE0019.severity = warning # Pattern matching over as+null check -dotnet_diagnostic.IDE0020.severity = warning # Pattern matching over is+cast -dotnet_diagnostic.IDE0028.severity = warning # Collection initializers -dotnet_diagnostic.IDE0029.severity = warning # Null coalescing (non-nullable) -dotnet_diagnostic.IDE0030.severity = warning # Null coalescing (nullable) -dotnet_diagnostic.IDE0031.severity = warning # Null propagation -dotnet_diagnostic.IDE0032.severity = warning # Auto properties -dotnet_diagnostic.IDE0033.severity = warning # Explicit tuple names -dotnet_diagnostic.IDE0034.severity = warning # Simple default expression -dotnet_diagnostic.IDE0036.severity = warning # Modifier order -dotnet_diagnostic.IDE0037.severity = warning # Inferred tuple/anon type member names -dotnet_diagnostic.IDE0039.severity = warning # Local function over lambda -dotnet_diagnostic.IDE0041.severity = warning # Null check over reference equality -dotnet_diagnostic.IDE0042.severity = warning # Deconstructed variable declaration -dotnet_diagnostic.IDE0045.severity = warning # Ternary over assignment -dotnet_diagnostic.IDE0046.severity = warning # Ternary over return -dotnet_diagnostic.IDE0053.severity = warning # Expression-bodied lambdas -dotnet_diagnostic.IDE0054.severity = warning # Compound assignment -dotnet_diagnostic.IDE0056.severity = warning # Index operator -dotnet_diagnostic.IDE0057.severity = warning # Range operator -dotnet_diagnostic.IDE0059.severity = warning # Unused value assignment -dotnet_diagnostic.IDE0060.severity = warning # Unused parameters -dotnet_diagnostic.IDE0063.severity = warning # Simple using statement -dotnet_diagnostic.IDE0066.severity = warning # Switch expression -dotnet_diagnostic.IDE0071.severity = warning # Simplified interpolation -dotnet_diagnostic.IDE0074.severity = warning # Coalesce compound assignment -dotnet_diagnostic.IDE0075.severity = warning # Simplified boolean expressions -dotnet_diagnostic.IDE0083.severity = warning # not pattern -dotnet_diagnostic.IDE0090.severity = warning # Implicit object creation -dotnet_diagnostic.IDE0130.severity = warning # Namespace matches folder -dotnet_diagnostic.IDE0150.severity = warning # Null check over type check -dotnet_diagnostic.IDE0160.severity = warning # File-scoped namespace -dotnet_diagnostic.IDE0170.severity = warning # Extended property pattern -dotnet_diagnostic.IDE0180.severity = warning # Tuple swap -dotnet_diagnostic.IDE0220.severity = warning # Foreach explicit cast -dotnet_diagnostic.IDE0230.severity = warning # UTF-8 string literals -dotnet_diagnostic.IDE0250.severity = warning # Readonly struct -dotnet_diagnostic.IDE0251.severity = warning # Readonly struct member -dotnet_diagnostic.IDE0258.severity = warning # Static anonymous function -dotnet_diagnostic.IDE0290.severity = warning # Primary constructors -dotnet_diagnostic.IDE1005.severity = warning # Conditional delegate call +dotnet_diagnostic.IDE0011.severity = error # Braces +dotnet_diagnostic.IDE0016.severity = error # Throw expressions +dotnet_diagnostic.IDE0017.severity = error # Object initializers +dotnet_diagnostic.IDE0018.severity = error # Inlined variable declaration +dotnet_diagnostic.IDE0019.severity = error # Pattern matching over as+null check +dotnet_diagnostic.IDE0020.severity = error # Pattern matching over is+cast +dotnet_diagnostic.IDE0028.severity = error # Collection initializers +dotnet_diagnostic.IDE0029.severity = error # Null coalescing (non-nullable) +dotnet_diagnostic.IDE0030.severity = error # Null coalescing (nullable) +dotnet_diagnostic.IDE0031.severity = error # Null propagation +dotnet_diagnostic.IDE0032.severity = error # Auto properties +dotnet_diagnostic.IDE0033.severity = error # Explicit tuple names +dotnet_diagnostic.IDE0034.severity = error # Simple default expression +dotnet_diagnostic.IDE0036.severity = error # Modifier order +dotnet_diagnostic.IDE0037.severity = error # Inferred tuple/anon type member names +dotnet_diagnostic.IDE0039.severity = error # Local function over lambda +dotnet_diagnostic.IDE0041.severity = error # Null check over reference equality +dotnet_diagnostic.IDE0042.severity = error # Deconstructed variable declaration +dotnet_diagnostic.IDE0045.severity = error # Ternary over assignment +dotnet_diagnostic.IDE0046.severity = error # Ternary over return +dotnet_diagnostic.IDE0053.severity = error # Expression-bodied lambdas +dotnet_diagnostic.IDE0054.severity = error # Compound assignment +dotnet_diagnostic.IDE0056.severity = error # Index operator +dotnet_diagnostic.IDE0057.severity = error # Range operator +dotnet_diagnostic.IDE0059.severity = error # Unused value assignment +dotnet_diagnostic.IDE0060.severity = error # Unused parameters +dotnet_diagnostic.IDE0063.severity = error # Simple using statement +dotnet_diagnostic.IDE0066.severity = error # Switch expression +dotnet_diagnostic.IDE0071.severity = error # Simplified interpolation +dotnet_diagnostic.IDE0074.severity = error # Coalesce compound assignment +dotnet_diagnostic.IDE0075.severity = error # Simplified boolean expressions +dotnet_diagnostic.IDE0079.severity = error # Remove unneccessary exclusions +dotnet_diagnostic.IDE0083.severity = error # not pattern +dotnet_diagnostic.IDE0090.severity = error # Implicit object creation +dotnet_diagnostic.IDE0130.severity = none # Disabled: conflicts with dotnet format (GitHub issue dotnet/format#2192) +dotnet_diagnostic.IDE0150.severity = error # Null check over type check +dotnet_diagnostic.IDE0160.severity = error # File-scoped namespace +dotnet_diagnostic.IDE0170.severity = error # Extended property pattern +dotnet_diagnostic.IDE0180.severity = error # Tuple swap +dotnet_diagnostic.IDE0220.severity = error # Foreach explicit cast +dotnet_diagnostic.IDE0230.severity = error # UTF-8 string literals +dotnet_diagnostic.IDE0250.severity = error # Readonly struct +dotnet_diagnostic.IDE0251.severity = error # Readonly struct member +dotnet_diagnostic.IDE0258.severity = error # Static anonymous function +dotnet_diagnostic.IDE0290.severity = error # Primary constructors +dotnet_diagnostic.IDE1005.severity = error # Conditional delegate call #### C# Coding Conventions #### [*.cs] diff --git a/CLAUDE.MD b/CLAUDE.MD index 3706d07..5d1952f 100644 --- a/CLAUDE.MD +++ b/CLAUDE.MD @@ -10,9 +10,16 @@ dotnet build src/ dotnet test src/ dotnet test src/ --filter "FullyQualifiedName~SomeTest" ``` +## Format + +```bash +dotnet format src/ --include .somedir/somefile.cs .somedir/somefile2.cs +``` ## Project Structure +Solution file: `src/Conjecture.slnx` + ### Production → Test project mapping | Production project | Test project | @@ -34,5 +41,6 @@ New test files go in the paired test project, mirroring the production file's re ### Other locations - Architecture decisions (ADRs): `docs/decisions/` +- Documentation site: `docs/site` - Public API surface: each non-test project has `PublicAPI.Unshipped.txt` — new public symbols must be declared here (enforced by RS0016 at build time; the compiler error includes the exact signature to copy in) - GitHub repo: `kommundsen/Conjecture` \ No newline at end of file diff --git a/src/Conjecture.Analyzers.CodeFixes/AssemblyInfo.cs b/src/Conjecture.Analyzers.CodeFixes/AssemblyInfo.cs index f9e33cd..9622a23 100644 --- a/src/Conjecture.Analyzers.CodeFixes/AssemblyInfo.cs +++ b/src/Conjecture.Analyzers.CodeFixes/AssemblyInfo.cs @@ -3,4 +3,4 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("Conjecture.Analyzers.Tests")] +[assembly: InternalsVisibleTo("Conjecture.Analyzers.Tests")] \ No newline at end of file diff --git a/src/Conjecture.Analyzers.CodeFixes/CON102CodeFix.cs b/src/Conjecture.Analyzers.CodeFixes/CON102CodeFix.cs index 8dc6335..8624547 100644 --- a/src/Conjecture.Analyzers.CodeFixes/CON102CodeFix.cs +++ b/src/Conjecture.Analyzers.CodeFixes/CON102CodeFix.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/Conjecture.Analyzers.CodeFixes/CON103CodeFix.cs b/src/Conjecture.Analyzers.CodeFixes/CON103CodeFix.cs index 9641fd0..8b5e649 100644 --- a/src/Conjecture.Analyzers.CodeFixes/CON103CodeFix.cs +++ b/src/Conjecture.Analyzers.CodeFixes/CON103CodeFix.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/Conjecture.Analyzers.Tests/CON100Tests.cs b/src/Conjecture.Analyzers.Tests/CON100Tests.cs index fa19025..c436e6d 100644 --- a/src/Conjecture.Analyzers.Tests/CON100Tests.cs +++ b/src/Conjecture.Analyzers.Tests/CON100Tests.cs @@ -3,7 +3,9 @@ using System.Collections.Immutable; using System.IO; + using Conjecture.Analyzers; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/Conjecture.Analyzers.Tests/CON101Tests.cs b/src/Conjecture.Analyzers.Tests/CON101Tests.cs index 20dd13e..fcb01e5 100644 --- a/src/Conjecture.Analyzers.Tests/CON101Tests.cs +++ b/src/Conjecture.Analyzers.Tests/CON101Tests.cs @@ -4,7 +4,9 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Conjecture.Analyzers; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/Conjecture.Analyzers.Tests/CON102Tests.cs b/src/Conjecture.Analyzers.Tests/CON102Tests.cs index 5f288f5..56adc24 100644 --- a/src/Conjecture.Analyzers.Tests/CON102Tests.cs +++ b/src/Conjecture.Analyzers.Tests/CON102Tests.cs @@ -7,7 +7,9 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; + using Conjecture.Analyzers; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/Conjecture.Analyzers.Tests/CON103Tests.cs b/src/Conjecture.Analyzers.Tests/CON103Tests.cs index 5979ef0..0436c39 100644 --- a/src/Conjecture.Analyzers.Tests/CON103Tests.cs +++ b/src/Conjecture.Analyzers.Tests/CON103Tests.cs @@ -7,7 +7,9 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; + using Conjecture.Analyzers; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/Conjecture.Analyzers.Tests/CON104Tests.cs b/src/Conjecture.Analyzers.Tests/CON104Tests.cs index a2c4450..5d0aef1 100644 --- a/src/Conjecture.Analyzers.Tests/CON104Tests.cs +++ b/src/Conjecture.Analyzers.Tests/CON104Tests.cs @@ -4,7 +4,9 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Conjecture.Analyzers; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/Conjecture.Analyzers.Tests/CON105Tests.cs b/src/Conjecture.Analyzers.Tests/CON105Tests.cs index b451d9a..603eb2c 100644 --- a/src/Conjecture.Analyzers.Tests/CON105Tests.cs +++ b/src/Conjecture.Analyzers.Tests/CON105Tests.cs @@ -4,7 +4,9 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Conjecture.Analyzers; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/Conjecture.Analyzers.Tests/EndToEnd/AnalyzerIntegrationE2ETests.cs b/src/Conjecture.Analyzers.Tests/EndToEnd/AnalyzerIntegrationE2ETests.cs index 4d49c1a..fd528ec 100644 --- a/src/Conjecture.Analyzers.Tests/EndToEnd/AnalyzerIntegrationE2ETests.cs +++ b/src/Conjecture.Analyzers.Tests/EndToEnd/AnalyzerIntegrationE2ETests.cs @@ -7,7 +7,9 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; + using Conjecture.Analyzers; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/Conjecture.Analyzers/CON100Analyzer.cs b/src/Conjecture.Analyzers/CON100Analyzer.cs index e4f75ef..cd7fce5 100644 --- a/src/Conjecture.Analyzers/CON100Analyzer.cs +++ b/src/Conjecture.Analyzers/CON100Analyzer.cs @@ -3,6 +3,7 @@ using System.Collections.Immutable; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.Analyzers/CON101Analyzer.cs b/src/Conjecture.Analyzers/CON101Analyzer.cs index 5167180..1dda02f 100644 --- a/src/Conjecture.Analyzers/CON101Analyzer.cs +++ b/src/Conjecture.Analyzers/CON101Analyzer.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Immutable; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.Analyzers/CON102Analyzer.cs b/src/Conjecture.Analyzers/CON102Analyzer.cs index 3c2fc95..793a60c 100644 --- a/src/Conjecture.Analyzers/CON102Analyzer.cs +++ b/src/Conjecture.Analyzers/CON102Analyzer.cs @@ -3,6 +3,7 @@ using System.Collections.Immutable; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.Analyzers/CON103Analyzer.cs b/src/Conjecture.Analyzers/CON103Analyzer.cs index b75d690..4a5ef55 100644 --- a/src/Conjecture.Analyzers/CON103Analyzer.cs +++ b/src/Conjecture.Analyzers/CON103Analyzer.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Immutable; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.Analyzers/CON104Analyzer.cs b/src/Conjecture.Analyzers/CON104Analyzer.cs index 194af8d..5ff1783 100644 --- a/src/Conjecture.Analyzers/CON104Analyzer.cs +++ b/src/Conjecture.Analyzers/CON104Analyzer.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Immutable; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.Analyzers/CON105Analyzer.cs b/src/Conjecture.Analyzers/CON105Analyzer.cs index db7ffe2..d005fbf 100644 --- a/src/Conjecture.Analyzers/CON105Analyzer.cs +++ b/src/Conjecture.Analyzers/CON105Analyzer.cs @@ -3,6 +3,7 @@ using System.Collections.Immutable; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.Analyzers/Conjecture.Analyzers.csproj b/src/Conjecture.Analyzers/Conjecture.Analyzers.csproj index d1e210c..b1740ee 100644 --- a/src/Conjecture.Analyzers/Conjecture.Analyzers.csproj +++ b/src/Conjecture.Analyzers/Conjecture.Analyzers.csproj @@ -14,8 +14,6 @@ - - diff --git a/src/Conjecture.Analyzers/PropertyAttributeHelper.cs b/src/Conjecture.Analyzers/PropertyAttributeHelper.cs index 6a8d399..aceda1d 100644 --- a/src/Conjecture.Analyzers/PropertyAttributeHelper.cs +++ b/src/Conjecture.Analyzers/PropertyAttributeHelper.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.Benchmarks/CoreDrawBenchmarks.cs b/src/Conjecture.Benchmarks/CoreDrawBenchmarks.cs index 60ec6ac..56acfd9 100644 --- a/src/Conjecture.Benchmarks/CoreDrawBenchmarks.cs +++ b/src/Conjecture.Benchmarks/CoreDrawBenchmarks.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using BenchmarkDotNet.Attributes; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Benchmarks/GeneratorBenchmarks.cs b/src/Conjecture.Benchmarks/GeneratorBenchmarks.cs index 6811300..52cd685 100644 --- a/src/Conjecture.Benchmarks/GeneratorBenchmarks.cs +++ b/src/Conjecture.Benchmarks/GeneratorBenchmarks.cs @@ -3,10 +3,13 @@ using System.IO; using System.Text; + using BenchmarkDotNet.Attributes; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Generators; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Conjecture.Benchmarks/Phase1Benchmarks.cs b/src/Conjecture.Benchmarks/Phase1Benchmarks.cs index 3e5c14a..a6a9f93 100644 --- a/src/Conjecture.Benchmarks/Phase1Benchmarks.cs +++ b/src/Conjecture.Benchmarks/Phase1Benchmarks.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using BenchmarkDotNet.Attributes; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Benchmarks/Phase2Benchmarks.cs b/src/Conjecture.Benchmarks/Phase2Benchmarks.cs index 67a2f39..f442820 100644 --- a/src/Conjecture.Benchmarks/Phase2Benchmarks.cs +++ b/src/Conjecture.Benchmarks/Phase2Benchmarks.cs @@ -2,7 +2,9 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Runtime.CompilerServices; + using BenchmarkDotNet.Attributes; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Benchmarks/StateMachineBenchmarks.cs b/src/Conjecture.Benchmarks/StateMachineBenchmarks.cs index 36e7f05..5e190c0 100644 --- a/src/Conjecture.Benchmarks/StateMachineBenchmarks.cs +++ b/src/Conjecture.Benchmarks/StateMachineBenchmarks.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using BenchmarkDotNet.Attributes; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -33,7 +34,9 @@ internal sealed class CounterMachineFailsAt3 : IStateMachine 3) + { throw new InvalidOperationException($"counter exceeded 3: {state}"); + } } } @@ -49,7 +52,9 @@ internal sealed class CounterMachineFailsAt20 : IStateMachine 20) + { throw new InvalidOperationException($"counter exceeded 20: {state}"); + } } } @@ -110,4 +115,4 @@ public async Task StateMachineShrinking_Short() => [Benchmark] public async Task StateMachineShrinking_Long() => await TestRunner.Run(shrinkSettings, data => failingLongStrategy.Generate(data)); -} +} \ No newline at end of file diff --git a/src/Conjecture.Benchmarks/TargetingBenchmarks.cs b/src/Conjecture.Benchmarks/TargetingBenchmarks.cs index 6207f53..7038336 100644 --- a/src/Conjecture.Benchmarks/TargetingBenchmarks.cs +++ b/src/Conjecture.Benchmarks/TargetingBenchmarks.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using BenchmarkDotNet.Attributes; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -175,4 +176,4 @@ public object RecursiveGeneration_Depth10() ConjectureData data = ConjectureData.ForGeneration(rng.Split()); return exprDepth10.Generate(data); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/ArbitraryAutoDiscoveryTests.cs b/src/Conjecture.Core.Tests/ArbitraryAutoDiscoveryTests.cs index 35c5a03..53efe9d 100644 --- a/src/Conjecture.Core.Tests/ArbitraryAutoDiscoveryTests.cs +++ b/src/Conjecture.Core.Tests/ArbitraryAutoDiscoveryTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Core.Tests/AsyncPropertyShrinkingTests.cs b/src/Conjecture.Core.Tests/AsyncPropertyShrinkingTests.cs index e244d33..1f7baef 100644 --- a/src/Conjecture.Core.Tests/AsyncPropertyShrinkingTests.cs +++ b/src/Conjecture.Core.Tests/AsyncPropertyShrinkingTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Diagnostics; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Core.Tests/EndToEnd/AdvancedShrinkingE2ETests.cs b/src/Conjecture.Core.Tests/EndToEnd/AdvancedShrinkingE2ETests.cs index 73f8426..48a14a2 100644 --- a/src/Conjecture.Core.Tests/EndToEnd/AdvancedShrinkingE2ETests.cs +++ b/src/Conjecture.Core.Tests/EndToEnd/AdvancedShrinkingE2ETests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Runtime.CompilerServices; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Core.Tests/FromAttributeTests.cs b/src/Conjecture.Core.Tests/FromAttributeTests.cs index 3a3338c..81b8b8b 100644 --- a/src/Conjecture.Core.Tests/FromAttributeTests.cs +++ b/src/Conjecture.Core.Tests/FromAttributeTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; namespace Conjecture.Core.Tests; diff --git a/src/Conjecture.Core.Tests/FromFactoryAttributeTests.cs b/src/Conjecture.Core.Tests/FromFactoryAttributeTests.cs index faf2425..710971f 100644 --- a/src/Conjecture.Core.Tests/FromFactoryAttributeTests.cs +++ b/src/Conjecture.Core.Tests/FromFactoryAttributeTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; namespace Conjecture.Core.Tests; diff --git a/src/Conjecture.Core.Tests/Internal/ConjectureDataTargetTests.cs b/src/Conjecture.Core.Tests/Internal/ConjectureDataTargetTests.cs index f0d35f9..587e99c 100644 --- a/src/Conjecture.Core.Tests/Internal/ConjectureDataTargetTests.cs +++ b/src/Conjecture.Core.Tests/Internal/ConjectureDataTargetTests.cs @@ -81,4 +81,4 @@ public void Observations_ReadableAfterFreeze() data.Freeze(); Assert.Equal(99.0, data.Observations["label"]); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/ExampleDatabaseLoggingTests.cs b/src/Conjecture.Core.Tests/Internal/ExampleDatabaseLoggingTests.cs index 22621d3..c1920bb 100644 --- a/src/Conjecture.Core.Tests/Internal/ExampleDatabaseLoggingTests.cs +++ b/src/Conjecture.Core.Tests/Internal/ExampleDatabaseLoggingTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; namespace Conjecture.Core.Tests.Internal; @@ -82,4 +83,4 @@ public void Dispose() { try { Directory.Delete(tempDir, recursive: true); } catch { } } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/HillClimberLoggingTests.cs b/src/Conjecture.Core.Tests/Internal/HillClimberLoggingTests.cs index 8412e22..90ef87f 100644 --- a/src/Conjecture.Core.Tests/Internal/HillClimberLoggingTests.cs +++ b/src/Conjecture.Core.Tests/Internal/HillClimberLoggingTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; namespace Conjecture.Core.Tests.Internal; @@ -65,4 +66,4 @@ public async Task Climb_WhenNoImprovement_DoesNotLogTargetingStep() Assert.DoesNotContain(logger.Entries, e => e.EventId.Id == 12); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/HillClimberPerturbTests.cs b/src/Conjecture.Core.Tests/Internal/HillClimberPerturbTests.cs index 9d5fdd8..412eb9c 100644 --- a/src/Conjecture.Core.Tests/Internal/HillClimberPerturbTests.cs +++ b/src/Conjecture.Core.Tests/Internal/HillClimberPerturbTests.cs @@ -14,8 +14,16 @@ public class HillClimberPerturbTests private static double LocalMaxScore(IReadOnlyList nodes) { var value = nodes[0].Value; - if (value <= 50) return (double)value; - if (value >= 80) return (double)value; + if (value <= 50) + { + return (double)value; + } + + if (value >= 80) + { + return (double)value; + } + return 0.0; // valley between 50 and 80 } diff --git a/src/Conjecture.Core.Tests/Internal/HillClimberTests.cs b/src/Conjecture.Core.Tests/Internal/HillClimberTests.cs index 759b184..2407cf1 100644 --- a/src/Conjecture.Core.Tests/Internal/HillClimberTests.cs +++ b/src/Conjecture.Core.Tests/Internal/HillClimberTests.cs @@ -97,7 +97,13 @@ public async Task Climb_MultipleIntegerNodes_TriesEachIndependently() { double sum = 0; foreach (var node in n) - if (node.IsIntegerLike) sum += node.Value; + { + if (node.IsIntegerLike) + { + sum += node.Value; + } + } + var dict = new Dictionary { [label] = sum }; return Task.FromResult<(Status, IReadOnlyDictionary)>((Status.Valid, dict)); }, diff --git a/src/Conjecture.Core.Tests/Internal/LogTests.cs b/src/Conjecture.Core.Tests/Internal/LogTests.cs index e416de5..f523988 100644 --- a/src/Conjecture.Core.Tests/Internal/LogTests.cs +++ b/src/Conjecture.Core.Tests/Internal/LogTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; namespace Conjecture.Core.Tests.Internal; @@ -174,4 +175,4 @@ public void AllMethods_WhenLoggerDisabled_DoNotCallLog() Log.DatabaseSaved(logger, testIdHash: "h"); Assert.Equal(0, logger.LogCallCount); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/SettingsLoaderTests.cs b/src/Conjecture.Core.Tests/Internal/SettingsLoaderTests.cs index c45efe1..456ebdf 100644 --- a/src/Conjecture.Core.Tests/Internal/SettingsLoaderTests.cs +++ b/src/Conjecture.Core.Tests/Internal/SettingsLoaderTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Text.Json; + using Conjecture.Core.Internal; namespace Conjecture.Core.Tests.Internal; diff --git a/src/Conjecture.Core.Tests/Internal/SettingsLoggerTests.cs b/src/Conjecture.Core.Tests/Internal/SettingsLoggerTests.cs index 8905bc9..7193e2c 100644 --- a/src/Conjecture.Core.Tests/Internal/SettingsLoggerTests.cs +++ b/src/Conjecture.Core.Tests/Internal/SettingsLoggerTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Core; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -33,4 +34,4 @@ public void SettingsAttribute_Apply_PreservesBaselineLogger() ConjectureSettings result = attr.Apply(baselineSettings); Assert.Same(baseline, result.Logger); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/SettingsTargetingTests.cs b/src/Conjecture.Core.Tests/Internal/SettingsTargetingTests.cs index c0eccda..ea6bb0c 100644 --- a/src/Conjecture.Core.Tests/Internal/SettingsTargetingTests.cs +++ b/src/Conjecture.Core.Tests/Internal/SettingsTargetingTests.cs @@ -42,4 +42,4 @@ public void TargetingProportion_Negative_ThrowsArgumentOutOfRangeException() { Assert.Throws(() => _ = new ConjectureSettings { TargetingProportion = -0.1 }); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/SharedParameterStrategyResolverTests.cs b/src/Conjecture.Core.Tests/Internal/SharedParameterStrategyResolverTests.cs index 9b42c72..ffd68b8 100644 --- a/src/Conjecture.Core.Tests/Internal/SharedParameterStrategyResolverTests.cs +++ b/src/Conjecture.Core.Tests/Internal/SharedParameterStrategyResolverTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Core.Tests/Internal/Shrinker/AdaptivePassTests.cs b/src/Conjecture.Core.Tests/Internal/Shrinker/AdaptivePassTests.cs index 4219a8e..1649123 100644 --- a/src/Conjecture.Core.Tests/Internal/Shrinker/AdaptivePassTests.cs +++ b/src/Conjecture.Core.Tests/Internal/Shrinker/AdaptivePassTests.cs @@ -31,7 +31,7 @@ public async ValueTask TryReduce(ShrinkState state) continue; } - IRNode[] candidate = [..state.Nodes]; + IRNode[] candidate = [.. state.Nodes]; candidate[i] = IRNode.ForInteger(node.Value - 1, node.Min, node.Max); if (await state.TryUpdate(candidate, i)) { diff --git a/src/Conjecture.Core.Tests/Internal/Shrinker/FloatSimplificationPassTests.cs b/src/Conjecture.Core.Tests/Internal/Shrinker/FloatSimplificationPassTests.cs index 5edd4cc..8f82ae3 100644 --- a/src/Conjecture.Core.Tests/Internal/Shrinker/FloatSimplificationPassTests.cs +++ b/src/Conjecture.Core.Tests/Internal/Shrinker/FloatSimplificationPassTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Runtime.CompilerServices; + using Conjecture.Core.Internal; namespace Conjecture.Core.Tests.Internal.Shrinker; diff --git a/src/Conjecture.Core.Tests/Internal/Shrinker/ShrinkerPassOrderTests.cs b/src/Conjecture.Core.Tests/Internal/Shrinker/ShrinkerPassOrderTests.cs index 0eb1468..6252ad2 100644 --- a/src/Conjecture.Core.Tests/Internal/Shrinker/ShrinkerPassOrderTests.cs +++ b/src/Conjecture.Core.Tests/Internal/Shrinker/ShrinkerPassOrderTests.cs @@ -3,6 +3,7 @@ using System.Reflection; using System.Runtime.CompilerServices; + using Conjecture.Core.Internal; namespace Conjecture.Core.Tests.Internal.Shrinker; diff --git a/src/Conjecture.Core.Tests/Internal/ShrinkerLoggingTests.cs b/src/Conjecture.Core.Tests/Internal/ShrinkerLoggingTests.cs index 97e7bf4..85f46fc 100644 --- a/src/Conjecture.Core.Tests/Internal/ShrinkerLoggingTests.cs +++ b/src/Conjecture.Core.Tests/Internal/ShrinkerLoggingTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -70,4 +71,4 @@ public async Task ShrinkAsync_WithNullLogger_DoesNotThrow() Assert.Equal(nodes.Count, shrunk.Count); Assert.Equal(0, shrinkCount); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/TargetReportingTests.cs b/src/Conjecture.Core.Tests/Internal/TargetReportingTests.cs index ee886a2..1e3ec44 100644 --- a/src/Conjecture.Core.Tests/Internal/TargetReportingTests.cs +++ b/src/Conjecture.Core.Tests/Internal/TargetReportingTests.cs @@ -59,4 +59,4 @@ public void Format_WithOriginalAndShrunk_TargetingScoresAppended() Assert.Contains("Target scores:", result); Assert.Contains("size = 3.1416", result); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/TestOutputHelperLoggerTests.cs b/src/Conjecture.Core.Tests/Internal/TestOutputHelperLoggerTests.cs index bffb424..a616d85 100644 --- a/src/Conjecture.Core.Tests/Internal/TestOutputHelperLoggerTests.cs +++ b/src/Conjecture.Core.Tests/Internal/TestOutputHelperLoggerTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -127,4 +128,4 @@ public void FromWriteLine_WithCustomMinLevel_HonorsLevel() Assert.True(logger.IsEnabled(LogLevel.Debug)); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/TestRunnerLoggingTests.cs b/src/Conjecture.Core.Tests/Internal/TestRunnerLoggingTests.cs index 62ac1b6..090351a 100644 --- a/src/Conjecture.Core.Tests/Internal/TestRunnerLoggingTests.cs +++ b/src/Conjecture.Core.Tests/Internal/TestRunnerLoggingTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -57,12 +58,7 @@ public async Task Run_HighAssumptionRejection_LogsHighUnsatisfiedRatioWarning() await Assert.ThrowsAsync(() => TestRunner.RunAsync(settings, _ => { callCount++; - if (callCount > 1) - { - throw new UnsatisfiedAssumptionException(); - } - - return Task.CompletedTask; + return callCount > 1 ? throw new UnsatisfiedAssumptionException() : Task.CompletedTask; })); Assert.Contains(logger.Entries, e => e.Level == LogLevel.Warning && e.EventId.Id == 7); @@ -87,4 +83,4 @@ public async Task Run_WithNullLogger_FailingRunDoesNotThrow() Assert.False(result.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/TestRunnerMultiTargetTests.cs b/src/Conjecture.Core.Tests/Internal/TestRunnerMultiTargetTests.cs index 4ba483c..16c94af 100644 --- a/src/Conjecture.Core.Tests/Internal/TestRunnerMultiTargetTests.cs +++ b/src/Conjecture.Core.Tests/Internal/TestRunnerMultiTargetTests.cs @@ -74,13 +74,17 @@ public async Task TenLabels_DoesNotCrash_AllLabelsPresent() var result = await TestRunner.Run(settings, data => { for (int i = 0; i < 10; i++) + { Target.Maximize((double)data.NextInteger(0, 100), $"label{i}"); + } }); Assert.NotNull(result.TargetingScores); Assert.Equal(10, result.TargetingScores.Count); for (int i = 0; i < 10; i++) + { Assert.True(result.TargetingScores.ContainsKey($"label{i}")); + } } [Fact] @@ -112,4 +116,4 @@ public async Task RoundRobin_BothLabelsImproveWithLimitedBudget() Assert.True(result.TargetingScores["a"] >= 0.0); Assert.True(result.TargetingScores["b"] >= 0.0); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Internal/TestRunnerTargetingTests.cs b/src/Conjecture.Core.Tests/Internal/TestRunnerTargetingTests.cs index 093a262..2f98647 100644 --- a/src/Conjecture.Core.Tests/Internal/TestRunnerTargetingTests.cs +++ b/src/Conjecture.Core.Tests/Internal/TestRunnerTargetingTests.cs @@ -21,10 +21,7 @@ public async Task TargetingPhase_ClimbsToHigherScore() TargetingProportion = 0.5, }; - var result = await TestRunner.Run(settings, data => - { - Target.Maximize((double)data.NextInteger(0, 100)); - }); + var result = await TestRunner.Run(settings, data => Target.Maximize((double)data.NextInteger(0, 100))); Assert.True(result.Passed); Assert.NotNull(result.TargetingScores); @@ -61,10 +58,7 @@ public async Task TargetingPhase_SkippedWhenTargetingFalse() TargetingProportion = 0.5, }; - var result = await TestRunner.Run(settings, data => - { - Target.Maximize((double)data.NextInteger(0, 100)); - }); + var result = await TestRunner.Run(settings, data => Target.Maximize((double)data.NextInteger(0, 100))); Assert.True(result.Passed); Assert.Null(result.TargetingScores); @@ -82,10 +76,7 @@ public async Task TestRunResult_IncludesTargetingScores_WhenTargetingRan() TargetingProportion = 0.5, }; - var result = await TestRunner.Run(settings, data => - { - Target.Maximize(42.0, "myscore"); - }); + var result = await TestRunner.Run(settings, data => Target.Maximize(42.0, "myscore")); Assert.NotNull(result.TargetingScores); Assert.True(result.TargetingScores.ContainsKey("myscore")); @@ -103,10 +94,7 @@ public async Task BudgetSplit_GenerationRunsProportionalExamples() TargetingProportion = 0.5, }; - var result = await TestRunner.Run(settings, data => - { - Target.Maximize((double)data.NextInteger(0, 100)); - }); + var result = await TestRunner.Run(settings, data => Target.Maximize((double)data.NextInteger(0, 100))); Assert.Equal(50, result.ExampleCount); } @@ -132,4 +120,4 @@ public async Task TargetingPhase_SkippedWhenGenerationFails() Assert.False(result.Passed); Assert.Null(result.TargetingScores); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Logging/EndToEnd/LoggingEndToEndTests.cs b/src/Conjecture.Core.Tests/Logging/EndToEnd/LoggingEndToEndTests.cs index 273c306..785628e 100644 --- a/src/Conjecture.Core.Tests/Logging/EndToEnd/LoggingEndToEndTests.cs +++ b/src/Conjecture.Core.Tests/Logging/EndToEnd/LoggingEndToEndTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -61,10 +62,7 @@ public async Task Run_WithTargeting_EmitsTargetingStartedAndCompleted() TargetingProportion = 0.5, }; - await TestRunner.Run(settings, data => - { - Target.Maximize((double)data.NextInteger(0, 100)); - }); + await TestRunner.Run(settings, data => Target.Maximize((double)data.NextInteger(0, 100))); Assert.Contains(logger.Entries, e => e.Level == LogLevel.Information && e.EventId.Id == 4); Assert.Contains(logger.Entries, e => e.Level == LogLevel.Information && e.EventId.Id == 5); @@ -86,12 +84,7 @@ public async Task Run_HighAssumptionRejection_EmitsHighUnsatisfiedRatioWarning() await Assert.ThrowsAsync(() => TestRunner.RunAsync(settings, _ => { callCount++; - if (callCount > 1) - { - throw new UnsatisfiedAssumptionException(); - } - - return Task.CompletedTask; + return callCount > 1 ? throw new UnsatisfiedAssumptionException() : Task.CompletedTask; })); Assert.Contains(logger.Entries, e => e.Level == LogLevel.Warning && e.EventId.Id == 7); @@ -116,4 +109,4 @@ public async Task Run_WithNullLogger_FailingPropertyDoesNotThrow() Assert.False(result.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkPass2Tests.cs b/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkPass2Tests.cs index b7e038e..f199f81 100644 --- a/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkPass2Tests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkPass2Tests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core.Internal; namespace Conjecture.Core.Tests.StateMachine; @@ -142,4 +143,4 @@ public async Task AfterConvergingToMinimum_RerunningShrinkPass_MakesNoFurtherPro Assert.False(furtherProgress); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkTests.cs b/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkTests.cs index 0bdac79..9c1332a 100644 --- a/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/CommandSequenceShrinkTests.cs @@ -110,4 +110,4 @@ public async Task TruncateFromEnd_AcceptsCandidate_WhenTryUpdateSucceeds() bool result = await pass.TryReduce(state); Assert.True(result); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/EndToEnd/QueueStateMachineTests.cs b/src/Conjecture.Core.Tests/StateMachine/EndToEnd/QueueStateMachineTests.cs index 6b86677..fd34ab6 100644 --- a/src/Conjecture.Core.Tests/StateMachine/EndToEnd/QueueStateMachineTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/EndToEnd/QueueStateMachineTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -28,11 +29,9 @@ private static int CountCommandStarts(IReadOnlyList nodes) => private abstract class QueueCommand { - public sealed class Enqueue : QueueCommand + public sealed class Enqueue(int value) : QueueCommand { - public Enqueue(int value) { Value = value; } - public int Value { get; } - public override string ToString() => $"Enqueue({Value})"; + public int Value { get; } = value; public override string ToString() => $"Enqueue({Value})"; } public sealed class Dequeue : QueueCommand @@ -78,7 +77,10 @@ public QueueState RunCommand(QueueState state, QueueCommand cmd) if (cmd is QueueCommand.Dequeue) { if (state.Queue.Count == 0) + { return new(state.Queue, null); + } + Queue q = new(state.Queue); q.Dequeue(); return new(q, null); @@ -86,7 +88,10 @@ public QueueState RunCommand(QueueState state, QueueCommand cmd) // Peek — planted bug: off-by-one on front element when Count > 1. if (state.Queue.Count == 0) + { return state; + } + int peeked = state.Queue.Count > 1 ? state.Queue.Peek() + 1 // Bug: returns front + 1, not front : state.Queue.Peek(); // Correct when only one element @@ -97,8 +102,10 @@ public void Invariant(QueueState state) { if (state.SnapshotPeek.HasValue && state.Queue.Count > 0 && state.SnapshotPeek.Value != state.Queue.Peek()) + { throw new InvalidOperationException( $"Peek returned {state.SnapshotPeek.Value} but front element is {state.Queue.Peek()}"); + } } } @@ -125,24 +132,27 @@ public QueueState RunCommand(QueueState state, QueueCommand cmd) if (cmd is QueueCommand.Dequeue) { if (state.Queue.Count == 0) + { return new(state.Queue, null); + } + Queue q = new(state.Queue); q.Dequeue(); return new(q, null); } // Peek — correct implementation. - if (state.Queue.Count == 0) - return state; - return new(new Queue(state.Queue), state.Queue.Peek()); + return state.Queue.Count == 0 ? state : new(new Queue(state.Queue), state.Queue.Peek()); } public void Invariant(QueueState state) { if (state.SnapshotPeek.HasValue && state.Queue.Count > 0 && state.SnapshotPeek.Value != state.Queue.Peek()) + { throw new InvalidOperationException( $"Peek returned {state.SnapshotPeek.Value} but front element is {state.Queue.Peek()}"); + } } } @@ -187,8 +197,10 @@ public void Invariant(QueueState state) { if (state.SnapshotPeek.HasValue && state.Queue.Count > 0 && state.SnapshotPeek.Value != state.Queue.Peek()) + { throw new InvalidOperationException( $"Peek returned {state.SnapshotPeek.Value} but front element is {state.Queue.Peek()}"); + } } } @@ -251,4 +263,4 @@ public async Task StateDependentCommands_DequeueNeverSelectedWhenQueueEmpty() data => _ = Generate.StateMachine().Generate(data)); Assert.True(result.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/EndToEnd/StackStateMachineTests.cs b/src/Conjecture.Core.Tests/StateMachine/EndToEnd/StackStateMachineTests.cs index 5f5b74d..76b35d0 100644 --- a/src/Conjecture.Core.Tests/StateMachine/EndToEnd/StackStateMachineTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/EndToEnd/StackStateMachineTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -26,11 +27,9 @@ private static int CountCommandStarts(IReadOnlyList nodes) => private abstract class StackCommand { - public sealed class Push : StackCommand + public sealed class Push(int value) : StackCommand { - public Push(int value) { Value = value; } - public int Value { get; } - public override string ToString() => $"Push({Value})"; + public int Value { get; } = value; public override string ToString() => $"Push({Value})"; } public sealed class Pop : StackCommand @@ -75,8 +74,10 @@ public StackState RunCommand(StackState state, StackCommand cmd) public void Invariant(StackState state) { if (state.ModelCount != state.Stack.Count) + { throw new InvalidOperationException( $"ModelCount {state.ModelCount} != Stack.Count {state.Stack.Count}"); + } } } @@ -110,8 +111,10 @@ public StackState RunCommand(StackState state, StackCommand cmd) public void Invariant(StackState state) { if (state.ModelCount != state.Stack.Count) + { throw new InvalidOperationException( $"ModelCount {state.ModelCount} != Stack.Count {state.Stack.Count}"); + } } } @@ -125,7 +128,9 @@ public IEnumerable> Commands(StackState state) { yield return Generate.Integers(0, 9).Select(n => (StackCommand)new StackCommand.Push(n)); if (state.Stack.Count > 0) + { yield return Generate.Just((StackCommand)new StackCommand.Pop()); + } } public StackState RunCommand(StackState state, StackCommand cmd) @@ -145,8 +150,10 @@ public StackState RunCommand(StackState state, StackCommand cmd) public void Invariant(StackState state) { if (state.ModelCount != state.Stack.Count) + { throw new InvalidOperationException( $"ModelCount {state.ModelCount} != Stack.Count {state.Stack.Count}"); + } } } @@ -206,4 +213,4 @@ public async Task StateDependentCommands_PopOnlyGeneratedWhenStackNonEmpty() data => _ = Generate.StateMachine().Generate(data)); Assert.True(result.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/GenStateMachineTests.cs b/src/Conjecture.Core.Tests/StateMachine/GenStateMachineTests.cs index 69de56c..1a6acd1 100644 --- a/src/Conjecture.Core.Tests/StateMachine/GenStateMachineTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/GenStateMachineTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -59,4 +60,4 @@ public void StateMachine_ComposesWithGenerateCompose() int count = derived.Generate(MakeData()); Assert.True(count >= 0); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/IStateMachineTests.cs b/src/Conjecture.Core.Tests/StateMachine/IStateMachineTests.cs index 691239e..76d7d6b 100644 --- a/src/Conjecture.Core.Tests/StateMachine/IStateMachineTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/IStateMachineTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; namespace Conjecture.Core.Tests.StateMachine; @@ -44,7 +45,7 @@ private sealed class ListMachine : IStateMachine, int> public IEnumerable> Commands(List state) => [Generate.Integers(1, 100)]; - public List RunCommand(List state, int command) { return [..state, command]; } + public List RunCommand(List state, int command) { return [.. state, command]; } public void Invariant(List state) { } } @@ -118,4 +119,4 @@ public void Interface_WorksWithReferenceTypeState() List initial = machine.InitialState(); Assert.Empty(initial); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/InvariantFailurePropagationTests.cs b/src/Conjecture.Core.Tests/StateMachine/InvariantFailurePropagationTests.cs index 8f8e93a..bbc19e7 100644 --- a/src/Conjecture.Core.Tests/StateMachine/InvariantFailurePropagationTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/InvariantFailurePropagationTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -92,4 +93,4 @@ public async Task FailureExceptionMessage_ContainsStepInfo() Assert.NotNull(thrown); Assert.Contains("step", thrown.Message, StringComparison.OrdinalIgnoreCase); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/ShrinkIntegrationTests.cs b/src/Conjecture.Core.Tests/StateMachine/ShrinkIntegrationTests.cs index 0262a11..dfb9134 100644 --- a/src/Conjecture.Core.Tests/StateMachine/ShrinkIntegrationTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/ShrinkIntegrationTests.cs @@ -80,4 +80,4 @@ public async Task CommandSequencePass_NoCommandStartNodes_DoesNotBreakNonStatefu Assert.NotNull(result.Counterexample); Assert.Equal(6UL, result.Counterexample![0].Value); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/StateMachineFormatterTests.cs b/src/Conjecture.Core.Tests/StateMachine/StateMachineFormatterTests.cs index 4095227..7f70145 100644 --- a/src/Conjecture.Core.Tests/StateMachine/StateMachineFormatterTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/StateMachineFormatterTests.cs @@ -104,4 +104,4 @@ public void Formatter_IsRegisteredWithFormatterRegistry_AfterConstruction() Assert.NotNull(registered); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/StateMachineRunTests.cs b/src/Conjecture.Core.Tests/StateMachine/StateMachineRunTests.cs index f103134..4d0e67d 100644 --- a/src/Conjecture.Core.Tests/StateMachine/StateMachineRunTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/StateMachineRunTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; namespace Conjecture.Core.Tests.StateMachine; @@ -98,4 +99,4 @@ public void ExecutedStep_IsValueEquatable() ExecutedStep b = new(5, "x"); Assert.Equal(a, b); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/StateMachineRunnerTests.cs b/src/Conjecture.Core.Tests/StateMachine/StateMachineRunnerTests.cs index d8e436d..2ccc383 100644 --- a/src/Conjecture.Core.Tests/StateMachine/StateMachineRunnerTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/StateMachineRunnerTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -124,4 +125,4 @@ public void Execute_CommandsAfterFailureNotExecuted() _ = commandsExecuted; // suppress warning Assert.Single(run.Steps); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/StateMachine/StateMachineStrategyTests.cs b/src/Conjecture.Core.Tests/StateMachine/StateMachineStrategyTests.cs index 16a2953..44e6785 100644 --- a/src/Conjecture.Core.Tests/StateMachine/StateMachineStrategyTests.cs +++ b/src/Conjecture.Core.Tests/StateMachine/StateMachineStrategyTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -142,4 +143,4 @@ public void Generate_StepsAreInExecutionOrder() Assert.True(run.Steps[i].State > run.Steps[i - 1].State); } } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Strategies/ComposeTargetTests.cs b/src/Conjecture.Core.Tests/Strategies/ComposeTargetTests.cs index 44a67a5..de838c4 100644 --- a/src/Conjecture.Core.Tests/Strategies/ComposeTargetTests.cs +++ b/src/Conjecture.Core.Tests/Strategies/ComposeTargetTests.cs @@ -59,11 +59,8 @@ public async Task Compose_Target_NaN_Throws() }); ConjectureSettings settings = new() { MaxExamples = 1, Seed = 1UL }; - TestRunResult result = await TestRunner.Run(settings, data => - { - strategy.Generate(data); - }); + TestRunResult result = await TestRunner.Run(settings, data => strategy.Generate(data)); Assert.True(result.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Strategies/GenRecursiveTests.cs b/src/Conjecture.Core.Tests/Strategies/GenRecursiveTests.cs index 4798493..895ffeb 100644 --- a/src/Conjecture.Core.Tests/Strategies/GenRecursiveTests.cs +++ b/src/Conjecture.Core.Tests/Strategies/GenRecursiveTests.cs @@ -126,4 +126,4 @@ public void Recursive_InGenCompose_WorksViaCtxGenerate() Assert.InRange(composed.Generate(data), 0, 3); } } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Strategies/Recursive/ExprTreeTests.cs b/src/Conjecture.Core.Tests/Strategies/Recursive/ExprTreeTests.cs index 0b28572..b91b956 100644 --- a/src/Conjecture.Core.Tests/Strategies/Recursive/ExprTreeTests.cs +++ b/src/Conjecture.Core.Tests/Strategies/Recursive/ExprTreeTests.cs @@ -161,4 +161,4 @@ public async Task ExprTree_WithMaxDepth20_DoesNotStackOverflow() Assert.True(result.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Strategies/Recursive/JsonValueTests.cs b/src/Conjecture.Core.Tests/Strategies/Recursive/JsonValueTests.cs index 7183e79..b597acd 100644 --- a/src/Conjecture.Core.Tests/Strategies/Recursive/JsonValueTests.cs +++ b/src/Conjecture.Core.Tests/Strategies/Recursive/JsonValueTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Text.Json; + using Conjecture.Core; using Conjecture.Core.Internal; @@ -167,4 +168,4 @@ public async Task JsonValue_ContainerCounterexample_ShrinksToEmptyContainer() Assert.Equal(0, itemCount); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Strategies/RecursiveStrategyTests.cs b/src/Conjecture.Core.Tests/Strategies/RecursiveStrategyTests.cs index 9cdffcf..112ef18 100644 --- a/src/Conjecture.Core.Tests/Strategies/RecursiveStrategyTests.cs +++ b/src/Conjecture.Core.Tests/Strategies/RecursiveStrategyTests.cs @@ -121,4 +121,4 @@ private sealed class Add(Expr left, Expr right) : Expr internal Expr Left { get; } = left; internal Expr Right { get; } = right; } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/TargetTests.cs b/src/Conjecture.Core.Tests/TargetTests.cs index 632b643..2fc37ee 100644 --- a/src/Conjecture.Core.Tests/TargetTests.cs +++ b/src/Conjecture.Core.Tests/TargetTests.cs @@ -12,10 +12,7 @@ public class TargetTests public async Task Maximize_WithinTestBody_RecordsObservation() { ConjectureSettings settings = new() { MaxExamples = 1, Seed = 1UL }; - TestRunResult result = await TestRunner.Run(settings, data => - { - Target.Maximize(10.0); - }); + TestRunResult result = await TestRunner.Run(settings, data => Target.Maximize(10.0)); Assert.True(result.Passed); } @@ -84,11 +81,8 @@ public async Task Maximize_SameLabel_LastValueWins() public async Task Maximize_NaN_Throws() { ConjectureSettings settings = new() { MaxExamples = 1, Seed = 1UL }; - TestRunResult result = await TestRunner.Run(settings, _ => - { - Assert.Throws(() => Target.Maximize(double.NaN)); - }); + TestRunResult result = await TestRunner.Run(settings, _ => Assert.Throws(() => Target.Maximize(double.NaN))); Assert.True(result.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingDatabaseTests.cs b/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingDatabaseTests.cs index 2d8423f..c76b201 100644 --- a/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingDatabaseTests.cs +++ b/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingDatabaseTests.cs @@ -155,4 +155,4 @@ public async Task TargetingFailure_SeedReproduction_RefindsFailure() Assert.False(replay.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingEffectivenessTests.cs b/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingEffectivenessTests.cs index 5cde806..54399b6 100644 --- a/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingEffectivenessTests.cs +++ b/src/Conjecture.Core.Tests/Targeting/EndToEnd/TargetingEffectivenessTests.cs @@ -192,4 +192,4 @@ public async Task Failure_WithTargeting_ProducesShrunkCounterexampleAndSeedRepro Assert.False(replayResult.Passed); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core.Tests/TrimAnnotationTests.cs b/src/Conjecture.Core.Tests/TrimAnnotationTests.cs index b7dcca6..436770b 100644 --- a/src/Conjecture.Core.Tests/TrimAnnotationTests.cs +++ b/src/Conjecture.Core.Tests/TrimAnnotationTests.cs @@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; + using Conjecture.Core; namespace Conjecture.Core.Tests; diff --git a/src/Conjecture.Core/BuiltInFormatters.cs b/src/Conjecture.Core/BuiltInFormatters.cs index aa11732..d0ad8d5 100644 --- a/src/Conjecture.Core/BuiltInFormatters.cs +++ b/src/Conjecture.Core/BuiltInFormatters.cs @@ -51,12 +51,12 @@ public string Format(string value) { switch (c) { - case '"': sb.Append("\\\""); break; + case '"': sb.Append("\\\""); break; case '\\': sb.Append("\\\\"); break; - case '\n': sb.Append("\\n"); break; - case '\r': sb.Append("\\r"); break; - case '\t': sb.Append("\\t"); break; - default: sb.Append(c); break; + case '\n': sb.Append("\\n"); break; + case '\r': sb.Append("\\r"); break; + case '\t': sb.Append("\\t"); break; + default: sb.Append(c); break; } } sb.Append('"'); diff --git a/src/Conjecture.Core/ExecutedStep.cs b/src/Conjecture.Core/ExecutedStep.cs index 0857024..4193cae 100644 --- a/src/Conjecture.Core/ExecutedStep.cs +++ b/src/Conjecture.Core/ExecutedStep.cs @@ -10,4 +10,4 @@ namespace Conjecture.Core; /// The type representing the system's state. /// The post-command state after this step was executed. /// A human-readable label for the command that produced this state. -public readonly record struct ExecutedStep(TState State, string CommandLabel); +public readonly record struct ExecutedStep(TState State, string CommandLabel); \ No newline at end of file diff --git a/src/Conjecture.Core/FloatingPointStrategy.cs b/src/Conjecture.Core/FloatingPointStrategy.cs index 4c1b57d..6f34a31 100644 --- a/src/Conjecture.Core/FloatingPointStrategy.cs +++ b/src/Conjecture.Core/FloatingPointStrategy.cs @@ -6,6 +6,7 @@ using System.Numerics; using System.Runtime.CompilerServices; + using Conjecture.Core.Internal; namespace Conjecture.Core; diff --git a/src/Conjecture.Core/IOutputFormatter.cs b/src/Conjecture.Core/IOutputFormatter.cs index 3f8d3cd..6223446 100644 --- a/src/Conjecture.Core/IOutputFormatter.cs +++ b/src/Conjecture.Core/IOutputFormatter.cs @@ -11,4 +11,4 @@ public interface IOutputFormatter /// Writes all to in this formatter's encoding. Task WriteAsync(IEnumerable data, Stream output, CancellationToken ct = default); -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/IStateMachine.cs b/src/Conjecture.Core/IStateMachine.cs index d0c7685..a6e9ba5 100644 --- a/src/Conjecture.Core/IStateMachine.cs +++ b/src/Conjecture.Core/IStateMachine.cs @@ -39,4 +39,4 @@ public interface IStateMachine /// /// The state to validate. void Invariant(TState state); -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/IntegerStrategy.cs b/src/Conjecture.Core/IntegerStrategy.cs index 4263d46..412c959 100644 --- a/src/Conjecture.Core/IntegerStrategy.cs +++ b/src/Conjecture.Core/IntegerStrategy.cs @@ -5,6 +5,7 @@ // Original copyright: Copyright (c) 2013-present, David R. MacIver and contributors. using System.Numerics; + using Conjecture.Core.Internal; namespace Conjecture.Core; diff --git a/src/Conjecture.Core/Internal/AdaptivePass.cs b/src/Conjecture.Core/Internal/AdaptivePass.cs index 79ff626..be673e9 100644 --- a/src/Conjecture.Core/Internal/AdaptivePass.cs +++ b/src/Conjecture.Core/Internal/AdaptivePass.cs @@ -14,7 +14,7 @@ public async ValueTask TryReduce(ShrinkState state) { if (productiveIndices.Count > 0) { - int[] snapshot = [..productiveIndices]; + int[] snapshot = [.. productiveIndices]; foreach (int i in snapshot) { if (await TryReduceAt(state, i)) @@ -44,7 +44,7 @@ private static async ValueTask TryReduceAt(ShrinkState state, int index) { return false; } - IRNode[] candidate = [..state.Nodes]; + IRNode[] candidate = [.. state.Nodes]; candidate[index] = node.WithValue(node.Value - 1); return await state.TryUpdate(candidate, index); } diff --git a/src/Conjecture.Core/Internal/BlockSwappingPass.cs b/src/Conjecture.Core/Internal/BlockSwappingPass.cs index c9cd901..def487b 100644 --- a/src/Conjecture.Core/Internal/BlockSwappingPass.cs +++ b/src/Conjecture.Core/Internal/BlockSwappingPass.cs @@ -20,7 +20,7 @@ public async ValueTask TryReduce(ShrinkState state) continue; } - IRNode[] candidate = [..state.Nodes]; + IRNode[] candidate = [.. state.Nodes]; candidate[i] = state.Nodes[i + 1]; candidate[i + 1] = state.Nodes[i]; if (await state.TryUpdate(candidate)) diff --git a/src/Conjecture.Core/Internal/CommandSequenceShrinkPass.cs b/src/Conjecture.Core/Internal/CommandSequenceShrinkPass.cs index 787b73f..864fb0d 100644 --- a/src/Conjecture.Core/Internal/CommandSequenceShrinkPass.cs +++ b/src/Conjecture.Core/Internal/CommandSequenceShrinkPass.cs @@ -113,4 +113,4 @@ private static List FindSentinels(IReadOnlyList nodes) } return sentinels; } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/Internal/ConjectureData.cs b/src/Conjecture.Core/Internal/ConjectureData.cs index cb13b8b..9e43247 100644 --- a/src/Conjecture.Core/Internal/ConjectureData.cs +++ b/src/Conjecture.Core/Internal/ConjectureData.cs @@ -121,9 +121,15 @@ internal void InsertCommandStart() internal void RecordObservation(string label, double value) { if (frozen) + { throw new InvalidOperationException("Cannot record observations on frozen ConjectureData."); + } + if (double.IsNaN(value) || double.IsInfinity(value)) + { throw new ArgumentException("Observation value must be finite.", nameof(value)); + } + observations[label] = value; } diff --git a/src/Conjecture.Core/Internal/ExampleDatabase.cs b/src/Conjecture.Core/Internal/ExampleDatabase.cs index a145828..4f9b1ea 100644 --- a/src/Conjecture.Core/Internal/ExampleDatabase.cs +++ b/src/Conjecture.Core/Internal/ExampleDatabase.cs @@ -149,4 +149,4 @@ public void Dispose() { connection?.Dispose(); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/Internal/FloatSimplificationPass.cs b/src/Conjecture.Core/Internal/FloatSimplificationPass.cs index e5e2d47..df2e031 100644 --- a/src/Conjecture.Core/Internal/FloatSimplificationPass.cs +++ b/src/Conjecture.Core/Internal/FloatSimplificationPass.cs @@ -42,7 +42,7 @@ private static async ValueTask TryReduceAt64(ShrinkState state, int index, ulong bits = node.Value; foreach (ulong candidate in Candidates64(bits)) { - IRNode[] arr = [..state.Nodes]; + IRNode[] arr = [.. state.Nodes]; arr[index] = IRNode.ForFloat64(candidate, node.Min, node.Max); if (await state.TryUpdate(arr)) { @@ -57,7 +57,7 @@ private static async ValueTask TryReduceAt32(ShrinkState state, int index, ulong bits = node.Value; foreach (ulong candidate in Candidates32(bits)) { - IRNode[] arr = [..state.Nodes]; + IRNode[] arr = [.. state.Nodes]; arr[index] = IRNode.ForFloat32(candidate, node.Min, node.Max); if (await state.TryUpdate(arr)) { diff --git a/src/Conjecture.Core/Internal/HillClimber.cs b/src/Conjecture.Core/Internal/HillClimber.cs index ebf9aad..6530570 100644 --- a/src/Conjecture.Core/Internal/HillClimber.cs +++ b/src/Conjecture.Core/Internal/HillClimber.cs @@ -33,12 +33,16 @@ internal static class HillClimber { var node = bestNodes[i]; if (!node.IsIntegerLike) + { continue; + } foreach (var candidateValue in CandidateValues(node)) { if (remaining <= 0) + { break; + } remaining--; var candidate = Mutate(bestNodes, i, candidateValue); @@ -58,11 +62,15 @@ internal static class HillClimber } if (greedyImproved) + { continue; + } // Greedy stalled — try random perturbation if rng provided. if (rng is null) + { break; + } var perturbImproved = false; while (remaining > 0 && !perturbImproved) @@ -83,7 +91,9 @@ internal static class HillClimber } if (!perturbImproved) + { break; + } } return (bestNodes, bestScore); @@ -93,11 +103,17 @@ private static List Perturb(List nodes, IRandom rng) { var integerLikeIndices = new List(); for (var i = 0; i < nodes.Count; i++) + { if (nodes[i].IsIntegerLike) + { integerLikeIndices.Add(i); + } + } if (integerLikeIndices.Count == 0) + { return nodes.ToList(); + } var count = (int)(rng.NextUInt64() % (ulong)Math.Min(3, integerLikeIndices.Count)) + 1; var result = nodes.ToList(); @@ -115,18 +131,20 @@ private static List Perturb(List nodes, IRandom rng) private static ulong RandomInRange(IRandom rng, ulong min, ulong max) { var range = max - min; - if (range == ulong.MaxValue) - return rng.NextUInt64(); - return min + rng.NextUInt64() % (range + 1); + return range == ulong.MaxValue ? rng.NextUInt64() : min + rng.NextUInt64() % (range + 1); } private static IEnumerable CandidateValues(IRNode node) { if (node.Value < node.Max) + { yield return node.Value + 1; + } if (node.Value > node.Min) + { yield return node.Value - 1; + } if (node.Value < node.Max) { diff --git a/src/Conjecture.Core/Internal/Log.cs b/src/Conjecture.Core/Internal/Log.cs index a28b1f2..fa6a081 100644 --- a/src/Conjecture.Core/Internal/Log.cs +++ b/src/Conjecture.Core/Internal/Log.cs @@ -54,4 +54,4 @@ internal static partial class Log [LoggerMessage(EventId = 12, Level = LogLevel.Debug, Message = "Targeting step: label={Label} improved to score={NewScore}")] internal static partial void TargetingStepImproved(ILogger logger, string label, double newScore); -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/Internal/RedistributionPass.cs b/src/Conjecture.Core/Internal/RedistributionPass.cs index 598182a..b2f1cd1 100644 --- a/src/Conjecture.Core/Internal/RedistributionPass.cs +++ b/src/Conjecture.Core/Internal/RedistributionPass.cs @@ -24,7 +24,7 @@ public async ValueTask TryReduce(ShrinkState state) for (ulong delta = 1; delta <= maxShift; delta++) { - IRNode[] candidate = [..state.Nodes]; + IRNode[] candidate = [.. state.Nodes]; candidate[i] = IRNode.ForInteger(state.Nodes[i].Value - delta, state.Nodes[i].Min, state.Nodes[i].Max); candidate[i + 1] = IRNode.ForInteger(state.Nodes[i + 1].Value + delta, state.Nodes[i + 1].Min, state.Nodes[i + 1].Max); if (await state.TryUpdate(candidate)) diff --git a/src/Conjecture.Core/Internal/SharedParameterStrategyResolver.cs b/src/Conjecture.Core/Internal/SharedParameterStrategyResolver.cs index c7acaa3..d99f9e7 100644 --- a/src/Conjecture.Core/Internal/SharedParameterStrategyResolver.cs +++ b/src/Conjecture.Core/Internal/SharedParameterStrategyResolver.cs @@ -159,18 +159,18 @@ private static object GenerateValue(Type type, ConjectureData data) { return type switch { - _ when type == typeof(int) => Generate.Integers().Generate(data), - _ when type == typeof(long) => Generate.Integers().Generate(data), - _ when type == typeof(byte) => Generate.Integers().Generate(data), - _ when type == typeof(bool) => Generate.Booleans().Generate(data), - _ when type == typeof(string) => Generate.Strings().Generate(data), - _ when type == typeof(float) => Generate.Floats().Generate(data), - _ when type == typeof(double) => Generate.Doubles().Generate(data), + _ when type == typeof(int) => Generate.Integers().Generate(data), + _ when type == typeof(long) => Generate.Integers().Generate(data), + _ when type == typeof(byte) => Generate.Integers().Generate(data), + _ when type == typeof(bool) => Generate.Booleans().Generate(data), + _ when type == typeof(string) => Generate.Strings().Generate(data), + _ when type == typeof(float) => Generate.Floats().Generate(data), + _ when type == typeof(double) => Generate.Doubles().Generate(data), _ when type == typeof(List) => Generate.Lists(Generate.Integers()).Generate(data), - { IsEnum: true } => GenerateEnum(type, data), + { IsEnum: true } => GenerateEnum(type, data), _ when Nullable.GetUnderlyingType(type) is { } u => data.NextInteger(0, 9) == 0 ? null! : GenerateValue(u, data), - _ => throw new NotSupportedException($"No strategy registered for parameter type '{type.FullName}'.") + _ => throw new NotSupportedException($"No strategy registered for parameter type '{type.FullName}'.") }; } diff --git a/src/Conjecture.Core/Internal/Shrinker.cs b/src/Conjecture.Core/Internal/Shrinker.cs index 720e392..9b394bc 100644 --- a/src/Conjecture.Core/Internal/Shrinker.cs +++ b/src/Conjecture.Core/Internal/Shrinker.cs @@ -5,6 +5,7 @@ // Original copyright: Copyright (c) 2013-present, David R. MacIver and contributors. using System.Diagnostics; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; diff --git a/src/Conjecture.Core/Internal/StateMachineRunner.cs b/src/Conjecture.Core/Internal/StateMachineRunner.cs index 4fd5459..a4ee9c0 100644 --- a/src/Conjecture.Core/Internal/StateMachineRunner.cs +++ b/src/Conjecture.Core/Internal/StateMachineRunner.cs @@ -58,4 +58,4 @@ internal static string FormatSteps(IReadOnlyList> s } return sb.ToString().TrimEnd(); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/Internal/StringAwarePass.cs b/src/Conjecture.Core/Internal/StringAwarePass.cs index e618913..cd577e0 100644 --- a/src/Conjecture.Core/Internal/StringAwarePass.cs +++ b/src/Conjecture.Core/Internal/StringAwarePass.cs @@ -94,7 +94,7 @@ private static async ValueTask TrySimplifyChar(ShrinkState state, int char { continue; } - IRNode[] candidate = [..state.Nodes]; + IRNode[] candidate = [.. state.Nodes]; candidate[charIndex] = IRNode.ForStringChar(target, charNode.Min, charNode.Max); if (await state.TryUpdate(candidate)) { diff --git a/src/Conjecture.Core/Internal/TestOutputHelperLogger.cs b/src/Conjecture.Core/Internal/TestOutputHelperLogger.cs index a658a78..956bad3 100644 --- a/src/Conjecture.Core/Internal/TestOutputHelperLogger.cs +++ b/src/Conjecture.Core/Internal/TestOutputHelperLogger.cs @@ -34,4 +34,4 @@ public IDisposable BeginScope(TState state) where TState : notnull { return NullLogger.Instance.BeginScope(state)!; } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/Internal/TestRunner.cs b/src/Conjecture.Core/Internal/TestRunner.cs index a36b6c8..5e97080 100644 --- a/src/Conjecture.Core/Internal/TestRunner.cs +++ b/src/Conjecture.Core/Internal/TestRunner.cs @@ -5,6 +5,7 @@ // Original copyright: Copyright (c) 2013-present, David R. MacIver and contributors. using System.Diagnostics; + using Microsoft.Extensions.Logging; namespace Conjecture.Core.Internal; @@ -105,7 +106,9 @@ private static async Task RunGenerationCore( // or when we've exhausted the full MaxExamples budget. bool atGenerationBudget = valid >= generationBudget && bestPerLabel.Count > 0; if (valid >= settings.MaxExamples || atGenerationBudget) + { break; + } totalAttempts++; ConjectureData data = ConjectureData.ForGeneration(rng.Split()); @@ -126,7 +129,9 @@ private static async Task RunGenerationCore( foreach (var (label, score) in data.Observations) { if (!bestPerLabel.TryGetValue(label, out var current) || score > current.Score) + { bestPerLabel[label] = (data.IRNodes, score); + } } if (sw is not null && sw.Elapsed > deadline!.Value) @@ -198,7 +203,10 @@ private static async Task RunGenerationCore( { var (status, obs) = await ReplayAndObserveAsync(nodes, test); if (status == Status.Interesting) + { failingNodes = nodes; + } + return (status, obs); } @@ -227,7 +235,10 @@ private static async Task RunGenerationCore( (IReadOnlyList shrunk, int shrinkCount) = await Shrinker.ShrinkAsync( failingNodes, n => ReplayAsync(n, test), logger); if (dbContext is DbContext ctx) + { ctx.Database.Save(ctx.TestIdHash, SerializeNodes(shrunk)); + } + Log.PropertyTestFailure(logger, valid + 1, $"0x{seed:X16}"); return TestRunResult.Fail(shrunk, failingNodes, seed, valid + 1, shrinkCount); } diff --git a/src/Conjecture.Core/RecursiveStrategy.cs b/src/Conjecture.Core/RecursiveStrategy.cs index 6a35f09..6660831 100644 --- a/src/Conjecture.Core/RecursiveStrategy.cs +++ b/src/Conjecture.Core/RecursiveStrategy.cs @@ -34,4 +34,4 @@ internal override T Generate(ConjectureData data) Strategy expanded = recursive(next); return expanded.Generate(data); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/StateMachineFormatter.cs b/src/Conjecture.Core/StateMachineFormatter.cs index 6b97773..1bbc14f 100644 --- a/src/Conjecture.Core/StateMachineFormatter.cs +++ b/src/Conjecture.Core/StateMachineFormatter.cs @@ -37,4 +37,4 @@ public string Format(StateMachineRun value) sb.Append("Invariant(state); // \u2190 fails here"); return sb.ToString(); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/StateMachineRun.cs b/src/Conjecture.Core/StateMachineRun.cs index 292a9c0..0fffd67 100644 --- a/src/Conjecture.Core/StateMachineRun.cs +++ b/src/Conjecture.Core/StateMachineRun.cs @@ -36,4 +36,4 @@ public sealed class StateMachineRun( /// Gets a value indicating whether the run completed without an invariant violation. /// public bool Passed => FailureStepIndex is null; -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/StateMachineStrategy.cs b/src/Conjecture.Core/StateMachineStrategy.cs index 99ab077..cfa1801 100644 --- a/src/Conjecture.Core/StateMachineStrategy.cs +++ b/src/Conjecture.Core/StateMachineStrategy.cs @@ -5,6 +5,7 @@ // Original copyright: Copyright (c) 2013-present, David R. MacIver and contributors. using System.Collections.Generic; + using Conjecture.Core.Internal; namespace Conjecture.Core; @@ -29,7 +30,7 @@ internal override StateMachineRun Generate(ConjectureData data) for (int i = 0; i < length; i++) { - Strategy[] commands = [..machine.Commands(state)]; + Strategy[] commands = [.. machine.Commands(state)]; if (commands.Length == 0) { break; @@ -49,4 +50,4 @@ internal override StateMachineRun Generate(ConjectureData data) } return run; } -} +} \ No newline at end of file diff --git a/src/Conjecture.Core/Target.cs b/src/Conjecture.Core/Target.cs index 5442f41..8983dbd 100644 --- a/src/Conjecture.Core/Target.cs +++ b/src/Conjecture.Core/Target.cs @@ -30,4 +30,4 @@ public static void Minimize(double observation, string label = "default") { Maximize(-observation, label); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Formatters.Tests/IOutputFormatterTests.cs b/src/Conjecture.Formatters.Tests/IOutputFormatterTests.cs index 890f85f..0a7bbc5 100644 --- a/src/Conjecture.Formatters.Tests/IOutputFormatterTests.cs +++ b/src/Conjecture.Formatters.Tests/IOutputFormatterTests.cs @@ -29,4 +29,4 @@ public Task WriteAsync(IEnumerable data, Stream output, CancellationToken return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/src/Conjecture.Formatters.Tests/JsonLinesOutputFormatterTests.cs b/src/Conjecture.Formatters.Tests/JsonLinesOutputFormatterTests.cs index 3d7b19c..b2e8195 100644 --- a/src/Conjecture.Formatters.Tests/JsonLinesOutputFormatterTests.cs +++ b/src/Conjecture.Formatters.Tests/JsonLinesOutputFormatterTests.cs @@ -3,6 +3,7 @@ using System.Text; using System.Text.Json; + using Conjecture.Formatters; namespace Conjecture.Formatters.Tests; @@ -44,4 +45,4 @@ public async Task WriteAsync_EmptyInput_WritesNothing() Assert.Equal(0, stream.Length); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Formatters.Tests/JsonOutputFormatterTests.cs b/src/Conjecture.Formatters.Tests/JsonOutputFormatterTests.cs index e941dc0..1d2b942 100644 --- a/src/Conjecture.Formatters.Tests/JsonOutputFormatterTests.cs +++ b/src/Conjecture.Formatters.Tests/JsonOutputFormatterTests.cs @@ -3,6 +3,7 @@ using System.Text; using System.Text.Json; + using Conjecture.Formatters; namespace Conjecture.Formatters.Tests; @@ -41,4 +42,4 @@ public async Task WriteAsync_EmptyInput_WritesEmptyArray() Assert.Equal("[]", Encoding.UTF8.GetString(stream.ToArray())); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Formatters/JsonFormatterOptions.cs b/src/Conjecture.Formatters/JsonFormatterOptions.cs index a52656c..e694aa3 100644 --- a/src/Conjecture.Formatters/JsonFormatterOptions.cs +++ b/src/Conjecture.Formatters/JsonFormatterOptions.cs @@ -11,4 +11,4 @@ internal static class JsonFormatterOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }; -} +} \ No newline at end of file diff --git a/src/Conjecture.Formatters/JsonLinesOutputFormatter.cs b/src/Conjecture.Formatters/JsonLinesOutputFormatter.cs index d644536..7450cc9 100644 --- a/src/Conjecture.Formatters/JsonLinesOutputFormatter.cs +++ b/src/Conjecture.Formatters/JsonLinesOutputFormatter.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Text.Json; + using Conjecture.Core; namespace Conjecture.Formatters; @@ -23,4 +24,4 @@ public async Task WriteAsync(IEnumerable data, Stream output, Cancellation await writer.FlushAsync(ct); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Formatters/JsonOutputFormatter.cs b/src/Conjecture.Formatters/JsonOutputFormatter.cs index a26bcf1..25bbb48 100644 --- a/src/Conjecture.Formatters/JsonOutputFormatter.cs +++ b/src/Conjecture.Formatters/JsonOutputFormatter.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Text.Json; + using Conjecture.Core; namespace Conjecture.Formatters; @@ -17,4 +18,4 @@ public async Task WriteAsync(IEnumerable data, Stream output, Cancellation { await JsonSerializer.SerializeAsync(output, data, JsonFormatterOptions.Default, ct); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Generators.Tests/ClassAndStructGeneratorTests.cs b/src/Conjecture.Generators.Tests/ClassAndStructGeneratorTests.cs index 19a9943..18e678e 100644 --- a/src/Conjecture.Generators.Tests/ClassAndStructGeneratorTests.cs +++ b/src/Conjecture.Generators.Tests/ClassAndStructGeneratorTests.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Conjecture.Generators.Tests/GeneratorDiagnosticTests.cs b/src/Conjecture.Generators.Tests/GeneratorDiagnosticTests.cs index ab0f581..4c1d5f1 100644 --- a/src/Conjecture.Generators.Tests/GeneratorDiagnosticTests.cs +++ b/src/Conjecture.Generators.Tests/GeneratorDiagnosticTests.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Conjecture.Generators.Tests/GeneratorInfrastructureTests.cs b/src/Conjecture.Generators.Tests/GeneratorInfrastructureTests.cs index 60a11ff..ca701e0 100644 --- a/src/Conjecture.Generators.Tests/GeneratorInfrastructureTests.cs +++ b/src/Conjecture.Generators.Tests/GeneratorInfrastructureTests.cs @@ -1,9 +1,10 @@ // Copyright (c) 2026 Kim Ommundsen. Licensed under the MPL-2.0. // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ +using Conjecture.Generators; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -using Conjecture.Generators; namespace Conjecture.Generators.Tests; diff --git a/src/Conjecture.Generators.Tests/NestedTypeGeneratorTests.cs b/src/Conjecture.Generators.Tests/NestedTypeGeneratorTests.cs index 447334c..fed9f3e 100644 --- a/src/Conjecture.Generators.Tests/NestedTypeGeneratorTests.cs +++ b/src/Conjecture.Generators.Tests/NestedTypeGeneratorTests.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Conjecture.Generators.Tests/SimpleRecordGeneratorTests.cs b/src/Conjecture.Generators.Tests/SimpleRecordGeneratorTests.cs index eaeb114..cc7d853 100644 --- a/src/Conjecture.Generators.Tests/SimpleRecordGeneratorTests.cs +++ b/src/Conjecture.Generators.Tests/SimpleRecordGeneratorTests.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Conjecture.Generators.Tests/TrimSafeGeneratorTests.cs b/src/Conjecture.Generators.Tests/TrimSafeGeneratorTests.cs index 49c56d9..54d63b3 100644 --- a/src/Conjecture.Generators.Tests/TrimSafeGeneratorTests.cs +++ b/src/Conjecture.Generators.Tests/TrimSafeGeneratorTests.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Conjecture.Generators.Tests/TypeModelExtractionTests.cs b/src/Conjecture.Generators.Tests/TypeModelExtractionTests.cs index fd812f1..31ca873 100644 --- a/src/Conjecture.Generators.Tests/TypeModelExtractionTests.cs +++ b/src/Conjecture.Generators.Tests/TypeModelExtractionTests.cs @@ -4,9 +4,11 @@ using System.Collections.Immutable; using System.IO; using System.Linq; + +using Conjecture.Generators; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -using Conjecture.Generators; namespace Conjecture.Generators.Tests; diff --git a/src/Conjecture.Generators/Conjecture.Generators.csproj b/src/Conjecture.Generators/Conjecture.Generators.csproj index 2606cf6..78cbc04 100644 --- a/src/Conjecture.Generators/Conjecture.Generators.csproj +++ b/src/Conjecture.Generators/Conjecture.Generators.csproj @@ -13,8 +13,6 @@ - - diff --git a/src/Conjecture.Generators/StrategyEmitter.cs b/src/Conjecture.Generators/StrategyEmitter.cs index ea3fa5a..9ce4f50 100644 --- a/src/Conjecture.Generators/StrategyEmitter.cs +++ b/src/Conjecture.Generators/StrategyEmitter.cs @@ -10,13 +10,13 @@ internal static class StrategyEmitter { private static readonly Dictionary PrimitiveData = new() { - ["System.Int32"] = ("global::Conjecture.Core.Generate.Integers()", "int"), - ["System.Int64"] = ("global::Conjecture.Core.Generate.Integers()", "long"), - ["System.Byte"] = ("global::Conjecture.Core.Generate.Integers()", "byte"), - ["System.Boolean"] = ("global::Conjecture.Core.Generate.Booleans()", "bool"), - ["System.String"] = ("global::Conjecture.Core.Generate.Strings()", "string"), - ["System.Double"] = ("global::Conjecture.Core.Generate.Doubles()", "double"), - ["System.Single"] = ("global::Conjecture.Core.Generate.Floats()", "float"), + ["System.Int32"] = ("global::Conjecture.Core.Generate.Integers()", "int"), + ["System.Int64"] = ("global::Conjecture.Core.Generate.Integers()", "long"), + ["System.Byte"] = ("global::Conjecture.Core.Generate.Integers()", "byte"), + ["System.Boolean"] = ("global::Conjecture.Core.Generate.Booleans()", "bool"), + ["System.String"] = ("global::Conjecture.Core.Generate.Strings()", "string"), + ["System.Double"] = ("global::Conjecture.Core.Generate.Doubles()", "double"), + ["System.Single"] = ("global::Conjecture.Core.Generate.Floats()", "float"), }; internal static string Emit(TypeModel model) diff --git a/src/Conjecture.Generators/TypeModel.cs b/src/Conjecture.Generators/TypeModel.cs index a7cdedf..1f3889d 100644 --- a/src/Conjecture.Generators/TypeModel.cs +++ b/src/Conjecture.Generators/TypeModel.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Immutable; + using Microsoft.CodeAnalysis; namespace Conjecture.Generators; diff --git a/src/Conjecture.Generators/TypeModelExtractor.cs b/src/Conjecture.Generators/TypeModelExtractor.cs index 2b6e54e..f89095a 100644 --- a/src/Conjecture.Generators/TypeModelExtractor.cs +++ b/src/Conjecture.Generators/TypeModelExtractor.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Immutable; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/Conjecture.MSTest.Tests/EndToEnd/MSTestAdapterE2ETests.cs b/src/Conjecture.MSTest.Tests/EndToEnd/MSTestAdapterE2ETests.cs index 885b820..e19c9ab 100644 --- a/src/Conjecture.MSTest.Tests/EndToEnd/MSTestAdapterE2ETests.cs +++ b/src/Conjecture.MSTest.Tests/EndToEnd/MSTestAdapterE2ETests.cs @@ -2,8 +2,10 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Conjecture.MSTest.Tests.EndToEnd; diff --git a/src/Conjecture.MSTest.Tests/EndToEnd/SourceGeneratorMSTestE2ETests.cs b/src/Conjecture.MSTest.Tests/EndToEnd/SourceGeneratorMSTestE2ETests.cs index e02a8e9..2618a81 100644 --- a/src/Conjecture.MSTest.Tests/EndToEnd/SourceGeneratorMSTestE2ETests.cs +++ b/src/Conjecture.MSTest.Tests/EndToEnd/SourceGeneratorMSTestE2ETests.cs @@ -2,9 +2,12 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using ConjectureProperty = Conjecture.MSTest.PropertyAttribute; namespace Conjecture.MSTest.Tests.EndToEnd; diff --git a/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTargetingTests.cs b/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTargetingTests.cs index beca6f9..b15f76c 100644 --- a/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTargetingTests.cs +++ b/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTargetingTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Microsoft.VisualStudio.TestTools.UnitTesting; + using ConjecturePropertyAttribute = Conjecture.MSTest.PropertyAttribute; namespace Conjecture.MSTest.Tests; @@ -40,4 +41,4 @@ public void TargetingProportion_CanBeSet() Assert.AreEqual(0.25, attr.TargetingProportion); } -} +} \ No newline at end of file diff --git a/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTests.cs b/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTests.cs index f3e3d2c..3c50481 100644 --- a/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTests.cs +++ b/src/Conjecture.MSTest.Tests/MSTestPropertyAttributeTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Microsoft.VisualStudio.TestTools.UnitTesting; + using ConjecturePropertyAttribute = Conjecture.MSTest.PropertyAttribute; namespace Conjecture.MSTest.Tests; diff --git a/src/Conjecture.MSTest.Tests/MSTestPropertyExecutionTests.cs b/src/Conjecture.MSTest.Tests/MSTestPropertyExecutionTests.cs index c828f07..f5a97ce 100644 --- a/src/Conjecture.MSTest.Tests/MSTestPropertyExecutionTests.cs +++ b/src/Conjecture.MSTest.Tests/MSTestPropertyExecutionTests.cs @@ -2,9 +2,11 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.MSTest; + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Conjecture.MSTest.Tests; diff --git a/src/Conjecture.MSTest.Tests/MSTestReportingTests.cs b/src/Conjecture.MSTest.Tests/MSTestReportingTests.cs index 1507665..4b78fa1 100644 --- a/src/Conjecture.MSTest.Tests/MSTestReportingTests.cs +++ b/src/Conjecture.MSTest.Tests/MSTestReportingTests.cs @@ -2,8 +2,10 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Conjecture.MSTest.Tests; diff --git a/src/Conjecture.MSTest.Tests/PropertyAttributeLoggingTests.cs b/src/Conjecture.MSTest.Tests/PropertyAttributeLoggingTests.cs index e69da45..d88752f 100644 --- a/src/Conjecture.MSTest.Tests/PropertyAttributeLoggingTests.cs +++ b/src/Conjecture.MSTest.Tests/PropertyAttributeLoggingTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -56,4 +57,4 @@ public async Task TestRunner_WithNullWriteLine_DoesNotThrow() await TestRunner.Run(settings, _ => { }); } -} +} \ No newline at end of file diff --git a/src/Conjecture.MSTest.Tests/StateMachine/StateMachineReportingTests.cs b/src/Conjecture.MSTest.Tests/StateMachine/StateMachineReportingTests.cs index fc156a0..6c8d8f2 100644 --- a/src/Conjecture.MSTest.Tests/StateMachine/StateMachineReportingTests.cs +++ b/src/Conjecture.MSTest.Tests/StateMachine/StateMachineReportingTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Conjecture.MSTest.Tests.StateMachine; @@ -79,4 +80,4 @@ public async Task StatefulProperty_ShrinkCount_IsReportedInResult() Assert.IsFalse(result.Passed); Assert.IsTrue(result.ShrinkCount > 0, $"Expected shrink count > 0, got {result.ShrinkCount}."); } -} +} \ No newline at end of file diff --git a/src/Conjecture.MSTest/PropertyAttribute.cs b/src/Conjecture.MSTest/PropertyAttribute.cs index 9bf1525..78f9503 100644 --- a/src/Conjecture.MSTest/PropertyAttribute.cs +++ b/src/Conjecture.MSTest/PropertyAttribute.cs @@ -5,8 +5,10 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; + using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Conjecture.Mcp.Tests/Tools/ShrinkOutputToolsTests.cs b/src/Conjecture.Mcp.Tests/Tools/ShrinkOutputToolsTests.cs index e18f6fb..2f26a86 100644 --- a/src/Conjecture.Mcp.Tests/Tools/ShrinkOutputToolsTests.cs +++ b/src/Conjecture.Mcp.Tests/Tools/ShrinkOutputToolsTests.cs @@ -74,4 +74,4 @@ public void Parse_UnrecognizedInput_ReturnsFormatHelp() var result = ShrinkOutputTools.Parse("Some random text with no Conjecture formatting"); Assert.Contains("parse", result, StringComparison.OrdinalIgnoreCase); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Mcp.Tests/Tools/StrategyToolsTests.cs b/src/Conjecture.Mcp.Tests/Tools/StrategyToolsTests.cs index 3868ce7..4888fd1 100644 --- a/src/Conjecture.Mcp.Tests/Tools/StrategyToolsTests.cs +++ b/src/Conjecture.Mcp.Tests/Tools/StrategyToolsTests.cs @@ -65,4 +65,4 @@ public void SuggestForType_CustomType_MentionsCompose() var result = StrategyTools.SuggestForType("MyRecord"); Assert.Contains("Generate.Compose", result); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Mcp.Tests/Tools/TestScaffoldingToolsTests.cs b/src/Conjecture.Mcp.Tests/Tools/TestScaffoldingToolsTests.cs index 1f7943d..6b17a79 100644 --- a/src/Conjecture.Mcp.Tests/Tools/TestScaffoldingToolsTests.cs +++ b/src/Conjecture.Mcp.Tests/Tools/TestScaffoldingToolsTests.cs @@ -60,4 +60,4 @@ public void ScaffoldPropertyTest_MSTest_UsesMSTestNamespace() var result = TestScaffoldingTools.ScaffoldPropertyTest("void Test(int x)", framework: "mstest"); Assert.Contains("Conjecture.MSTest", result); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Mcp/Program.cs b/src/Conjecture.Mcp/Program.cs index 04399ce..1dd7924 100644 --- a/src/Conjecture.Mcp/Program.cs +++ b/src/Conjecture.Mcp/Program.cs @@ -2,8 +2,10 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Mcp.Resources; + using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; + using ModelContextProtocol.Server; var builder = Host.CreateApplicationBuilder(args); @@ -15,4 +17,4 @@ .WithListResourcesHandler(ApiReferenceResources.HandleListResources) .WithReadResourceHandler(ApiReferenceResources.HandleReadResource); -await builder.Build().RunAsync(); +await builder.Build().RunAsync(); \ No newline at end of file diff --git a/src/Conjecture.Mcp/Resources/ApiReferenceResources.cs b/src/Conjecture.Mcp/Resources/ApiReferenceResources.cs index 13d7b02..c3bc772 100644 --- a/src/Conjecture.Mcp/Resources/ApiReferenceResources.cs +++ b/src/Conjecture.Mcp/Resources/ApiReferenceResources.cs @@ -3,6 +3,7 @@ using System.IO; using System.Reflection; + using ModelContextProtocol.Protocol; using ModelContextProtocol.Server; @@ -23,7 +24,7 @@ internal static class ApiReferenceResources ]; internal static ValueTask HandleListResources( - RequestContext context, CancellationToken cancellationToken) + RequestContext _, CancellationToken __) { var resources = Topics.Select(t => new Resource { @@ -37,7 +38,7 @@ internal static ValueTask HandleListResources( } internal static ValueTask HandleReadResource( - RequestContext context, CancellationToken cancellationToken) + RequestContext context, CancellationToken _) { var uri = context.Params?.Uri ?? string.Empty; const string prefix = "conjecture://api/"; @@ -73,4 +74,4 @@ private static string LoadDoc(string topic) using var reader = new StreamReader(stream); return reader.ReadToEnd(); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Mcp/Tools/ShrinkOutputTools.cs b/src/Conjecture.Mcp/Tools/ShrinkOutputTools.cs index 74a250f..654463d 100644 --- a/src/Conjecture.Mcp/Tools/ShrinkOutputTools.cs +++ b/src/Conjecture.Mcp/Tools/ShrinkOutputTools.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Text; using System.Text.RegularExpressions; + using ModelContextProtocol.Server; namespace Conjecture.Mcp.Tools; @@ -31,10 +32,7 @@ internal static class ShrinkOutputTools public static string ExplainShrinkOutput( [Description("The Conjecture failure output text from a failed [Property] test")] string failureOutput) { - if (string.IsNullOrWhiteSpace(failureOutput)) - return "No output provided."; - - return Parse(failureOutput); + return string.IsNullOrWhiteSpace(failureOutput) ? "No output provided." : Parse(failureOutput); } internal static string Parse(string output) @@ -64,7 +62,10 @@ internal static string Parse(string output) { exampleCount = int.Parse(summaryMatch.Groups["examples"].Value); if (summaryMatch.Groups["shrinks"].Success) + { shrinkCount = int.Parse(summaryMatch.Groups["shrinks"].Value); + } + currentSection = "original"; continue; } @@ -113,7 +114,9 @@ internal static string Parse(string output) sb.AppendLine(); sb.AppendLine("**Failing values:**"); foreach (var (name, value) in originalParams) + { sb.AppendLine($"- `{name}` = `{value}`"); + } } sb.AppendLine(); @@ -145,7 +148,9 @@ internal static string Parse(string output) { sb.AppendLine($"**Shrinking:** The failing input was simplified **{shrinkCount} time{(shrinkCount == 1 ? "" : "s")}** to find the minimal counterexample."); if (shrinkCount == 0) + { sb.AppendLine(" (The first failing example was already minimal — no simplification was needed.)"); + } } } @@ -155,7 +160,9 @@ internal static string Parse(string output) sb.AppendLine(); sb.AppendLine(shrunkParams.Count > 0 ? "**Minimal counterexample (after shrinking):**" : "**Failing input:**"); foreach (var (name, value) in displayParams) + { sb.AppendLine($"- `{name}` = `{value}`"); + } sb.AppendLine(); sb.AppendLine( @@ -168,7 +175,9 @@ internal static string Parse(string output) sb.AppendLine(); sb.AppendLine("**Original (unshrunk) failing input:**"); foreach (var (name, value) in originalParams) + { sb.AppendLine($"- `{name}` = `{value}`"); + } } if (seed is not null) @@ -185,4 +194,4 @@ internal static string Parse(string output) return sb.ToString(); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Mcp/Tools/StrategyTools.cs b/src/Conjecture.Mcp/Tools/StrategyTools.cs index f447cba..bff1010 100644 --- a/src/Conjecture.Mcp/Tools/StrategyTools.cs +++ b/src/Conjecture.Mcp/Tools/StrategyTools.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.ComponentModel; + using ModelContextProtocol.Server; namespace Conjecture.Mcp.Tools; @@ -198,4 +199,4 @@ private static string InnerType(string typeName) var start = typeName.IndexOf('<') + 1; return typeName[start..^1]; } -} +} \ No newline at end of file diff --git a/src/Conjecture.Mcp/Tools/TestScaffoldingTools.cs b/src/Conjecture.Mcp/Tools/TestScaffoldingTools.cs index e394df0..20f2ce6 100644 --- a/src/Conjecture.Mcp/Tools/TestScaffoldingTools.cs +++ b/src/Conjecture.Mcp/Tools/TestScaffoldingTools.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Text; + using ModelContextProtocol.Server; namespace Conjecture.Mcp.Tools; @@ -29,11 +30,15 @@ public static string ScaffoldPropertyTest( var parenStart = signature.IndexOf('('); var parenEnd = signature.LastIndexOf(')'); if (parenStart < 0 || parenEnd < 0 || parenEnd <= parenStart) + { return []; + } var paramSection = signature[(parenStart + 1)..parenEnd].Trim(); if (string.IsNullOrWhiteSpace(paramSection)) + { return []; + } var results = new List<(string, string)>(); foreach (var chunk in SplitParams(paramSection)) @@ -44,16 +49,23 @@ public static string ScaffoldPropertyTest( { var closeAttr = part.IndexOf(']'); if (closeAttr >= 0) + { part = part[(closeAttr + 1)..].Trim(); + } } var lastSpace = part.LastIndexOf(' '); - if (lastSpace < 0) continue; + if (lastSpace < 0) + { + continue; + } var type = part[..lastSpace].Trim(); var name = part[(lastSpace + 1)..].Trim(); if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(name)) + { results.Add((type, name)); + } } return results; @@ -83,7 +95,11 @@ private static IEnumerable SplitParams(string paramSection) internal static string ParseMethodName(string signature) { var parenIdx = signature.IndexOf('('); - if (parenIdx < 0) return "Method"; + if (parenIdx < 0) + { + return "Method"; + } + var beforeParen = signature[..parenIdx]; var last = beforeParen.Split(' ', StringSplitOptions.RemoveEmptyEntries).Last(); return last; @@ -158,4 +174,4 @@ private static void AppendUsings(StringBuilder sb, string framework) break; } } -} +} \ No newline at end of file diff --git a/src/Conjecture.NUnit.Tests/EndToEnd/NUnitAdapterE2ETests.cs b/src/Conjecture.NUnit.Tests/EndToEnd/NUnitAdapterE2ETests.cs index 3562e4d..1779240 100644 --- a/src/Conjecture.NUnit.Tests/EndToEnd/NUnitAdapterE2ETests.cs +++ b/src/Conjecture.NUnit.Tests/EndToEnd/NUnitAdapterE2ETests.cs @@ -2,8 +2,10 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using NUnit.Framework; namespace Conjecture.NUnit.Tests.EndToEnd; diff --git a/src/Conjecture.NUnit.Tests/EndToEnd/SourceGeneratorNUnitE2ETests.cs b/src/Conjecture.NUnit.Tests/EndToEnd/SourceGeneratorNUnitE2ETests.cs index 42dc47c..2965c48 100644 --- a/src/Conjecture.NUnit.Tests/EndToEnd/SourceGeneratorNUnitE2ETests.cs +++ b/src/Conjecture.NUnit.Tests/EndToEnd/SourceGeneratorNUnitE2ETests.cs @@ -2,9 +2,12 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using NUnit.Framework; + using ConjectureProperty = Conjecture.NUnit.PropertyAttribute; namespace Conjecture.NUnit.Tests.EndToEnd; diff --git a/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTargetingTests.cs b/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTargetingTests.cs index 318758e..ac04a96 100644 --- a/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTargetingTests.cs +++ b/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTargetingTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using NUnit.Framework; + using ConjecturePropertyAttribute = Conjecture.NUnit.PropertyAttribute; namespace Conjecture.NUnit.Tests; @@ -40,4 +41,4 @@ public void TargetingProportion_CanBeSet() Assert.That(attr.TargetingProportion, Is.EqualTo(0.25)); } -} +} \ No newline at end of file diff --git a/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTests.cs b/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTests.cs index a893289..dd868ad 100644 --- a/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTests.cs +++ b/src/Conjecture.NUnit.Tests/NUnitPropertyAttributeTests.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using NUnit.Framework.Interfaces; + using ConjecturePropertyAttribute = Conjecture.NUnit.PropertyAttribute; namespace Conjecture.NUnit.Tests; diff --git a/src/Conjecture.NUnit.Tests/NUnitPropertyExecutionTests.cs b/src/Conjecture.NUnit.Tests/NUnitPropertyExecutionTests.cs index 17e21e7..48144bf 100644 --- a/src/Conjecture.NUnit.Tests/NUnitPropertyExecutionTests.cs +++ b/src/Conjecture.NUnit.Tests/NUnitPropertyExecutionTests.cs @@ -2,9 +2,11 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.NUnit; + using NUnit.Framework; namespace Conjecture.NUnit.Tests; diff --git a/src/Conjecture.NUnit.Tests/NUnitReportingTests.cs b/src/Conjecture.NUnit.Tests/NUnitReportingTests.cs index 3e5c672..4bc0184 100644 --- a/src/Conjecture.NUnit.Tests/NUnitReportingTests.cs +++ b/src/Conjecture.NUnit.Tests/NUnitReportingTests.cs @@ -2,8 +2,10 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using NUnit.Framework; namespace Conjecture.NUnit.Tests; diff --git a/src/Conjecture.NUnit.Tests/PropertyAttributeLoggingTests.cs b/src/Conjecture.NUnit.Tests/PropertyAttributeLoggingTests.cs index 18743c9..fc93435 100644 --- a/src/Conjecture.NUnit.Tests/PropertyAttributeLoggingTests.cs +++ b/src/Conjecture.NUnit.Tests/PropertyAttributeLoggingTests.cs @@ -3,7 +3,9 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; + using NUnit.Framework; namespace Conjecture.NUnit.Tests; @@ -56,4 +58,4 @@ public async Task TestRunner_WithNullWriteLine_DoesNotThrow() await TestRunner.Run(settings, _ => { }); } -} +} \ No newline at end of file diff --git a/src/Conjecture.NUnit.Tests/StateMachine/StateMachineReportingTests.cs b/src/Conjecture.NUnit.Tests/StateMachine/StateMachineReportingTests.cs index 5ca5496..a98dc82 100644 --- a/src/Conjecture.NUnit.Tests/StateMachine/StateMachineReportingTests.cs +++ b/src/Conjecture.NUnit.Tests/StateMachine/StateMachineReportingTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using NUnit.Framework; namespace Conjecture.NUnit.Tests.StateMachine; @@ -77,4 +78,4 @@ public async Task StatefulProperty_ShrinkCount_IsReportedInResult() Assert.That(result.Passed, Is.False); Assert.That(result.ShrinkCount, Is.GreaterThan(0), $"Expected shrink count > 0, got {result.ShrinkCount}."); } -} +} \ No newline at end of file diff --git a/src/Conjecture.NUnit/Internal/PropertyTestCommand.cs b/src/Conjecture.NUnit/Internal/PropertyTestCommand.cs index 4e33740..cb22d2b 100644 --- a/src/Conjecture.NUnit/Internal/PropertyTestCommand.cs +++ b/src/Conjecture.NUnit/Internal/PropertyTestCommand.cs @@ -3,14 +3,17 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; -using ILogger = Microsoft.Extensions.Logging.ILogger; + using NUnit.Framework; using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using NUnit.Framework.Internal.Commands; +using ILogger = Microsoft.Extensions.Logging.ILogger; + namespace Conjecture.NUnit.Internal; internal sealed class PropertyTestCommand : DelegatingTestCommand diff --git a/src/Conjecture.NUnit/PropertyAttribute.cs b/src/Conjecture.NUnit/PropertyAttribute.cs index ec96d05..575df2b 100644 --- a/src/Conjecture.NUnit/PropertyAttribute.cs +++ b/src/Conjecture.NUnit/PropertyAttribute.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.NUnit.Internal; + using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using NUnit.Framework.Internal.Builders; diff --git a/src/Conjecture.SelfTests/GeneratorSelfTests.cs b/src/Conjecture.SelfTests/GeneratorSelfTests.cs index 33f3db4..676ea21 100644 --- a/src/Conjecture.SelfTests/GeneratorSelfTests.cs +++ b/src/Conjecture.SelfTests/GeneratorSelfTests.cs @@ -4,6 +4,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.SelfTests; diff --git a/src/Conjecture.SelfTests/InfrastructureSelfTests.cs b/src/Conjecture.SelfTests/InfrastructureSelfTests.cs index 4423659..6dae4fa 100644 --- a/src/Conjecture.SelfTests/InfrastructureSelfTests.cs +++ b/src/Conjecture.SelfTests/InfrastructureSelfTests.cs @@ -4,6 +4,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit.V3; + using Xunit; using ShrinkEngine = Conjecture.Core.Internal.Shrinker; diff --git a/src/Conjecture.SelfTests/RecursiveStrategySelfTests.cs b/src/Conjecture.SelfTests/RecursiveStrategySelfTests.cs index b79e03f..57114d0 100644 --- a/src/Conjecture.SelfTests/RecursiveStrategySelfTests.cs +++ b/src/Conjecture.SelfTests/RecursiveStrategySelfTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Xunit; namespace Conjecture.SelfTests; @@ -22,7 +23,7 @@ public class RecursiveStrategySelfTests private static int ReplayDepth(IReadOnlyList nodes) { int depth = 0; - SelfTestHelpers.Replay(nodes, data => { depth = DepthCountingStrategy.Generate(data); }); + SelfTestHelpers.Replay(nodes, data => depth = DepthCountingStrategy.Generate(data)); return depth; } @@ -65,4 +66,4 @@ public async Task RecursiveStrategy_ShrunkValue_HasDepthAtMostOriginal() Assert.True(shrunkDepth <= originalDepth, $"Shrunk depth {shrunkDepth} exceeded original depth {originalDepth}"); } -} +} \ No newline at end of file diff --git a/src/Conjecture.SelfTests/ShrinkerInvariantTests.cs b/src/Conjecture.SelfTests/ShrinkerInvariantTests.cs index 735a545..a9ca745 100644 --- a/src/Conjecture.SelfTests/ShrinkerInvariantTests.cs +++ b/src/Conjecture.SelfTests/ShrinkerInvariantTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Xunit; using ShrinkEngine = Conjecture.Core.Internal.Shrinker; diff --git a/src/Conjecture.SelfTests/StateMachineSelfTests.cs b/src/Conjecture.SelfTests/StateMachineSelfTests.cs index 6a0e280..92038a7 100644 --- a/src/Conjecture.SelfTests/StateMachineSelfTests.cs +++ b/src/Conjecture.SelfTests/StateMachineSelfTests.cs @@ -2,8 +2,10 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Collections.Generic; + using Conjecture.Core; using Conjecture.Core.Internal; + using Xunit; using ShrinkEngine = Conjecture.Core.Internal.Shrinker; @@ -57,7 +59,9 @@ public int RunCommand(int state, CounterCommand cmd) => public void Invariant(int state) { if (state >= 3) + { throw new InvalidOperationException($"Counter exceeded threshold: {state}"); + } } } @@ -110,11 +114,14 @@ public async Task CommandSequenceShrinkPass_Idempotent_NoFurtherProgressAfterShr Assert.False(result.Passed); - Action property = data => _ = MachineStrategy().Generate(data); + static void Property(ConjectureData data) + { + _ = MachineStrategy().Generate(data); + } (IReadOnlyList _, int additionalShrinks) = await ShrinkEngine.ShrinkAsync( result.Counterexample!, - nodes => new ValueTask(SelfTestHelpers.Replay(nodes, property))); + nodes => new ValueTask(SelfTestHelpers.Replay(nodes, Property))); Assert.Equal(0, additionalShrinks); } -} +} \ No newline at end of file diff --git a/src/Conjecture.SelfTests/StrategyLawTests.cs b/src/Conjecture.SelfTests/StrategyLawTests.cs index ce6063d..7193516 100644 --- a/src/Conjecture.SelfTests/StrategyLawTests.cs +++ b/src/Conjecture.SelfTests/StrategyLawTests.cs @@ -4,6 +4,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.SelfTests; diff --git a/src/Conjecture.SelfTests/TargetingSelfTests.cs b/src/Conjecture.SelfTests/TargetingSelfTests.cs index d2aef5f..ea36955 100644 --- a/src/Conjecture.SelfTests/TargetingSelfTests.cs +++ b/src/Conjecture.SelfTests/TargetingSelfTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Xunit; namespace Conjecture.SelfTests; @@ -110,4 +111,4 @@ public async Task TargetingPhase_RecordedScores_AreAllFinite() $"Score for label '{kvp.Key}' is not finite: {kvp.Value}"); } } -} +} \ No newline at end of file diff --git a/src/Conjecture.Tool.Tests/AssemblyLoaderTests.cs b/src/Conjecture.Tool.Tests/AssemblyLoaderTests.cs index fd3f2bc..91debda 100644 --- a/src/Conjecture.Tool.Tests/AssemblyLoaderTests.cs +++ b/src/Conjecture.Tool.Tests/AssemblyLoaderTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Tool; @@ -97,4 +98,4 @@ public void ResolveByTargetType_UnknownType_ReturnsNull() Assert.Null(provider); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Tool.Tests/GenerateCommandTests.cs b/src/Conjecture.Tool.Tests/GenerateCommandTests.cs index 5dd6272..394069b 100644 --- a/src/Conjecture.Tool.Tests/GenerateCommandTests.cs +++ b/src/Conjecture.Tool.Tests/GenerateCommandTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Text.Json; + using Conjecture.Tool; namespace Conjecture.Tool.Tests; @@ -135,4 +136,4 @@ await Assert.ThrowsAsync(() => seed: 1UL, format: "json")); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Tool/AssemblyLoader.cs b/src/Conjecture.Tool/AssemblyLoader.cs index ea02ab2..1b8bf2f 100644 --- a/src/Conjecture.Tool/AssemblyLoader.cs +++ b/src/Conjecture.Tool/AssemblyLoader.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; namespace Conjecture.Tool; @@ -80,11 +81,6 @@ private static bool ImplementsIStrategyProvider(Type type) private static bool IsProviderForType(Type providerType, string typeName) { Type? targetType = GetProviderTargetType(providerType); - if (targetType is not null) - { - return targetType.FullName == typeName || targetType.Name == typeName; - } - - return false; + return targetType is not null && (targetType.FullName == typeName || targetType.Name == typeName); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Tool/Commands/GenerateCommand.cs b/src/Conjecture.Tool/Commands/GenerateCommand.cs index 7f6fd23..981be22 100644 --- a/src/Conjecture.Tool/Commands/GenerateCommand.cs +++ b/src/Conjecture.Tool/Commands/GenerateCommand.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Formatters; @@ -95,4 +96,4 @@ private static async Task ExecuteTypedAsync( using StreamReader reader = new(ms); return await reader.ReadToEndAsync(); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Tool/Program.cs b/src/Conjecture.Tool/Program.cs index bf1ab06..08c8763 100644 --- a/src/Conjecture.Tool/Program.cs +++ b/src/Conjecture.Tool/Program.cs @@ -2,4 +2,4 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ // Entry point — CLI implementation pending. -await Task.CompletedTask; +await Task.CompletedTask; \ No newline at end of file diff --git a/src/Conjecture.Xunit.Tests/EndToEnd/FloatingPointPropertyE2ETests.cs b/src/Conjecture.Xunit.Tests/EndToEnd/FloatingPointPropertyE2ETests.cs index f74e418..62e1cb6 100644 --- a/src/Conjecture.Xunit.Tests/EndToEnd/FloatingPointPropertyE2ETests.cs +++ b/src/Conjecture.Xunit.Tests/EndToEnd/FloatingPointPropertyE2ETests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/EndToEnd/PropertyShrinkingE2ETests.cs b/src/Conjecture.Xunit.Tests/EndToEnd/PropertyShrinkingE2ETests.cs index eda00f7..492741d 100644 --- a/src/Conjecture.Xunit.Tests/EndToEnd/PropertyShrinkingE2ETests.cs +++ b/src/Conjecture.Xunit.Tests/EndToEnd/PropertyShrinkingE2ETests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/EndToEnd/SourceGeneratorE2ETests.cs b/src/Conjecture.Xunit.Tests/EndToEnd/SourceGeneratorE2ETests.cs index 4acbcc0..85c05f7 100644 --- a/src/Conjecture.Xunit.Tests/EndToEnd/SourceGeneratorE2ETests.cs +++ b/src/Conjecture.Xunit.Tests/EndToEnd/SourceGeneratorE2ETests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/EndToEnd/StringPropertyE2ETests.cs b/src/Conjecture.Xunit.Tests/EndToEnd/StringPropertyE2ETests.cs index 0374a48..e91b614 100644 --- a/src/Conjecture.Xunit.Tests/EndToEnd/StringPropertyE2ETests.cs +++ b/src/Conjecture.Xunit.Tests/EndToEnd/StringPropertyE2ETests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/FromAttributeResolverTests.cs b/src/Conjecture.Xunit.Tests/FromAttributeResolverTests.cs index 68bf6c1..a58ca9b 100644 --- a/src/Conjecture.Xunit.Tests/FromAttributeResolverTests.cs +++ b/src/Conjecture.Xunit.Tests/FromAttributeResolverTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/FromFactoryAttributeResolverTests.cs b/src/Conjecture.Xunit.Tests/FromFactoryAttributeResolverTests.cs index 4393f97..fbcbce8 100644 --- a/src/Conjecture.Xunit.Tests/FromFactoryAttributeResolverTests.cs +++ b/src/Conjecture.Xunit.Tests/FromFactoryAttributeResolverTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/ParameterStrategyResolverExtendedTests.cs b/src/Conjecture.Xunit.Tests/ParameterStrategyResolverExtendedTests.cs index 512ddb3..f2d7a03 100644 --- a/src/Conjecture.Xunit.Tests/ParameterStrategyResolverExtendedTests.cs +++ b/src/Conjecture.Xunit.Tests/ParameterStrategyResolverExtendedTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/PropertyAttributeDatabaseTests.cs b/src/Conjecture.Xunit.Tests/PropertyAttributeDatabaseTests.cs index 4bcea93..98d00ba 100644 --- a/src/Conjecture.Xunit.Tests/PropertyAttributeDatabaseTests.cs +++ b/src/Conjecture.Xunit.Tests/PropertyAttributeDatabaseTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/PropertyAttributeExampleTests.cs b/src/Conjecture.Xunit.Tests/PropertyAttributeExampleTests.cs index e5e6a0b..8b7fc59 100644 --- a/src/Conjecture.Xunit.Tests/PropertyAttributeExampleTests.cs +++ b/src/Conjecture.Xunit.Tests/PropertyAttributeExampleTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit; diff --git a/src/Conjecture.Xunit.Tests/PropertyAttributeFailureMessageTests.cs b/src/Conjecture.Xunit.Tests/PropertyAttributeFailureMessageTests.cs index f4812e2..4122f1e 100644 --- a/src/Conjecture.Xunit.Tests/PropertyAttributeFailureMessageTests.cs +++ b/src/Conjecture.Xunit.Tests/PropertyAttributeFailureMessageTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.Tests/PropertyAttributeLoggingTests.cs b/src/Conjecture.Xunit.Tests/PropertyAttributeLoggingTests.cs index 6916312..b3c16ec 100644 --- a/src/Conjecture.Xunit.Tests/PropertyAttributeLoggingTests.cs +++ b/src/Conjecture.Xunit.Tests/PropertyAttributeLoggingTests.cs @@ -3,7 +3,9 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; + using Xunit.Abstractions; namespace Conjecture.Xunit.Tests; @@ -58,4 +60,4 @@ public async Task TestRunner_WithNullWriteLine_DoesNotThrow() await TestRunner.Run(settings, _ => { }); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Xunit.Tests/PropertyAttributeTargetingTests.cs b/src/Conjecture.Xunit.Tests/PropertyAttributeTargetingTests.cs index 36b3daa..f66bfe4 100644 --- a/src/Conjecture.Xunit.Tests/PropertyAttributeTargetingTests.cs +++ b/src/Conjecture.Xunit.Tests/PropertyAttributeTargetingTests.cs @@ -38,4 +38,4 @@ public void TargetingProportion_CanBeSet() Assert.Equal(0.25, attr.TargetingProportion); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Xunit.Tests/StateMachine/StateMachineReportingTests.cs b/src/Conjecture.Xunit.Tests/StateMachine/StateMachineReportingTests.cs index 469aa69..cf36cb7 100644 --- a/src/Conjecture.Xunit.Tests/StateMachine/StateMachineReportingTests.cs +++ b/src/Conjecture.Xunit.Tests/StateMachine/StateMachineReportingTests.cs @@ -75,4 +75,4 @@ public async Task StatefulProperty_ShrinkCount_IsReportedInResult() Assert.False(result.Passed); Assert.True(result.ShrinkCount > 0, $"Expected shrink count > 0, got {result.ShrinkCount}."); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Xunit.Tests/TrimAnnotationTests.cs b/src/Conjecture.Xunit.Tests/TrimAnnotationTests.cs index 0dd4a06..1827059 100644 --- a/src/Conjecture.Xunit.Tests/TrimAnnotationTests.cs +++ b/src/Conjecture.Xunit.Tests/TrimAnnotationTests.cs @@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; + using Conjecture.Core.Internal; using Conjecture.Xunit.Internal; diff --git a/src/Conjecture.Xunit.Tests/XunitV2SharedResolverTests.cs b/src/Conjecture.Xunit.Tests/XunitV2SharedResolverTests.cs index 3bd877a..32744df 100644 --- a/src/Conjecture.Xunit.Tests/XunitV2SharedResolverTests.cs +++ b/src/Conjecture.Xunit.Tests/XunitV2SharedResolverTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; diff --git a/src/Conjecture.Xunit.V3.Tests/EndToEnd/SourceGeneratorXunitV3E2ETests.cs b/src/Conjecture.Xunit.V3.Tests/EndToEnd/SourceGeneratorXunitV3E2ETests.cs index 9a16664..7b322fa 100644 --- a/src/Conjecture.Xunit.V3.Tests/EndToEnd/SourceGeneratorXunitV3E2ETests.cs +++ b/src/Conjecture.Xunit.V3.Tests/EndToEnd/SourceGeneratorXunitV3E2ETests.cs @@ -2,9 +2,11 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.Xunit.V3.Tests.EndToEnd; diff --git a/src/Conjecture.Xunit.V3.Tests/EndToEnd/XunitV3AdapterE2ETests.cs b/src/Conjecture.Xunit.V3.Tests/EndToEnd/XunitV3AdapterE2ETests.cs index 70297f7..d4a8af5 100644 --- a/src/Conjecture.Xunit.V3.Tests/EndToEnd/XunitV3AdapterE2ETests.cs +++ b/src/Conjecture.Xunit.V3.Tests/EndToEnd/XunitV3AdapterE2ETests.cs @@ -2,9 +2,11 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.Xunit.V3.Tests.EndToEnd; diff --git a/src/Conjecture.Xunit.V3.Tests/PropertyAttributeLoggingTests.cs b/src/Conjecture.Xunit.V3.Tests/PropertyAttributeLoggingTests.cs index ef93521..7ed155b 100644 --- a/src/Conjecture.Xunit.V3.Tests/PropertyAttributeLoggingTests.cs +++ b/src/Conjecture.Xunit.V3.Tests/PropertyAttributeLoggingTests.cs @@ -3,7 +3,9 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; + using Xunit; using Xunit.v3; @@ -58,4 +60,4 @@ public async Task TestRunner_WithNullWriteLine_DoesNotThrow() await TestRunner.Run(settings, _ => { }); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Xunit.V3.Tests/StateMachine/StateMachineReportingTests.cs b/src/Conjecture.Xunit.V3.Tests/StateMachine/StateMachineReportingTests.cs index 77d8dd6..3ec07ee 100644 --- a/src/Conjecture.Xunit.V3.Tests/StateMachine/StateMachineReportingTests.cs +++ b/src/Conjecture.Xunit.V3.Tests/StateMachine/StateMachineReportingTests.cs @@ -3,6 +3,7 @@ using Conjecture.Core; using Conjecture.Core.Internal; + using Xunit; namespace Conjecture.Xunit.V3.Tests.StateMachine; @@ -76,4 +77,4 @@ public async Task StatefulProperty_ShrinkCount_IsReportedInResult() Assert.False(result.Passed); Assert.True(result.ShrinkCount > 0, $"Expected shrink count > 0, got {result.ShrinkCount}."); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTargetingTests.cs b/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTargetingTests.cs index 6d77853..a3760c0 100644 --- a/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTargetingTests.cs +++ b/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTargetingTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.Xunit.V3.Tests; @@ -39,4 +40,4 @@ public void TargetingProportion_CanBeSet() Assert.Equal(0.25, attr.TargetingProportion); } -} +} \ No newline at end of file diff --git a/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTests.cs b/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTests.cs index 03f90d3..2200352 100644 --- a/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTests.cs +++ b/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyAttributeTests.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.Xunit.V3.Tests; diff --git a/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyExecutionTests.cs b/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyExecutionTests.cs index 85e95ca..2d2ec48 100644 --- a/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyExecutionTests.cs +++ b/src/Conjecture.Xunit.V3.Tests/XunitV3PropertyExecutionTests.cs @@ -2,9 +2,11 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.Xunit.V3.Tests; diff --git a/src/Conjecture.Xunit.V3.Tests/XunitV3ReportingTests.cs b/src/Conjecture.Xunit.V3.Tests/XunitV3ReportingTests.cs index 6067155..9df3877 100644 --- a/src/Conjecture.Xunit.V3.Tests/XunitV3ReportingTests.cs +++ b/src/Conjecture.Xunit.V3.Tests/XunitV3ReportingTests.cs @@ -2,9 +2,11 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; using Conjecture.Xunit.V3; + using Xunit; namespace Conjecture.Xunit.V3.Tests; diff --git a/src/Conjecture.Xunit.V3/Internal/PropertyTestCase.cs b/src/Conjecture.Xunit.V3/Internal/PropertyTestCase.cs index 120e417..4c02fa5 100644 --- a/src/Conjecture.Xunit.V3/Internal/PropertyTestCase.cs +++ b/src/Conjecture.Xunit.V3/Internal/PropertyTestCase.cs @@ -4,10 +4,13 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; + using Xunit; using Xunit.Sdk; using Xunit.v3; diff --git a/src/Conjecture.Xunit.V3/PropertyAttribute.cs b/src/Conjecture.Xunit.V3/PropertyAttribute.cs index 1fc9f00..1e46d61 100644 --- a/src/Conjecture.Xunit.V3/PropertyAttribute.cs +++ b/src/Conjecture.Xunit.V3/PropertyAttribute.cs @@ -2,6 +2,7 @@ // See LICENSE.txt in the project root or https://mozilla.org/MPL/2.0/ using System.Runtime.CompilerServices; + using Xunit; using Xunit.v3; diff --git a/src/Conjecture.Xunit/Internal/PropertyTestCase.cs b/src/Conjecture.Xunit/Internal/PropertyTestCase.cs index 1f128a1..8bdb68e 100644 --- a/src/Conjecture.Xunit/Internal/PropertyTestCase.cs +++ b/src/Conjecture.Xunit/Internal/PropertyTestCase.cs @@ -64,7 +64,7 @@ public override void Deserialize(IXunitSerializationInfo info) MaxStrategyRejections = info.GetValue("MaxStrategyRejections"); DeadlineMs = info.GetValue("DeadlineMs"); string? targetingStr = info.GetValue("Targeting"); - Targeting = targetingStr is null ? true : bool.Parse(targetingStr); + Targeting = targetingStr is null || bool.Parse(targetingStr); string? proportionStr = info.GetValue("TargetingProportion"); if (proportionStr is not null && double.TryParse(proportionStr, System.Globalization.NumberStyles.Float, diff --git a/src/Conjecture.Xunit/Internal/PropertyTestCaseRunner.cs b/src/Conjecture.Xunit/Internal/PropertyTestCaseRunner.cs index 489ea31..4d89cee 100644 --- a/src/Conjecture.Xunit/Internal/PropertyTestCaseRunner.cs +++ b/src/Conjecture.Xunit/Internal/PropertyTestCaseRunner.cs @@ -4,9 +4,12 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; + using Conjecture.Core; using Conjecture.Core.Internal; + using Microsoft.Extensions.Logging; + using Xunit.Abstractions; using Xunit.Sdk; @@ -185,4 +188,4 @@ protected override async Task RunTestAsync() return summary; } -} +} \ No newline at end of file