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

Enable C#12#3338

Merged
colombod merged 1 commit into
dotnet:mainfrom
colombod:enable_cs12
Nov 23, 2023
Merged

Enable C#12#3338
colombod merged 1 commit into
dotnet:mainfrom
colombod:enable_cs12

Conversation

@colombod

@colombod colombod commented Nov 23, 2023

Copy link
Copy Markdown
Member

Complete .NET8 release with C#12 support

@colombod colombod added Area-C# Specific to C# enhancement New feature or request labels Nov 23, 2023
@colombod
colombod merged commit 35c844a into dotnet:main Nov 23, 2023
@colombod
colombod deleted the enable_cs12 branch November 23, 2023 14:30
@johngardner58work

johngardner58work commented Sep 30, 2024

Copy link
Copy Markdown

using declaration not supported only using statements. Get Error: (4,22): error CS1002: ; expected
See code from Jupyter Lab in VScode .NET Interactive Kernel below:
`#r "nuget: Microsoft.Extensions.Logging, 8.0.0"
#r "nuget: Microsoft.Extensions.Logging.Console, 8.0.0"
#r "nuget: Microsoft.Extensions.Configuration, 8.0.0"

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;

using ILoggerFactory factory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Information));
ILogger logger = factory.CreateLogger("Program");

logger.LogTrace("Trace message");
logger.LogDebug("Debug message");
logger.LogInformation("Info message");
logger.LogWarning("Warning message");
logger.LogError("Error message");
logger.LogCritical("Critical message");`

@colombod

Copy link
Copy Markdown
Member Author

Using statement are not supported in csharp scripting, they won't work

@jonsequitur

Copy link
Copy Markdown
Contributor

@johngardner58work Is it your expectation that disposal would happen when the kernel is shut down (i.e. when you restart it or close the notebook)?

If so you can do this:

Microsoft.DotNet.Interactive.Kernel.Root.RegisterForDisposal(factory);

@johngardner58work

Copy link
Copy Markdown

@colombod Using statement in block form does work, not the using declaration form. I don't see why Csharp scripting would care which. Perhaps I should repost for Csharp scripting?

if (...) // this does not work
{
using FileStream f = new FileStream(@"C:\users\jaredpar\using.md");
// statements
}

// NOT Equivalent in C# script but DOES work
if (...)
{
using (FileStream f = new FileStream(@"C:\users\jaredpar\using.md"))
{
// statements
}
}

@jonsequitur

Copy link
Copy Markdown
Contributor

Perhaps I should repost for Csharp scripting?

The place to open this issue would be in dotnet/roslyn.

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

Labels

Area-C# Specific to C# enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants