GithubHelp home page GithubHelp logo

sucrose0413 / sylvan.buildtools.resources Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markpflug/sylvan.buildtools.resources

0.0 0.0 0.0 116 KB

Json Resource file support in C# projects.

License: MIT License

C# 100.00%

sylvan.buildtools.resources's Introduction

Sylvan.BuildTools.Resources

Provides Json Resource file support in C# projects.

This provides an alternative to using resx files to defined resources in C# projects. The benefits over resx are:

  • human readable file format (try writing resx xml from scratch without documentation)
  • generated C# code doesn't get included in project/source control (unlike designer.cs files)
  • Doesn't require modifying the .csproj (adding a single resx file will add ~12 lines to your csproj file)
  • Doesn't require Visual Studio to function. (resx files don't work in VS Code for example)

Referencing the Sylvan.BuildTools.Resources package will not add any dependency to your project. The package operates at build time and will embed resources in your output assembly, and includes compiled code files containing resource accessors.

Json resource files use the ".resj" file extension, and a very simple json document to specify resources. Currently supports strings and text files. Text file path should be specified relative to the resj file location. Supports creating localized satellite assemblies using the same naming convention as resx.

Example files:

[Resources.json]

{
  "Strings": {
    "Greeting": "Hello, Resj",
    "Farewell": "Goodbye, Resx"
  },
  "Files": {
    "ComplexQuery": "sql/query.sql"
  }
}

[Resources.de-DE.json]

{
  "Strings": {
    "Greeting": "Hallo, Resj",
    "Farewell": "Auf Wiedersehen, Resx"
  }
}

You can control the resource generation specifying a custom namespace, and the visibility of the generated class:

  <ItemGroup>
    <JsonResource Update="Path/To/Resource.resj">
      <AccessModifier>Public</AccessModifier>
      <Namespace>CustomNS</Namespace>
      <ResourceName>CustomResourceName</ResourceName>
    </JsonResource>
  </ItemGroup>

Running Sylvan.BuildTools.Resources.Tests on Unix

If you'd like to develop Sylvan.BuildTools.Resources under Mono, and encounter issues with reference assemblies not being found while running tests, you might need to run something similar beforehand (source1, source2):

export FrameworkPathOverride=/lib/mono/4.6-api

Release Notes:

0.4.0

  • Adds code comments to generated code, allowing projects that use WarningsAsErrors and DocumentationFile to compile without error.
  • Big thanks to @teddybeermaniac for his contribution here.

sylvan.buildtools.resources's People

Contributors

markpflug avatar the127 avatar teddybeermaniac avatar omelhus avatar sucrose0413 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.