-
Notifications
You must be signed in to change notification settings - Fork 366
Add fsharp-project-structure skill #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0f3d7b3
194579d
ddfcf42
da175b1
51b2ce3
6992adc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,3 +15,65 @@ scenarios: | |||||||||
| - "Identified DefineConstants overwrites existing constants instead of appending" | ||||||||||
| - "Identified analyzer PackageReference missing PrivateAssets, unquoted MSBuild condition, mixed Include/Update in same ItemGroup, or Exec instead of Message task" | ||||||||||
| timeout: 160 | ||||||||||
|
|
||||||||||
| - name: "Add a module to an F# project" | ||||||||||
| prompt: | | ||||||||||
| Add a Validation.fs module to the F# project at fsharp/OrderService/ that | ||||||||||
| validates orders before processing. It should check that the order has at | ||||||||||
| least one item and that the customer name is not empty. Return a | ||||||||||
| Result<Order, string> with a descriptive error message on failure. Then | ||||||||||
| update Program.fs to validate the order before processing it, printing the | ||||||||||
| error if validation fails. | ||||||||||
| setup: | ||||||||||
| copy_test_files: true | ||||||||||
| assertions: | ||||||||||
| - type: "exit_success" | ||||||||||
| - type: "file_contains" | ||||||||||
| path: "fsharp/OrderService/OrderService.fsproj" | ||||||||||
| value: "Validation.fs" | ||||||||||
| rubric: | ||||||||||
| - "Created Validation.fs with a validation function returning Result<Order, string>" | ||||||||||
| - "Inserted Compile Include=\"Validation.fs\" AFTER Domain.fs and BEFORE Program.fs in the .fsproj" | ||||||||||
| - "Did NOT place Validation.fs after Program.fs in the Compile item list" | ||||||||||
| - "Updated Program.fs to call the validation function before processing" | ||||||||||
| - "Ran dotnet build and it succeeded" | ||||||||||
| timeout: 120 | ||||||||||
|
|
||||||||||
| - name: "Fix broken file order causing FS0039" | ||||||||||
| prompt: | | ||||||||||
| The F# project at fsharp/BrokenOrder/ fails to build. Diagnose and fix the issue. | ||||||||||
| setup: | ||||||||||
| copy_test_files: true | ||||||||||
| assertions: | ||||||||||
| - type: "exit_success" | ||||||||||
| - type: "file_contains" | ||||||||||
| path: "fsharp/BrokenOrder/BrokenOrder.fsproj" | ||||||||||
| value: "Domain.fs" | ||||||||||
|
||||||||||
| value: "Domain.fs" | |
| value: | | |
| Domain.fs" /> | |
| <Compile Include="Services.fs" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="Services.fs" /> | ||
| <Compile Include="Domain.fs" /> | ||
| <Compile Include="Program.fs" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module BrokenOrder.Domain | ||
|
|
||
| type OrderId = OrderId of int | ||
|
|
||
| type OrderItem = { | ||
| Name: string | ||
| Quantity: int | ||
| Price: decimal | ||
| } | ||
|
|
||
| type Order = { | ||
| Id: OrderId | ||
| CustomerName: string | ||
| Items: OrderItem list | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| open BrokenOrder.Domain | ||
| open BrokenOrder.Services | ||
|
|
||
| let order = { | ||
| Id = OrderId 1 | ||
| CustomerName = "Alice" | ||
| Items = [ | ||
| { Name = "Widget"; Quantity = 2; Price = 9.99m } | ||
| { Name = "Gadget"; Quantity = 1; Price = 24.99m } | ||
| ] | ||
| } | ||
|
|
||
| let total = processOrder order | ||
| printfn "Order total: $%M" total |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module BrokenOrder.Services | ||
|
|
||
| open BrokenOrder.Domain | ||
|
|
||
| let calculateTotal (order: Order) = | ||
| order.Items | ||
| |> List.sumBy (fun item -> item.Price * decimal item.Quantity) | ||
|
|
||
| let processOrder (order: Order) = | ||
| let total = calculateTotal order | ||
| printfn "Processing order for %s: $%M" order.CustomerName total | ||
| total |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <Project> | ||
| <!-- Empty: intentionally short-circuits the parent Directory.Build.props | ||
| which exists only as a C# antipattern fixture and would otherwise | ||
| leak C#-specific settings (analyzers, TreatWarningsAsErrors) into | ||
| these F# fixtures. --> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <Project> | ||
| <!-- Empty: see Directory.Build.props in this folder for rationale. --> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module OrderService.Domain | ||
|
|
||
| type OrderId = OrderId of int | ||
|
|
||
| type OrderItem = { | ||
| Name: string | ||
| Quantity: int | ||
| Price: decimal | ||
| } | ||
|
|
||
| type Order = { | ||
| Id: OrderId | ||
| CustomerName: string | ||
| Items: OrderItem list | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="Domain.fs" /> | ||
| <Compile Include="Services.fs" /> | ||
| <Compile Include="Program.fs" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| open OrderService.Domain | ||
| open OrderService.Services | ||
|
|
||
| let order = { | ||
| Id = OrderId 1 | ||
| CustomerName = "Alice" | ||
| Items = [ | ||
| { Name = "Widget"; Quantity = 2; Price = 9.99m } | ||
| { Name = "Gadget"; Quantity = 1; Price = 24.99m } | ||
| ] | ||
| } | ||
|
|
||
| let total = processOrder order | ||
| printfn "Order total: $%M" total |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module OrderService.Services | ||
|
|
||
| open OrderService.Domain | ||
|
|
||
| let calculateTotal (order: Order) = | ||
| order.Items | ||
| |> List.sumBy (fun item -> item.Price * decimal item.Quantity) | ||
|
|
||
| let processOrder (order: Order) = | ||
| let total = calculateTotal order | ||
| printfn "Processing order for %s: $%M" order.CustomerName total | ||
| total |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This auto-generated lock file appears to be accidentally truncated: the "Directory.Build Consolidation" section ends mid-sentence and the literal placeholder text
[truncated]is committed. Regenerate this compiled lock (or restore the removed content) so the document is complete and does not contain placeholders.