Giter Site home page Giter Site logo

jsonbyexamplegenerator's Introduction

Animated gif dynamically generated from my profile repo

jsonbyexamplegenerator's People

Contributors

hermanussen avatar iqualityrobin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsonbyexamplegenerator's Issues

Problem with VS2019

Hey,

I am trying to use a generator and VS is highlighting errors, but the application compiles and runs.
image

1>CSC : error SI0000: Exception: The hintName contains an invalid character ':' at position 13.

Sometime, at the second compilation , it gives me
1>CSC : error SI0000: Exception: The hintName contains an invalid character ':' at position 13.

I think that is from

context.AddSource(GetSourceFileName(namespaceName, jsonFile.Path),
SourceText.From(generatedCode, Encoding.UTF8));

Could you modify
private string GetSourceFileName(string namespaceName, string path)
{
var fullPath = Path.GetFullPath(path)
.Replace(Path.GetFullPath("."), string.Empty)
.Replace("/", "")
.Replace("\", "
")
.Replace(".", "_");

        return $"{namespaceName}_{fullPath.Trim('_')}.gen.cs";
    }

to take just the file name of the jsonFile ?

Something like
var fullPath = Path.GetFileNameWithoutExtension(path)

We do not need namespace and others - it is just a hint.
And , if we want to see, we can put in csproj

<PropertyGroup> <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> <CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)Generated</CompilerGeneratedFilesOutputPath> </PropertyGroup>

namespace should be the default assembly name

IF I put the code in

C:\test2\JsonByExampleGenerator

the namespace generated by the JsonByExampleGenerator.Example.csroj will be

namespace JsonByExampleGenerator.Example.Json.C.Test2.JsonByExampleGenerator.JsonByExampleGeneratorExample.Products

Please put just the

namespace JsonByExampleGenerator.Example

add intellisense

Please add this header

//------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------

and for the classes the

[GeneratedCode("...", "...")]
[CompilerGenerated]

to have intellisense

Feedback about JsonByExampleGenerator

Hello Robin Hermanussen

I have started a mini-e-book about Roslyn Source Code Generators(RSCG).

Your RSCG , JsonByExampleGenerator from https://github.com/hermanussen/JsonByExampleGenerator/ , is between them at https://github.com/ignatandrei/RSCG_Examples/tree/main/JsonToClass

I am thinking to add to the e-book the some more information regarding the RSCG from the authors of RSCG.

So could you please answer to the following :

  1. Short info about you , Robin Hermanussen

  2. Why did you start this JsonByExampleGenerator ?

  3. How do yourself use your JsonByExampleGenerator ?

  4. What other RSCG do you use ?

  5. Any other feedback ?

Thanks

Andrei Ignat
http://msprogrammer.serviciipeweb.ro/

Remove Microsoft.CodeAnalysis.CSharp.Workspaces

Suggestion to make a private asset to avoid nuget errors like below:

NU1605: Detected package downgrade: Microsoft.CodeAnalysis.CSharp.Workspaces from 4.2.0 to 3.8.0. Reference the package directly from the project to select a different version.

NuGetizer is already setup this way.

[CS0234] The type or namespace name 'Json' does not exist in the namespace 'ConsoleApp1' (are you missing an assembly reference?)

First of all congratulation on such a great ides of generating strong type based on a sample Json file.

I am trying to use version 0.10.0 in a net6.0 project. Coding in the IDE looks fine and I can go to the definition of the c# code too. However I am getting the following error during the build.

[CS0234] The type or namespace name 'Json' does not exist in the namespace 'ConsoleApp1' (are you missing an assembly reference?)

Do you think it is because of net6.0 or something else.

Noticed you have been working on the upgrade to version 6.0 recently. Is there any plan for supporting net6.0?

Update:
I downgraded to version 0.8.4, and it worked. It seems the last couple of packages pushed to nuget had issues.

image

Feature Idea - Inline Json to Poco Object/Config

What if, you could define json inline in code (or wrapped in an attribute or class) and have that available as an object at runtime? That would be sorta cool, would reduce the noise in fluent builders and such.

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.