Skip to content

Commit a86f88c

Browse files
committed
Add ILSpySamples-CSharp project and update ILSpySamples to support multiple target frameworks
1 parent a101ca8 commit a86f88c

File tree

6 files changed

+121
-52
lines changed

6 files changed

+121
-52
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ indent_size = 2
6969
[*.{yml,yaml}]
7070
indent_size = 2
7171
indent_style = space
72+
73+
74+
# C# analyzers
75+
[*.{cs,vb}]
76+
dotnet_diagnostic.CA2252.severity = none

IcedTasks.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B3
2727
EndProject
2828
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ILSpySamples", "examples\ILSpySamples\ILSpySamples.fsproj", "{130D8BDE-DAB6-4B12-925D-A9CFEC9F8B02}"
2929
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpySamples-CSharp", "examples\ILSpySamples-CSharp\ILSpySamples-CSharp.csproj", "{F079E375-8A7E-4AF4-B89F-E0365682EEA6}"
31+
EndProject
3032
Global
3133
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3234
Debug|Any CPU = Debug|Any CPU
@@ -133,6 +135,18 @@ Global
133135
{130D8BDE-DAB6-4B12-925D-A9CFEC9F8B02}.Release|x64.Build.0 = Release|Any CPU
134136
{130D8BDE-DAB6-4B12-925D-A9CFEC9F8B02}.Release|x86.ActiveCfg = Release|Any CPU
135137
{130D8BDE-DAB6-4B12-925D-A9CFEC9F8B02}.Release|x86.Build.0 = Release|Any CPU
138+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
139+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
140+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Debug|x64.ActiveCfg = Debug|Any CPU
141+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Debug|x64.Build.0 = Debug|Any CPU
142+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Debug|x86.ActiveCfg = Debug|Any CPU
143+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Debug|x86.Build.0 = Debug|Any CPU
144+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
145+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Release|Any CPU.Build.0 = Release|Any CPU
146+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Release|x64.ActiveCfg = Release|Any CPU
147+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Release|x64.Build.0 = Release|Any CPU
148+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Release|x86.ActiveCfg = Release|Any CPU
149+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6}.Release|x86.Build.0 = Release|Any CPU
136150
EndGlobalSection
137151
GlobalSection(SolutionProperties) = preSolution
138152
HideSolutionNode = FALSE
@@ -145,5 +159,6 @@ Global
145159
{446B1378-DDC2-47CD-A6F2-C10F946B7E12} = {ACBEE43C-7A88-4FB1-9B06-DB064D22B29F}
146160
{04D5314E-2B8F-442B-9983-DCD12CC43448} = {ACBEE43C-7A88-4FB1-9B06-DB064D22B29F}
147161
{130D8BDE-DAB6-4B12-925D-A9CFEC9F8B02} = {B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}
162+
{F079E375-8A7E-4AF4-B89F-E0365682EEA6} = {B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}
148163
EndGlobalSection
149164
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
6+
<RootNamespace>ILSpySamples_CSharp</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<EnablePreviewFeatures>true</EnablePreviewFeatures>
10+
<Features>$(Features);runtime-async=on</Features>
11+
<NoWarn>$(NoWarn);SYSLIB5007</NoWarn>
12+
</PropertyGroup>
13+
14+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+

2+
3+
4+
// See https://aka.ms/new-console-template for more information
5+
Console.WriteLine("Hello, World!");
6+
7+
8+
9+
public class Thingy
10+
{
11+
public async Task<int> DoThingAsync()
12+
{
13+
await Task.Yield();
14+
return 42;
15+
}
16+
}

examples/ILSpySamples/ILSpySamples.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
44
<GenerateDocumentationFile>true</GenerateDocumentationFile>
5+
<OutputType>Exe</OutputType>
56
</PropertyGroup>
67
<ItemGroup>
78
<Compile Include="Library.fs" />

examples/ILSpySamples/Library.fs

Lines changed: 69 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,76 @@ open System.Threading.Tasks
44
open System.Collections.Generic
55

66

7-
module Task =
7+
module TaskRuntime =
8+
open IcedTasks.Polyfill.TasksRuntime
9+
open System.Runtime.CompilerServices
810

9-
let forLoopEnumerable (x: IEnumerable<_>) =
11+
[<MethodImpl(MethodImplOptions.Async)>]
12+
let doThing () =
1013
task {
11-
for i in x do
12-
do! Task.Yield()
13-
printfn "%A" i
14+
do! Task.Yield()
15+
return 42
1416
}
1517

16-
module IcedTasks =
17-
open IcedTasks
18-
19-
module Task =
20-
open IcedTasks.Polyfill.Task
21-
22-
let forLoopEnumerable (x: IEnumerable<_>) =
23-
task {
24-
for i in x do
25-
do! Task.Yield()
26-
printfn "%A" i
27-
}
28-
29-
30-
let forLoopAsyncEnmerable (x: IAsyncEnumerable<_>) =
31-
task {
32-
for i in x do
33-
do! Task.Yield()
34-
printfn "%A" i
35-
}
36-
37-
let tryFinally () =
38-
task {
39-
try
40-
do! Task.Yield()
41-
finally
42-
printfn "finally2"
43-
}
44-
45-
46-
module CT =
47-
open IcedTasks.Polyfill.Task
48-
49-
let forLoopEnumerable (x: IEnumerable<_>) =
50-
cancellableTask {
51-
for i in x do
52-
do! Task.Yield()
53-
printfn "%A" i
54-
}
55-
56-
let forLoopAsyncEnmerable (x: IAsyncEnumerable<_>) =
57-
cancellableTask {
58-
for i in x do
59-
do! Task.Yield()
60-
printfn "%A" i
61-
}
18+
// module Task =
19+
20+
// let forLoopEnumerable (x: IEnumerable<_>) =
21+
// task {
22+
// for i in x do
23+
// do! Task.Yield()
24+
// printfn "%A" i
25+
// }
26+
27+
// module IcedTasks =
28+
// open IcedTasks
29+
30+
// module Task =
31+
// open IcedTasks.Polyfill.Task
32+
33+
// let forLoopEnumerable (x: IEnumerable<_>) =
34+
// task {
35+
// for i in x do
36+
// do! Task.Yield()
37+
// printfn "%A" i
38+
// }
39+
40+
41+
// let forLoopAsyncEnmerable (x: IAsyncEnumerable<_>) =
42+
// task {
43+
// for i in x do
44+
// do! Task.Yield()
45+
// printfn "%A" i
46+
// }
47+
48+
// let tryFinally () =
49+
// task {
50+
// try
51+
// do! Task.Yield()
52+
// finally
53+
// printfn "finally2"
54+
// }
55+
56+
57+
// module CT =
58+
// open IcedTasks.Polyfill.Task
59+
60+
// let forLoopEnumerable (x: IEnumerable<_>) =
61+
// cancellableTask {
62+
// for i in x do
63+
// do! Task.Yield()
64+
// printfn "%A" i
65+
// }
66+
67+
// let forLoopAsyncEnmerable (x: IAsyncEnumerable<_>) =
68+
// cancellableTask {
69+
// for i in x do
70+
// do! Task.Yield()
71+
// printfn "%A" i
72+
// }
73+
74+
75+
module Main =
76+
[<EntryPoint>]
77+
78+
let main _argv =
79+
TaskRuntime.doThing().GetAwaiter().GetResult()

0 commit comments

Comments
 (0)