Table of Contents

Visual Studio Code - Guide

This guide will help you get VS Code Setup as best as possible for 2sxc development.

Tip

You'll often write code in your 2sxc Apps - either as C#/Razor or JavaScript. 2sxc is a very open system, so you can use any editor you like. For quick fixes and simple things, use the built-in editor, which is based on Monaco (VS Code Online). But for more sophisticated stuff we highly recommend VS Code.

Prepare VS Code for 2sxc

VSCode is amazing right out of the box, but to really be productive, you need to do a few things:

  1. Install VS Code
  2. Install the C# DevKit extensions
  3. Configure each App with
    1. Intellisense (see below)
    2. Ignore the obj and .vs folders (see below)
  4. Check possible edge cases (see below)

With these preparations, VS-Code is able to assist in basic C# code. It can't provide IntelliSense for 2sxc specific APIs yet, so for that, read on.

Setup IntelliSense

Then

  1. copy the files app.sln and app.csproj from the templates folder to your main app folder (or a specific edition-subfolder)
  2. restart VS Code
  3. if VS Code / C# Dev Kit asks which solution to load, choose the correct app.sln for the folder you want to work on
Note

2sxc app setups contains multiple .sln files, so VS Code / C# Dev Kit should usually prompt you to choose one and remember that choice for the workspace. If it does not load the correct solution reliably, use the .NET: Open Solution command and manually open the root app.sln.

That's it - you should now have IntelliSense on all your C# and Razor files.

➡️ See full instructions here: DotNet Project (VS Code Helper)

GitIgnore Temporary Folders

Add these lines to your .gitignore file to prevent temporary files from being added to your repository:

.vs/
obj/
bin/

Warnings when Using IntelliSense

Warning

IntelliSense can show you internal APIs which will change over time.

IntelliSense is an amazing productivity boost, but you should avoid using internal APIs.

To make this unlikely, we spent a LOT of time to clearly mark internal stuff. Avoid the following:

  1. Almost everything in the ToSic.Eav.* namespace is usually internal, so avoid using it
    1. Exception: ToSic.Eav.Data, ToSic.Eav.DataSource and ToSic.Eav.DataSources are really public
  2. Anything in a *.Internal namespace
  3. Anything in a *.Integration namespace
  4. Anything in a *.Backend namespace
  5. Anything in a *.Sys namespace
  6. Anything marked with [Obsolete]
  7. Anything marked with [EditorBrowsable(EditorBrowsableState.Never)] - IntelliSense will not show these APIs
  8. Properties beginning with an underscore, eg _Something

Known Issues when C# IntelliSense is not Working

Here we try to collect known issues and solutions.

  1. A razor file has the same name as a C# class in the AppCode Folder
    This will confuse the IntelliSense, since the Razor file will magically be seen as a class with the same name. Solution: Rename the Razor file to something else.

Configure an App for JavaScript IntelliSense

TODO: this is not yet documented


History

  • Added v16.07 2023-10
  • 2024-06-19 - Added more details about the .csproj file incl. date-version and correct DNN System.Net.Http reference
  • 2026-03-21 major update with complex .csproj which is outsourced to the DotNet Project extension.

Shortlink: https://go.2sxc.org/vscode