Can we have file viewing and highlighting for cs, fs, vb like we have for xml, json, sql files?

edited April 7

Using #load with .cs files from within LINQPad ( #load "My Queries\myutils\mycsharpfile.cs" )


  • Is your request just to be able to view those files? Or would you expect more functionality such as highlighting and execution?

  • The #load feature is how we can use .cs files so to view and have syntax highlighting on these files would be great.

    xml, json, txt and sql files are supported.

    @JoeAlbahari My request is to add cs, csx, vb, fs, fsx. 🤞

  • Syntax highlighting is already supported for .cs and .csx files. Furthermore, you can execute .cs files directly in LINQPad if there are no missing dependencies. It doesn't work in your case because your file has a .cs.txt extension rather than a .cs extension.

    I can add support for .fs/.fsx and .vb file extensions, although support for .vb won't go beyond syntax highlighting - it would be a lot of work to get .vb files run directly in LINQPad. Visual Basic files are also unsupported for #load. Are you a big user of VB?

  • edited April 8

    See my screenshot below.

    That zcdvzv.cs file doesn't show up inside the My Queries folder like txt, json, xml and sql files do. I dragged and dropped it inside LINQPad to open.

    You can also save a file as anything see my screenshot below:

    LINQPad adds .linq to the end of my .stephen file. The file extension is visible in the explorer which represent the file name inside LINQPad but not on disk. This behavior is different from how json files are handled. Saving a new query as yourfilename.json will create a json file natively inside LINQPad and on disk. In other words json files are natively supported as a special file type with unique behavior.

    Inside the directory there are cs files not visible in My Queries explorer.

    The files with .txt added to them was done so I can view them inside of LINQPad, which is a workaround in lieu of file type support.

    The Open Query dialog file types include cs files however not visible in My Queries explorer.

    And csv files can be opened but not visible inside the explorer.

    Is it possible to make any file type under My Queries visible? Maybe advanced settings or options? Or maybe a API for custom file type handlers via a plugin?

    With the new AI assistant features working with more file types inside LINQPad can be useful to reduce context switching with other apps.

    When opening a cs file it is rendered as a linq file which is the wrong behavior?

    cs, fs, vb etc. should be rendered similar to how the other supported file types are without linq file features enabled/visible?

    I code in VB less often due to its decline in general so whatever you can do is fine.

    I suppose my title should have said something similar to " Can we have file types visible inside the My Queries explorer with highlighting for cs, fs, vb, etc. like we have for xml, json, sql files?


  • edited April 10

    @JoeAlbahari Another idea is to have a setting to make visible all file extensions but only open inside LINQPad file types you support. So a pdf file selected in the explorer won't open anything similar to the behavior when folders are selected.

    But add an item to the right-click menu:

    To open file in default app. So a Python file would open in VS Code on my PC.

    This would allow me to work with 3D model files e.g., 3dm, obj, step, stl, SoldWorks files related to queries opened in LINQPad without leaving LINQPad.

    Selecting an unsupported file won't do anything in LINQPad only be visible in the explorer and able to be opened in default app. Unsupported files should be excluded from search.

    To recap:

    Supported files:
    cs, csx, fs, fsx, txt, json, sql, xml, config, vb, etc.
    Opens inside LINQPad with type specific syntax highlighting
    Included in search or find operations

    Unsupported files:
    py, js, ts, 3D formats, image formats etc.
    Only visible
    Excluded from search or find operations
    Right-click menu to open file in default app

    These maybe better put under Editor or General here:

    My current solution for working with unsupported file types is simalar to this:

        var allfiles = Directory.GetFiles(Util.MyQueriesFolder);
        foreach (var item in allfiles)
            FileInfo f = new FileInfo(item);
            Hyperlinq h = new Hyperlinq(f.FullName).Dump();

    Then open file from Results panel.

  • The latest beta shows .cs/.fs files in My Queries and Navigate To. There's a good case for allowing these in that LINQPad offers quite good support for .cs/.fs, both in terms of direct execution and inclusion via #load. The Ctrl+K,O feature has also been expanded to open the My Queries folder if the current query doesn't have a location (hasn't been saved). This should make it easier to bring up Windows Explorer to manage other file types.

    The File | Open dialog also now supports a greater range of file types that can be syntax-highlighted using LINQPad's existing parsers. In terms of allowing these to appear in My Queries, this would have to be an option and so requires additional work that will push it forward into a future feature request.

Sign In or Register to comment.