8000 GitHub - devlooped/SmallSharp: Create, edit and run multiple C# top-level programs in the same project by just selecting the startup program from the start button. Β· GitHub
[go: up one dir, main page]

Skip to content

About

Create, edit and run multiple C# top-level programs in the same project by just selecting the startup program from the start button.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

309 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

235 Commits

Folders and files

Repository files navigation

Icon SmallSharp

Version Downloads EULA OSS

Create, edit and run multiple C# file-based apps in the same project in the IDE, honoring per-file #:package references, #:property project values and even #:sdk 😍

Open Source Maintenance Fee

To ensure the long-term sustainability of this project, users of this package who generate revenue must pay an Open Source Maintenance Fee. While the source code is freely available under the terms of the License, this package and other aspects of the project require adherence to the Maintenance Fee.

To pay the Maintenance Fee, become a Sponsor at the proper OSMF tier. A single fee covers all of Devlooped packages.

Overview

C# top-level programs allow a very intuitive, simple and streamlined experience for quickly spiking or learning C#. The addition of file-based apps in .NET 10 takes this further by allowing package references and even MSBuild properties to be specified per file:

#:package Humanizer@2.14.1
#:property ImplicitUsings=true
#:property Nullable=enable

using Humanizer;

var dotNet9Released = DateTimeOffset.Parse("2024-12-03");
var since = DateTimeOffset.Now - dotNet9Released;

Console.WriteLine($"It has been {since.Humanize()} since .NET 9 was released.");

Editing these standalone files in VSCode, however, is suboptimal compared with the full C# experience in Visual Studio. In Visual Studio, though, you can only have one top-level program in a project, and as of now, you cannot leverage the #:package and #:property directives at all.

SmallSharp allows dynamically selecting the file to run, right from the Start button/dropdown (for compilation and launch/debug). It also automatically restores the #:package references so the project system can resolve them, and even emits the #:property directives if present to customize the build as needed.

start button

This list is automatically kept in sync as you add more .cs files to the project. When you select one target C# file, that becomes the only top-level program to be compiled, so you don't have to modify any of the others since they automatically become None items.

Tip

An initial build after selection change migh be needed to restore the packages and compile the selected file, unless you're using the SDK mode for SmallSharp (see below).

All compile files directly under the project directory root are considered top-level programs for selection and compilation purposes. If you need to share code among them, you can place additional files in subdirectories and those will behave like normal compile items.

Usage