Code Monkey home page Code Monkey logo

Comments (4)

TyOverby avatar TyOverby commented on September 28, 2024

These should all be available now.

from try.

rpetrusha avatar rpetrusha commented on September 28, 2024

This issue should be reopened.

Although the user's current culture is detected for code run directly in the try.dot.net REPL, this is not the case for code run from docs.microsoft.com/dotnet.

For instance, the example for the "C" standard numeric format string in Standard numeric format strings is:

double value = 12345.6789;
Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture));
Console.WriteLine(value.ToString("C3", CultureInfo.CurrentCulture));
Console.WriteLine(value.ToString("C3", 
                  CultureInfo.CreateSpecificCulture("da-DK")));

This produces the following output:

(2,39): error CS0103: The name 'CultureInfo' does not exist in the current context
(3,40): error CS0103: The name 'CultureInfo' does not exist in the current context
(5,19): error CS0103: The name 'CultureInfo' does not exist in the current context

If the code is modified by fully qualifying references to CultureInfo, it works:

¤12,345.68
¤12,345.679
kr. 12.345,679

If it is wrapped in a complete type/method, an OutOfMemoryException results. For example, the following code:

public class Example
{
    public static void Main()
    {
        double value = 12345.6789;
        Console.WriteLine(value.ToString("C", System.Globalization.CultureInfo.CurrentCulture));
        Console.WriteLine(value.ToString("C3", System.Globalization.CultureInfo.CurrentCulture));
        Console.WriteLine(value.ToString("C3", 
                        System.Globalization.CultureInfo.CreateSpecificCulture("da-DK")));
    }
}

produces the following output:

System.OutOfMemoryException: Out of memory
  at (wrapper managed-to-native) System.AppDomain.LoadAssemblyRaw(System.AppDomain,byte[],byte[],System.Security.Policy.Evidence,bool)
  at System.AppDomain.Load (System.Byte[] rawAssembly, System.Byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence, System.Boolean refonly) <0x29da3b8 + 0x0003e> in <900ecd0f11284a0ca19b03bb59a43de7>:0 
  at System.AppDomain.Load (System.Byte[] rawAssembly, System.Byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence) <0x29da258 + 0x00022> in <900ecd0f11284a0ca19b03bb59a43de7>:0 
  at System.AppDomain.Load (System.Byte[] rawAssembly) <0x29da188 + 0x00014> in <900ecd0f11284a0ca19b03bb59a43de7>:0 
  at System.Reflection.Assembly.Load (System.Byte[] rawAssembly) <0x29da0c0 + 0x00010> in <900ecd0f11284a0ca19b03bb59a43de7>:0 
  at MLS.WasmCodeRunner.CodeRunner.ProcessCompileResult (MLS.WasmCodeRunner.CompileResult compileResult, System.Int32 sequence) <0x29d85f8 + 0x00040> in <14b79e8017af40b2b2f7b42a1677165b>:0 

And adding a using statement to the previous code to import the System.Globalization namespace doesn't work:

(1,7): error CS1003: Syntax error, '(' expected
(1,7): error CS0118: 'System.Globalization' is a namespace but is used like a variable
(1,27): error CS1026: ) expected
(1,27): error CS0642: Possible mistaken empty statement
(1,1): error CS1513: } expected

from try.

jonsequitur avatar jonsequitur commented on September 28, 2024

The difference in behavior between try.dot.net and docs.microsoft.com/dotnet is because the latter is using the in-browser execution model via Blazor, whereas the former is using C# scripting. We can opt specific pages (but not specific samples within a page) out of the Blazor implementation. This is a short-term fix because the scripting-based implementation will be going away. We should discuss how to adjust the content accordingly.

@rchande @jdanyow

from try.

jonsequitur avatar jonsequitur commented on September 28, 2024

This issue is no longer relevant to the current implementation.

from try.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.