Skip to content

Update of samples to latest Microsoft assemblies and Visual Studio#442

Merged
oleg-shilo merged 12 commits intooleg-shilo:masterfrom
maettu-this:sample_update
Feb 14, 2026
Merged

Update of samples to latest Microsoft assemblies and Visual Studio#442
oleg-shilo merged 12 commits intooleg-shilo:masterfrom
maettu-this:sample_update

Conversation

@maettu-this
Copy link
Collaborator

Hi Oleg,

This PR is related to #434 analysis. Please review the changes and adjust/refine as needed. I'll also add some comments with additional input.

Note that I have also tried to use the almost "latest" C# 13 with the NET472 samples:

...
    .LoadMethod(@"public char func()
    {
        return '\e';
    }");

    char result = script.func();
}

Results in:

CSScriptLib.CompilerException
  HResult=0x80131600
  Message=C:\Users\<USER>\AppData\Local\Temp\CSSCRIPT\22772.e8d93bcc-0132-4eb3-b607-0cfc0c6032dd.tmp.cs(7,64): error CS1009: Unrecognized escape sequence.

  Source=CSScriptLib
  StackTrace:
   at CSScriptLib.CodeDomEvaluator.CompileAssemblyFromFileBatch_with_Csc(String[] fileNames, String[] ReferencedAssemblies, String outAssembly, Boolean IncludeDebugInformation, CompileInfo info) in <WORKSPACE>\src\CSScriptLib\src\CSScriptLib\Evaluator.CodeDom.cs:line 425
   at CSScriptLib.CodeDomEvaluator.Compile(String scriptText, String scriptFile, CompileInfo info) in <WORKSPACE>\src\CSScriptLib\src\CSScriptLib\Evaluator.CodeDom.cs:line 156
   at CSScriptLib.EvaluatorBase`1.CompileCode(String scriptText, String scriptFile, CompileInfo info) in <WORKSPACE>\src\CSScriptLib\src\CSScriptLib\EvaluatorBase.cs:line 241
   at CSScriptLib.EvaluatorBase`1.CompileCode(String scriptText) in <WORKSPACE>\src\CSScriptLib\src\CSScriptLib\EvaluatorBase.cs:line 135
   at CSScriptLib.EvaluatorBase`1.LoadCodeByName(String scriptText, String className, Object[] args) in <WORKSPACE>\src\CSScriptLib\src\CSScriptLib\EvaluatorBase.cs:line 609
   at CSScriptLib.EvaluatorBase`1.LoadMethod(String code) in <WORKSPACE>\src\CSScriptLib\src\CSScriptLib\EvaluatorBase.cs:line 762
   at Client.NET472.Program.Test_CodeDom() in <WORKSPACE>\src\CSScriptLib\src\Client.NET472 (Roslyn+CodeDom)\Program.cs:line 55
   at Client.NET472.Program.main(String[] args) in <WORKSPACE>\src\CSScriptLib\src\Client.NET472 (Roslyn+CodeDom)\Program.cs:line 38
   at Client.NET472.Program.Main(String[] args) in <WORKSPACE>\src\CSScriptLib\src\Client.NET472 (Roslyn+CodeDom)\Program.cs:line 21

https://stackoverflow.com/questions/56651472/does-c-sharp-8-support-the-net-framework quite well explains on the possibilities and limitations of using C# 8+ with .NET Framework. Possible yes, but neither recommended nor without restrictions. I have tried to make this clearer in the CS-Script samples.

Best regards,
Matthias

Copy link
Collaborator Author

@maettu-this maettu-this left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional input as mentioned in the PR.

Copy link
Collaborator Author

@maettu-this maettu-this left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more finding/proposal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about the samples, how about splitting (Roslyn+CodeDom) such this project gets reduced to (Roslyn) and all CodeDom related functionality is demonstrated by (CodeDom)?

Rationale:

  • Roslyn doesn't need to NuGet csc.exe, correct?
  • More obvious to host app developer which parts need to be taken, depending on evaluator used.

@maettu-this
Copy link
Collaborator Author

maettu-this commented Feb 11, 2026

I have just added to the PR by further cleaning up the .NET Framework sample projects. Please see commit messages for details.

To conclude on this PR, please see proposals further above.

@oleg-shilo oleg-shilo merged commit 65c41ed into oleg-shilo:master Feb 14, 2026
1 of 2 checks passed
@oleg-shilo
Copy link
Owner

I am merging it as is. But I am planning to rework the whole .NET Framework use case so there will be a reasonable change in the sample(s).
But I will merge this PR anyway to get the latest dependencies.

oleg-shilo added a commit that referenced this pull request Feb 15, 2026
Major rework f the .NET Framework samples. Triggered by #442
===================
Refactor compiler selection and CodeDom evaluator logic

- Remove obsolete CompileOnServer and move compiler path logic from Globals to CodeDomEvaluator
- Add DefaultNetFrameworkCompiler, SuppressDefaultNetFrameworkAssemblies, and MsNetComilersToolsetCompiler to CodeDomEvaluator
- Update assembly reference logic to support suppressing default .NET Framework assemblies
- Refactor Client.NET472 test code for clarity and coverage; remove NetCompiler.cs and related code
- Update solution/project files to remove "Client.NET472 (Roslyn+CodeDom)" and add "Client.NET472"
- Expand csc property documentation for clarity and platform details
oleg-shilo added a commit that referenced this pull request Feb 15, 2026
Reworked and unified csc.exe probing for CodeDom compilation.
Triggered by #434 and #442
=============
Improve compiler discovery and add SemanticVersion class

Refactored compiler location logic into Globals with new methods for NuGet and SDK-based compilers. Introduced SemanticVersion class for parsing and comparing semantic versions, with comprehensive unit tests. Updated CodeDomEvaluator to handle .dll and .exe compilers correctly. Added Microsoft.Net.Sdk.Compilers.Toolset NuGet reference to Client.NET. Fixed minor bugs and improved process handling. Expanded documentation and updated build/test scripts.
@maettu-this
Copy link
Collaborator Author

maettu-this commented Feb 16, 2026

I am merging it as is. But I am planning to rework the whole .NET Framework use case so there will be a reasonable change in the sample(s). But I will merge this PR anyway to get the latest dependencies.

@oleg-shilo, sounds reasonable. Do you intend to do this work as part of #440? If so, will you copy-paste the additional findings/proposals from this PR to that issue or shall I do so? Or will work be as part of a new issue?

@oleg-shilo
Copy link
Owner

Yes, I have practically finished. working on #440. I treatedthis effort as a continuation of this very PR.
I also extended the documentation to cover the use cases that you have discovered are not straightforward.
I communicated these doc changes in our exchange in #434.

The proposal from this PR is implemented (e.g. the NET Frx code sample has been collapsed into a single sample). The compiler is now coming from the NuGet package, even though the SDK distro is also detected as a fallback.

Though packaging the compilers with the user app is yet to be documented.

Is this what you mean?

@maettu-this
Copy link
Collaborator Author

Is this what you mean?

Yepp, exactly. I'll take a closer look at the reworked samples once I see #440 got closed and I find some time to do so. Thanks for all the efforts!

@oleg-shilo
Copy link
Owner

I will close #440 only after 1 month without any post-release defect reports. This is the workflow I follow.
To indicate completion of the development, I use labels.
I just marked it as done: waiting for release. So you can have a look at the code already, but of course, it is not released yet.

  • Framework Sample
  • Core Sample
  • Documentation on handling shared dependencies (e.g. Microsoft.CodeAnalysis.dll)
  • [yet to be done] Documentation on how to distribute apps that require CodeDom compilers
  • [yet to be done] Replace all mentionings ".NET SDK needed" with the nuget package alternative option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants