Skip to content

Commit ec2a4e2

Browse files
Add usage examples
1 parent adfb4d1 commit ec2a4e2

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

CSharpInteractive.Tests/README_TEMPLATE.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ Besides that, it is possible to get an instance of [System.IServiceProvider](htt
182182
``` CSharp
183183
public void Run()
184184
{
185-
var serviceProvider =
185+
var serviceProvider =
186186
GetService<IServiceCollection>()
187-
.AddTransient<MyTask>()
188-
.BuildServiceProvider();
187+
.AddTransient<MyTask>()
188+
.BuildServiceProvider();
189189

190190
var myTask = serviceProvider.GetRequiredService<MyTask>();
191191
var exitCode = myTask.Run();
@@ -451,7 +451,7 @@ var result = dockerRun
451451
result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse();
452452
result.ExitCode.ShouldBe(0);
453453

454-
string ToAbsoluteLinuxPath(string path) =>
454+
string ToAbsoluteLinuxPath(string path) =>
455455
"/" + path.Replace(":", "").Replace('\\', '/');
456456
```
457457

@@ -614,10 +614,10 @@ result.ExitCode.ShouldBe(0);
614614

615615
// Creates a NuGet package of version 1.2.3 for the project, running a command like: "dotnet pack /p:version=1.2.3" from the directory "MyLib"
616616
result = new DotNetPack()
617-
.WithWorkingDirectory("MyLib")
618-
.AddProps(("version", "1.2.3"))
619-
.Build()
620-
.EnsureSuccess();
617+
.WithWorkingDirectory("MyLib")
618+
.AddProps(("version", "1.2.3"))
619+
.Build()
620+
.EnsureSuccess();
621621

622622
result.ExitCode.ShouldBe(0);
623623
```
@@ -775,7 +775,7 @@ var testUnderDotCover = test.Customize(cmd =>
775775
+ $"--dcOutput={dotCoverSnapshot}"
776776
+ "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi"
777777
+ "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage");
778-
778+
779779
// Runs tests under dotCover via a command like: "dotnet dotcover test ..."
780780
var result = testUnderDotCover
781781
.Build()
@@ -805,7 +805,7 @@ using HostApi;
805805

806806
var projectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]);
807807
Directory.CreateDirectory(projectDir);
808-
808+
809809
// Creates a local tool manifest
810810
new DotNetNew("tool-manifest")
811811
.WithWorkingDirectory(projectDir)

CSharpInteractive.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
<s:Boolean x:Key="/Default/UserDictionary/Words/=decoherence/@EntryIndexedValue">True</s:Boolean>
304304
<s:Boolean x:Key="/Default/UserDictionary/Words/=dependencyinjection/@EntryIndexedValue">True</s:Boolean>
305305
<s:Boolean x:Key="/Default/UserDictionary/Words/=Enumerables/@EntryIndexedValue">True</s:Boolean>
306+
<s:Boolean x:Key="/Default/UserDictionary/Words/=immutype/@EntryIndexedValue">True</s:Boolean>
306307
<s:Boolean x:Key="/Default/UserDictionary/Words/=initializers/@EntryIndexedValue">True</s:Boolean>
307308
<s:Boolean x:Key="/Default/UserDictionary/Words/=inversionofcontrol/@EntryIndexedValue">True</s:Boolean>
308309
<s:Boolean x:Key="/Default/UserDictionary/Words/=multithreading/@EntryIndexedValue">True</s:Boolean>

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ The created project contains 2 entry points:
110110
| CSharpInteractive.Templates | [![NuGet](https://img.shields.io/nuget/v/CSharpInteractive.Templates )](https://www.nuget.org/packages/CSharpInteractive.Templates ) | .NET build project template | dotnet new install CSharpInteractive.Templates |
111111
| CSharpInteractive | [![NuGet](https://img.shields.io/nuget/v/CSharpInteractive)](https://www.nuget.org/packages/CSharpInteractive) | A library for use in .NET build projects | dotnet add package CSharpInteractive |
112112

113+
## Usage examples
114+
115+
- [Build project example](https://github.com/DevTeam/csharp-interactive/tree/master/Samples/MySampleLib)
116+
- [CSharp Interactive build project](https://github.com/DevTeam/csharp-interactive/tree/master/Build)
117+
- [Pure.DI build project](https://github.com/DevTeam/Pure.DI/tree/master/build)
118+
- [Immutype build project](https://github.com/DevTeam/Immutype/tree/master/Build)
119+
- [Comparison with Cake and Nuke](https://github.com/DevTeam/ci-cd)
120+
113121
## API
114122

115123
- Output, logging and tracing
@@ -293,10 +301,10 @@ Besides that, it is possible to get an instance of [System.IServiceProvider](htt
293301
``` CSharp
294302
public void Run()
295303
{
296-
var serviceProvider =
304+
var serviceProvider =
297305
GetService<IServiceCollection>()
298-
.AddTransient<MyTask>()
299-
.BuildServiceProvider();
306+
.AddTransient<MyTask>()
307+
.BuildServiceProvider();
300308

301309
var myTask = serviceProvider.GetRequiredService<MyTask>();
302310
var exitCode = myTask.Run();
@@ -562,7 +570,7 @@ var result = dockerRun
562570
result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse();
563571
result.ExitCode.ShouldBe(0);
564572

565-
string ToAbsoluteLinuxPath(string path) =>
573+
string ToAbsoluteLinuxPath(string path) =>
566574
"/" + path.Replace(":", "").Replace('\\', '/');
567575
```
568576

@@ -725,10 +733,10 @@ result.ExitCode.ShouldBe(0);
725733

726734
// Creates a NuGet package of version 1.2.3 for the project, running a command like: "dotnet pack /p:version=1.2.3" from the directory "MyLib"
727735
result = new DotNetPack()
728-
.WithWorkingDirectory("MyLib")
729-
.AddProps(("version", "1.2.3"))
730-
.Build()
731-
.EnsureSuccess();
736+
.WithWorkingDirectory("MyLib")
737+
.AddProps(("version", "1.2.3"))
738+
.Build()
739+
.EnsureSuccess();
732740

733741
result.ExitCode.ShouldBe(0);
734742
```
@@ -886,7 +894,7 @@ var testUnderDotCover = test.Customize(cmd =>
886894
+ $"--dcOutput={dotCoverSnapshot}"
887895
+ "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi"
888896
+ "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage");
889-
897+
890898
// Runs tests under dotCover via a command like: "dotnet dotcover test ..."
891899
var result = testUnderDotCover
892900
.Build()
@@ -916,7 +924,7 @@ using HostApi;
916924

917925
var projectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]);
918926
Directory.CreateDirectory(projectDir);
919-
927+
920928
// Creates a local tool manifest
921929
new DotNetNew("tool-manifest")
922930
.WithWorkingDirectory(projectDir)

README_BODY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,11 @@ The created project contains 2 entry points:
109109
| dotnet-csi | [![NuGet](https://img.shields.io/nuget/v/dotnet-csi)](https://www.nuget.org/packages/dotnet-csi) | Interactive .NET tool for REPL and running scripts | dotnet tool install --global dotnet-csi |
110110
| CSharpInteractive.Templates | [![NuGet](https://img.shields.io/nuget/v/CSharpInteractive.Templates )](https://www.nuget.org/packages/CSharpInteractive.Templates ) | .NET build project template | dotnet new install CSharpInteractive.Templates |
111111
| CSharpInteractive | [![NuGet](https://img.shields.io/nuget/v/CSharpInteractive)](https://www.nuget.org/packages/CSharpInteractive) | A library for use in .NET build projects | dotnet add package CSharpInteractive |
112+
113+
## Usage examples
114+
115+
- [Build project example](https://github.com/DevTeam/csharp-interactive/tree/master/Samples/MySampleLib)
116+
- [CSharp Interactive build project](https://github.com/DevTeam/csharp-interactive/tree/master/Build)
117+
- [Pure.DI build project](https://github.com/DevTeam/Pure.DI/tree/master/build)
118+
- [Immutype build project](https://github.com/DevTeam/Immutype/tree/master/Build)
119+
- [Comparison with Cake and Nuke](https://github.com/DevTeam/ci-cd)

0 commit comments

Comments
 (0)