Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Commit 79262a4

Browse files
committed
CST files improved
Now you can type any code in a .cst file without the need of adding all the usings, nor "namespace Foo", nor "public class Bar". You can just type the code you wish to execute.
1 parent 7735cc1 commit 79262a4

20 files changed

Lines changed: 60 additions & 74 deletions

CSMD/CSMD.csproj

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
<AssemblyName>CSMD</AssemblyName>
1212
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<NoWin32Manifest>False</NoWin32Manifest>
15+
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
16+
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
17+
<NoStdLib>False</NoStdLib>
18+
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
19+
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
1420
</PropertyGroup>
1521
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1622
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -23,9 +29,9 @@
2329
<WarningLevel>4</WarningLevel>
2430
</PropertyGroup>
2531
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<PlatformTarget>AnyCPU</PlatformTarget>
27-
<DebugType>pdbonly</DebugType>
28-
<Optimize>true</Optimize>
32+
<PlatformTarget>x86</PlatformTarget>
33+
<DebugType>PdbOnly</DebugType>
34+
<Optimize>True</Optimize>
2935
<OutputPath>bin\Release\</OutputPath>
3036
<DefineConstants>TRACE</DefineConstants>
3137
<ErrorReport>prompt</ErrorReport>
@@ -101,6 +107,15 @@
101107
<PropertyGroup>
102108
<PostBuildEvent>"D:\Archivos de programa (x86)\Insert Icons\InsertIcons.exe" "$(TargetPath)" "$(ProjectDir)cst.ico"</PostBuildEvent>
103109
</PropertyGroup>
110+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
111+
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
112+
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
113+
</PropertyGroup>
114+
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
115+
<BaseAddress>4194304</BaseAddress>
116+
<RegisterForComInterop>False</RegisterForComInterop>
117+
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
118+
</PropertyGroup>
104119
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
105120
Other similar extension points exist, see Microsoft.Common.targets.
106121
<Target Name="BeforeBuild">

