CsEffect.System
0.15.0
dotnet add package CsEffect.System --version 0.15.0
NuGet\Install-Package CsEffect.System -Version 0.15.0
<PackageReference Include="CsEffect.System" Version="0.15.0" />
<PackageVersion Include="CsEffect.System" Version="0.15.0" />
<PackageReference Include="CsEffect.System" />
paket add CsEffect.System --version 0.15.0
#r "nuget: CsEffect.System, 0.15.0"
#:package CsEffect.System@0.15.0
#addin nuget:?package=CsEffect.System&version=0.15.0
#tool nuget:?package=CsEffect.System&version=0.15.0
CsEffect.System
Built-in effect attribute library providing system-oriented effects for CsEffect consumers.
Overview
CsEffect.System provides a collection of pre-defined effect attributes for common system operations like I/O, console output, file operations, and HTTP requests. This package serves as both a useful library and a reference implementation for creating your own effect libraries.
Included Effects
IoEffectAttribute
A general-purpose I/O effect that acts as a superset for other I/O-related effects.
[IoEffect]
public void DoGeneralIo()
{
// Can call any I/O operation
}
ConsoleEffectAttribute
Covers operations that write to or read from the system console.
Targets: System.Console
[ConsoleEffect]
public void WriteToConsole(string message)
{
Console.WriteLine(message);
Console.Write("Prompt: ");
}
FileEffectAttribute
Covers file system operations.
Targets: System.IO.File
Severity: Error (violations are treated as compilation errors)
[FileEffect]
public void SaveData(string path, string data)
{
File.WriteAllText(path, data);
}
HttpEffectAttribute
Covers HTTP operations including client requests and message handling.
Targets: HttpClient, HttpMessageInvoker, HttpRequestMessage, HttpResponseMessage
[HttpEffect]
public async Task<string> FetchDataAsync(string url)
{
using var client = new HttpClient();
return await client.GetStringAsync(url);
}
Effect Hierarchy
The effects in this library follow a hierarchy where more general effects can satisfy more specific requirements:
IoEffectAttribute (base)
├── ConsoleEffectAttribute
├── FileEffectAttribute
└── HttpEffectAttribute
This means:
- Methods marked with
[IoEffect]can call methods requiring[ConsoleEffect],[FileEffect], or[HttpEffect] - Methods marked with
[ConsoleEffect]cannot call methods requiring[FileEffect]or[HttpEffect]without additional annotations
Usage
Install the package:
<PackageReference Include="CsEffect.System" Version="0.2.0" />Use the attributes:
using CsEffect.System; [ConsoleEffect, FileEffect] // Multiple effects can be combined public void LogToFileAndConsole(string message) { Console.WriteLine(message); File.AppendAllText("log.txt", message + Environment.NewLine); }Enable analysis (requires CsEffect analyzer):
<PackageReference Include="CsEffect" Version="0.2.0" OutputItemType="Analyzer" />
Creating Your Own Effect Libraries
Use this package as a reference for creating domain-specific effect libraries:
Reference the analyzer:
<ProjectReference Include="path\to\CsEffect.Analyzer.csproj" />Create your effects:
[EffectTargets(typeof(Database))] public sealed class DatabaseEffectAttribute : EffectAttribute { }Consider severity:
[EffectSeverity(EffectViolationLevel.Error)] // Make violations errors public sealed class CriticalEffectAttribute : EffectAttribute { }
Best Practices
- Use specific effects (
[FileEffect]) rather than general ones ([IoEffect]) when possible - Combine multiple effects when a method performs multiple types of operations
- Consider creating your own effect hierarchies for domain-specific operations
- Use
[IoEffect]as a catch-all when you need to perform various I/O operations
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CsEffect.Core (>= 0.15.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.15.0 | 197 | 10/13/2025 |
| 0.14.0 | 194 | 10/13/2025 |
| 0.13.0 | 196 | 10/13/2025 |
| 0.12.0 | 183 | 10/13/2025 |
| 0.11.0 | 198 | 10/13/2025 |
| 0.10.0 | 198 | 10/12/2025 |
| 0.9.0 | 200 | 10/12/2025 |
| 0.8.0 | 196 | 10/12/2025 |
| 0.7.0 | 193 | 10/12/2025 |
| 0.6.0 | 190 | 10/12/2025 |
| 0.5.0 | 179 | 10/12/2025 |
| 0.4.0 | 184 | 10/12/2025 |
| 0.3.0 | 128 | 10/11/2025 |
| 0.2.0 | 128 | 10/11/2025 |
| 0.2.0-alpha.12 | 89 | 10/11/2025 |
| 0.2.0-alpha.11 | 73 | 10/10/2025 |
| 0.2.0-alpha.9 | 87 | 10/10/2025 |
| 0.2.0-alpha.8 | 81 | 10/10/2025 |
| 0.1.0-alpha.1 | 96 | 10/10/2025 |
| 0.0.0 | 126 | 10/11/2025 |