Skip to content

Commit ffc05a4

Browse files
committed
file-based app
1 parent a0d397f commit ffc05a4

File tree

11 files changed

+55
-0
lines changed

11 files changed

+55
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#:property AllowUnsafeBlocks=true
2+
3+
// unsafe ブロックはオプションをつけないと使えない構文。
4+
unsafe
5+
{
6+
int n = 1;
7+
int* pn = &n;
8+
Console.WriteLine($"{(nint)pn:x}");
9+
}

Chapters/SingleFile/AspNet.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#:sdk Microsoft.NET.Sdk.Web
2+
3+
var app = WebApplication.CreateBuilder(args).Build();
4+
app.MapGet("/", () => "Hello World!");
5+
app.Run();

Chapters/SingleFile/Cat.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Console.WriteLine("🐈");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<InvariantGlobalization>true</InvariantGlobalization>
9+
</PropertyGroup>
10+
11+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Console.WriteLine(new DateTime(2000, 1, 2, 3, 4, 5));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#:property InvariantGlobalization=true
2+
Console.WriteLine(new DateTime(2000, 1, 2, 3, 4, 5));

Chapters/SingleFile/Lib/Lib.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
</Project>

Chapters/SingleFile/Lib/Program.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Lib;
2+
3+
public class Class1
4+
{
5+
public static string Name => "Lib.Class1";
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#:package Microsoft.CodeAnalysis.CSharp@4.14.0
2+
3+
using Microsoft.CodeAnalysis.CSharp;
4+
5+
var tree = CSharpSyntaxTree.ParseText("class Class1;");
6+
var root = await tree.GetRootAsync();
7+
Console.WriteLine(root.GetFirstToken().Text);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#:project Lib/Lib.csproj
2+
Console.WriteLine(Lib.Class1.Name);

0 commit comments

Comments
 (0)