CSMD/Compiler.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ void Init() {
3434

3535
public void Compile(string code = "") {
3636

37-
CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<String, String>
37+
var provider = new CSharpCodeProvider(new Dictionary<String, String>
3838
{ { "CompilerVersion", NETVersion } });
3939

40-
CompilerParameters cp = new CompilerParameters() {
40+
var cp = new CompilerParameters {
4141
GenerateInMemory = false,
4242
GenerateExecutable = true,
4343
IncludeDebugInformation = false,
@@ -56,12 +56,36 @@ public void Compile(string code = "") {
5656
Compile(cp, provider, code);
5757
}
5858

59-
void Compile(CompilerParameters cp, CSharpCodeProvider provider, string code) {
59+
void Compile(CompilerParameters cp, CodeDomProvider provider, string code) {
60+
61+
const string basecode = @"using System;
62+
using System.Collections.Generic;
63+
using System.Linq;
64+
using System.Text;
65+
using System.IO;
66+
using System.Diagnostics;
67+
68+
namespace Foo {
69+
public class Bar {
70+
@main
71+
}
72+
}";
73+
74+
const string main = @"static void Main(string[] args) {
75+
@code
76+
}";
77+
78+
if (!code.Contains("namespace Foo") && !code.Contains("public class bar"))
79+
if (!code.Contains("static void Main"))
80+
code = basecode.Replace("@main", main).Replace("@code", code);
81+
else
82+
code = basecode.Replace("@main", code);
83+
6084
CompilerResults cr = provider.CompileAssemblyFromSource(cp, code);
6185

6286
if (cr.Errors.Count > 0)
6387
{
64-
List<string> errors = new List<string>();
88+
var errors = new List<string>();
6589

6690
foreach (CompilerError ce in cr.Errors)
6791
errors.Add((ce.IsWarning ? "Warning " : "Error ") + ce.ErrorNumber + " [Line " + ce.Line

CSMD/MainF.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public MainF(string[] args = null)
4444
Args = args;
4545
}
4646
else // This takes so, so long in InitializeComponent();
47-
compileTSSB.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[]
47+
compileTSSB.DropDownItems.AddRange(new ToolStripItem[]
4848
{ settingsTSMI, saveTSMI, tss, spamTSMI});
4949

5050
if (Settings.Default.ExecutablePath == "") {
@@ -57,18 +57,17 @@ public MainF(string[] args = null)
5757
infoTSSL.Text += Application.ProductVersion;
5858
}
5959

60-
private void MainF_Load(object sender, EventArgs e) {
60+
void MainF_Load(object sender, EventArgs e) {
6161
consoleTB.Select(170, 0);
6262
}
6363

64-
#endregion
65-
66-
64+
#endregion
6765

6866
#region Editor
6967

70-
private void consoleTB_KeyDown(object sender, KeyEventArgs e) {
68+
#endregion
7169

70+
void consoleTB_KeyDown(object sender, KeyEventArgs e) {
7271
int i = consoleTB.SelectionStart;
7372
int l = consoleTB.GetLineFromCharIndex(i);
7473
int t = LineTabs(l);
@@ -90,7 +89,7 @@ private void consoleTB_KeyDown(object sender, KeyEventArgs e) {
9089

9190
int bfss = -1; // before selection start
9291

93-
private void consoleTB_KeyUp(object sender, KeyEventArgs e)
92+
void consoleTB_KeyUp(object sender, KeyEventArgs e)
9493
{
9594
//int i = consoleTB.SelectionStart;
9695
//int l = consoleTB.GetLineFromCharIndex(i);
@@ -102,18 +101,16 @@ private void consoleTB_KeyUp(object sender, KeyEventArgs e)
102101
}
103102

104103

105-
private int LineTabs(int lineIndex)
104+
int LineTabs(int lineIndex)
106105
{
107106
string line = consoleTB.Text.Split('\n')[lineIndex];
108107
string fl = Regex.Split(line, "[^\t]+")[0];
109108
return fl.Count(c => c == '\t');
110109
}
111110

112-
#endregion
113-
114111
#region Compile
115112

116-
private void compileTSSB_ButtonClick(object sender, EventArgs e) {
113+
void compileTSSB_ButtonClick(object sender, EventArgs e) {
117114
Compile();
118115
}
119116

@@ -123,15 +120,15 @@ private void compileTSSB_ButtonClick(object sender, EventArgs e) {
123120

124121
#region Status strip
125122

126-
private void settingsTSMI_Click(object sender, EventArgs e)
123+
void settingsTSMI_Click(object sender, EventArgs e)
127124
{ new SettingsF().Show(); }
128125

129-
private void saveTSMI_Click(object sender, EventArgs e) {
126+
void saveTSMI_Click(object sender, EventArgs e) {
130127
if (codeSFD.ShowDialog() == DialogResult.OK)
131128
File.WriteAllText(codeSFD.FileName, consoleTB.Text, Encoding.UTF8);
132129
}
133130

134-
private void spamTSMI_Click(object sender, EventArgs e)
131+
void spamTSMI_Click(object sender, EventArgs e)
135132
{ Process.Start("http://lonamiwebs.tk"); }
136133

137134
#endregion

CSMD/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// Puede especificar todos los valores o establecer como predeterminados los números de compilación y de revisión
3333
// mediante el carácter '*', como se muestra a continuación:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.2.8")]
36-
[assembly: AssemblyFileVersion("1.0.2.8")]
35+
[assembly: AssemblyVersion("1.0.3.2")]
36+
[assembly: AssemblyFileVersion("1.0.3.2")]

CSMD/bin/Debug/CSMD.exe

1 KB
Binary file not shown.

CSMD/bin/Debug/CSMD.pdb

4 KB
Binary file not shown.

CSMD/bin/Debug/CSMD.vshost.exe

-23.6 KB
Binary file not shown.

CSMD/bin/Debug/CSMD.vshost.exe.config

Lines changed: 0 additions & 40 deletions
This file was deleted.

CSMD/bin/Debug/CSMD.vshost.exe.manifest

Lines changed: 0 additions & 11 deletions
This file was deleted.
-3.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)