Coder Social home page Coder Social logo

sourcegeneratorplayground's Introduction

"bulb by Luca Ska from the Noun Project" Source Generator Playground

License: MIT Main build status Join the Discord

Source Generator Playground is a simple Blazor app that lets you experiment with a C# 9 source generator. It allows you to write a simple console application, and a source generator, and observe the generated output and the program output.

Multiple generators can be supplied, though they all need to live in the same text box, and the generator(s) can add any number of syntax trees to the compilation. All care is taken to capture meaningful errors from compilation of the generator, the program, and the running of the program.

You can browse through the in built samples to try out generators, and start modifying things to see what happens. If you want to run your own, use the Load buttons. At the moment the only references available that can be leveraged is whatever is necessary for the app itself.

Feel free to log issues for feedback, or PRs for new samples etc.

sourcegeneratorplayground's People

Contributors

buildstarted avatar davidwengier avatar epignosisx avatar stefanloerwald avatar willl 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  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  avatar  avatar

sourcegeneratorplayground's Issues

Failing in MS Edge

Uncaught Error: This browser does not support WebAssembly.
at blazor.webassembly.js:1:42456
at c (blazor.webassembly.js:1:43072)
at :1:20
at blazor.webassembly.js:1:43275
at new Promise ()
at Object.start (blazor.webassembly.js:1:37752)
at blazor.webassembly.js:1:35786
at blazor.webassembly.js:1:33770
at Object.next (blazor.webassembly.js:1:33875)
at i (blazor.webassembly.js:1:32589)

Please, pretty please, add support for a VB (Source Generator) experience.

With Source Generators coming to VB (available now in VS 16.9.0P2.0), can you please consider giving the ability to switch between a C# and/or VB experience?

Thanks.

UPDATE1: BTW, wanted to share how AWESOME this tool is... what an excellent way to give it a go without a whole lot of overhead.

Improve website SEO

Googling for the following phrases does not bring up the site in the first page (or second if anyones actually uses the second page).

source generators online
.net 5 source generators
roslyn source generators online

Such a great website should be more discoverable!

Context: yesterday I watched your talk on .NET Conf and today I wanted to give it a try but didn't remember the domain name.

Non-Hello World samples not working

Just tried this out, and all the samples other than Hello World are showing compiler errors, sounds like a reference to the NuGet package Microsoft.CodeAnalysis.CSharp is needed.

e.g. for Auto Notify the Output window shows:


Generator.cs(7,30): error CS0234: The type or namespace name 'CSharp' does not exist in the namespace 'Microsoft.CodeAnalysis' (are you missing an assembly reference?)
Generator.cs(8,30): error CS0234: The type or namespace name 'CSharp' does not exist in the namespace 'Microsoft.CodeAnalysis' (are you missing an assembly reference?)
Generator.cs(170,25): error CS0246: The type or namespace name 'FieldDeclarationSyntax' could not be found (are you missing a using directive or an assembly reference?)
Generator.cs(48,13): error CS0246: The type or namespace name 'CSharpParseOptions' could not be found (are you missing a using directive or an assembly reference?)
Generator.cs(48,66): error CS0246: The type or namespace name 'CSharpCompilation' could not be found (are you missing a using directive or an assembly reference?)
Generator.cs(48,111): error CS0246: The type or namespace name 'CSharpParseOptions' could not be found (are you missing a using directive or an assembly reference?)
Generator.cs(49,74): error CS0103: The name 'CSharpSyntaxTree' does not exist in the current context
Generator.cs(57,22): error CS0246: The type or namespace name 'FieldDeclarationSyntax' could not be found (are you missing a using directive or an assembly reference?)
Generator.cs(60,26): error CS0246: The type or namespace name 'VariableDeclaratorSyntax' could not be found (are you missing a using directive or an assembly reference?)
Generator.cs(170,85): error CS0246: The type or namespace name 'FieldDeclarationSyntax' could not be found (are you missing a using directive or an assembly reference?)
Generator.cs(178,35): error CS0246: The type or namespace name 'FieldDeclarationSyntax' could not be found (are you missing a using directive or an assembly reference?)

Same errors seen in firefox and chrome.

Dependency injection sample failing in some cases

I changed the code to this

using System;

namespace MyApp
{
class Program
{
static void Main()
{
// Comment and uncomment these lines to see how the generation changes
var foo = DI.ServiceLocator.GetService();

        var anotherFoo = DI.ServiceLocator.GetService<IFoo>();

        var bar = DI.ServiceLocator.GetService<IBar>();
        RegisterTest<ITest>();
        //// Uncomment to demonstrate build errors:
        // var baz = DI.ServiceLocator.GetService<IBaz>();

        Console.WriteLine("Hello World");
    }
    static void RegisterTest<T>()
    {
        var tt = DI.ServiceLocator.GetService<T>();
    }
}
interface ITest
{

}
//// Comment and uncomment the attribute to see how the generation changes
//[DI.Transient]
interface IFoo
{
}

class Foo : IFoo
{
}

interface IBar
{
}

class Bar : IBar
{
}

interface IBaz
{
}
class Test : ITest
{

}

}

When i run it, says Error(s) running generator:

warning CS8785: Generator 'DISourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'NullReferenceException' with message 'Object reference not set to an instance of an object.'

There are times when there is a public method and a person is using generics to decide what will register. In this case, its now working. Would be a shame if there was no way with source generators to make it work in that case since reflection is too slow.

[BUG] Doesn not resize properly

I've encountered an issue with the webpage layout not resizing correctly after adjusting the browser window size. Initially, when I enlarge the browser window, the webpage scales up as expected. However, the problem arises when I subsequently decrease the browser window size; the webpage does not scale down properly to fit the smaller size. This results in a layout that does not adjust to the reduced window size, potentially cutting off content or causing layout issues.

Steps to Reproduce

  1. Open the website in a web browser.
  2. Resize the browser window to a larger size, observing the webpage scale up accordingly.
  3. Without refreshing the page, resize the browser window to a smaller size.

Expected Behavior

The webpage should dynamically adjust and resize correctly both when the browser window is enlarged and when it is made smaller, ensuring that the layout and content are appropriately scaled and fully visible.

Actual Behavior

After enlarging the browser window and then making it smaller, the webpage does not resize back down properly. This results in a layout that doesn't fit the smaller window size, potentially obscuring content and causing usability issues.

Environment

  • Browser: Firefox 123.0.1 (64-Bit)
  • OS: Windows 11

Screenshots

grafik

(Yes, this is the full webpage)

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.