Raffinert.NoneItemAccessGenerator
1.0.3
See the version list below for details.
dotnet add package Raffinert.NoneItemAccessGenerator --version 1.0.3
NuGet\Install-Package Raffinert.NoneItemAccessGenerator -Version 1.0.3
<PackageReference Include="Raffinert.NoneItemAccessGenerator" Version="1.0.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Raffinert.NoneItemAccessGenerator --version 1.0.3
#r "nuget: Raffinert.NoneItemAccessGenerator, 1.0.3"
// Install Raffinert.NoneItemAccessGenerator as a Cake Addin #addin nuget:?package=Raffinert.NoneItemAccessGenerator&version=1.0.3 // Install Raffinert.NoneItemAccessGenerator as a Cake Tool #tool nuget:?package=Raffinert.NoneItemAccessGenerator&version=1.0.3
A refined version of the original EmbeddedResourceAccessGenerator by ChristophHornung adapted for None items.
Important: The original EmbeddedResourceAccessGenerator is incompatible with this generator and must be removed before adding this generator.
NoneItemAccessGenerator
The Raffinert.NoneItemAccessGenerator is a code generator to allow easy access to all none item files with CopyToOutputDirectory attribute specified as Always or PreserveNewest.
Usage
Get the nuget package here.
After referencing the Raffinert.NoneItemAccessGenerator
nuget the code generation will
automatically create a class Nones
in the root namespace of the project.
Together with the generated None
enumeration there are several options to access
none item files:
E.g. for a Test.txt
none item in the TestAsset
folder:
- Via enum access through the
None
enum:
// Via the generated extension methods on the enum
using Stream s = None.TestAsset_Test_txt.GetStream();
using StreamReader sr = None.TestAsset_Test_txt.GetReader();
- Via enum access through the
None[FolderName]
enum:
// Via the generated extension methods on the enum
using Stream s = None_TestAsset.Test_txt.GetStream();
using StreamReader sr = None_TestAsset.Test_txt.GetReader();
string text = None_TestAsset.Test_txt.ReadAllText();
string textAsync = await None_TestAsset.Test_txt.ReadAllTextAsync(CancellationToken.None);
byte[] bytes = None_TestAsset.Test_txt.ReadAllBytes();
byte[] bytesAsync = await None_TestAsset.Test_txt.ReadAllBytesAsync(CancellationToken.None);
See also:
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v 1.0.3 - Separate readmes between the projects and update them.
v 1.0.2 - Added ReadAllBytes and ReadAllBytesAsync methods
v.1.0.1 - Fix the msbuild condition
v.1.0.0 - Initial release.