Raffinert.NoneItemAccessGenerator 1.0.5

dotnet add package Raffinert.NoneItemAccessGenerator --version 1.0.5                
NuGet\Install-Package Raffinert.NoneItemAccessGenerator -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Raffinert.NoneItemAccessGenerator" Version="1.0.5">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Raffinert.NoneItemAccessGenerator --version 1.0.5                
#r "nuget: Raffinert.NoneItemAccessGenerator, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Raffinert.NoneItemAccessGenerator as a Cake Addin
#addin nuget:?package=Raffinert.NoneItemAccessGenerator&version=1.0.5

// Install Raffinert.NoneItemAccessGenerator as a Cake Tool
#tool nuget:?package=Raffinert.NoneItemAccessGenerator&version=1.0.5                

StandWithUkraine

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

NuGet version (Chorn.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();
    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);
  • 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:

There are no supported framework assets in this package.

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.

Version Downloads Last updated
1.0.5 113 10/22/2024
1.0.4 75 10/22/2024
1.0.3 93 10/14/2024
1.0.2 103 10/8/2024
1.0.1 90 10/7/2024
1.0.0 105 10/7/2024

v 1.0.5 - Fix missing using System.Threading directive.
v 1.0.4 - Fix missing using System.Threading.Tasks directive.
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.