RSCG – Pinecone.TypedPath

RSCG – Pinecone.TypedPath
 
 

name Pinecone.TypedPath
nuget https://www.nuget.org/packages/Pinecone.TypedPath/
link https://github.com/nickpinecone/typed-path
author Nick Pinecone

Generating typed paths for file system navigation and manipulation.

 

This is how you can use Pinecone.TypedPath .

The code that you start with is


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
	
	<ItemGroup>
		<AdditionalFiles Include="MyFolderToShow/**" />
	</ItemGroup>
	<ItemGroup>
    <PackageReference Include="Pinecone.TypedPath" Version="1.0.4" />
  </ItemGroup>
	<PropertyGroup>
		<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
		<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
	</PropertyGroup>
</Project>


The code that you will use is


using FolderToCode;

Console.WriteLine(MyFolder.en.A);
Console.WriteLine(MyFolder.ro.A);



using System;
using System.Collections.Generic;
using System.Text;
using TypedPath;

namespace FolderToCode;

[TypedPath("MyFolderToShow")]
public partial  class MyFolder: ITypedPath
{
    public static string Wrap(string path)
    {
        return path;
    }
}


 

The code that is generated is

namespace FolderToCode;

[global::System.CodeDom.Compiler.GeneratedCode("TypedPath", "1.0.0")]
public partial class MyFolder
{
    public static partial class en
    {
        public static readonly string A = Wrap("MyFolder\en\a.json");
    }
    public static partial class ro
    {
        public static readonly string A = Wrap("MyFolder\ro\a.json");
    }
}

using System;

namespace TypedPath;

[global::System.CodeDom.Compiler.GeneratedCode("TypedPath", "1.0.0")]
[AttributeUsage(AttributeTargets.Class)]
public class TypedPathAttribute : Attribute
{
    public string Path { get; }
    public bool OriginalFilename { get; }

    public TypedPathAttribute(string path, bool originalFilename = false)
    {
        Path = path;
        OriginalFilename = originalFilename;
    }
}
namespace TypedPath;

[global::System.CodeDom.Compiler.GeneratedCode("TypedPath", "1.0.0")]
public interface ITypedPath
{
    public static abstract string Wrap(string path);
}

Code and pdf at

https://ignatandrei.github.io/RSCG_Examples/v2/docs/Pinecone.TypedPath


Posted

in

,

by

Tags: