Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Simplified Single File C# Execution #43681

Open
kapilepatel opened this issue Nov 21, 2024 · 0 comments
Open

Proposal: Simplified Single File C# Execution #43681

kapilepatel opened this issue Nov 21, 2024 · 0 comments
Labels

Comments

@kapilepatel
Copy link

kapilepatel commented Nov 21, 2024

Describe the issue or suggestion

Proposal: Simplified Single File C# Execution

Current Situation

In many programming languages like JavaScript, Python, Java, C, C++, and Go, developers can easily run single source files without creating a full project structure. However, in .NET, running a single .cs file requires setting up an entire project with multiple files and configurations.

The Pain Points

  • Increased friction for quick experiments
  • Overhead for learning and prototyping
  • Barrier to entry for newcomers
  • Time-consuming setup for simple code snippets

Potential Solutions

1. Global Tool for Single File Execution

  • Develop a dotnet global tool that can directly run a .cs file
  • Example desired syntax: dotnet run-cs MyScript.cs

2. Language-Level Support

  • Introduce a compiler flag or runtime option to execute single files
  • Similar to Python's or JavaScript's direct file execution

3. REPL Improvements

  • Enhance C# Interactive (csi) to more seamlessly handle standalone files
  • Make it more intuitive and feature-rich

Existing Partial Workarounds

  • Using dotnet script (community package)
  • Mono's C# compiler
  • Online REPLs

Questions for Discussion

  • What are the technical challenges preventing single file execution?
  • Are there architectural reasons for the current project-based approach?
  • Would a standardized solution benefit the .NET ecosystem?

Community Impact

  • Lower entry barrier for new developers
  • Faster prototyping and learning
  • Improved developer experience

// Current Painful Path
// Requires creating multiple files, project structure, etc.

/ Desired Simple Execution
// Imagine being able to just run: dotnet run-cs SimpleProgram.cs
//filename SimpleProgram.cs

public class SimpleProgram 
{
    public static void Main()
    {
        Console.WriteLine("Hello, World!");
    }
}
@dotnetrepoman dotnetrepoman bot added the ⌚ Not Triaged Not triaged label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant