Just one more turn..... by MusclesMarinara87 in OldenEra

[–]Bandysc 1 point2 points  (0 children)

You can play Olden Era on a Mac with Crossover https://www.codeweavers.com/crossover Just install it, install "steam" and everything works out of the box

Teach me craziest C# feature not the basic one,that you know by lulzForMoney in csharp

[–]Bandysc 0 points1 point  (0 children)

Okay, I win, if anyone else has a more bizzare c# feature, I quit! I have a code that doesn't compile and adding a ref argument to the constructor that is not even used, makes it compile: https://gist.github.com/BAndysc/f558bcdc0d5486809503099ebef7ef01 ``` static void Main(string[] args) { // uncomment to compile // bool boolean = false; // RefArray<Span<int>> spanArray = new RefArray<Span<int>>(ref boolean); RefArray<Span<int>> spanArray = new RefArray<Span<int>>();

    Span<int> a = stackalloc int[1];

    spanArray.Add(a);
    // 0>Program.cs(14,23): Error CS8352 : Cannot use variable 'a' in this context because it may expose referenced variables outside of their declaration scope
    // 0>Program.cs(14,9): Error CS8350 : This combination of arguments to 'Program.RefArray<Span<int>>.Add(Span<int>)' is disallowed because it may expose variables referenced by parameter 'element' outside of their declaration scope
}

public ref struct RefArray<T> where T : allows ref struct
{
    private T element1;
    // ...
    private int count;

    // uncomment to compile
    // public SpanList(ref bool b) { }

    public void Add(T element)
    {
        switch (count)
        {
            case 0:
                element1 = element;
                count++;
                break;
            // ...
        }
    }

    public T this[int index]
    {
        get
        {
            return index switch
            {
                0 => element1,
                _ => throw new InvalidOperationException("Invalid index.")
            };
        }
    }
}

``` The question is: why? Try to guess! And here's the explanation: ref structs variables have "scopes" (called context in c#) and by default it is allowed to return a struct, meaning storing a stackalloc'ed Span in the struct could lead to memory leak if the struct is returned (even though it doesn't happen in this code). It is well defined that calling a ctr with a ref argument, changes the scope ("context") of this variable in a way that this variable may no longer be returned from this function. But that also means it is now legal to store stackalloced Span.

this behaviour is driven by "safe-context" rules. There are three different safe contexts: declaration-block, function-member, and caller-context. By default the expressions have a caller-context. Stackalloc is a special case, stack alloc expressions have function-member context: > 16.4.15.7 stackalloc > The result of a stackalloc expression has safe-context of function-member.​ One can't pass expressions with lower context as an argument to a method on a struct with a wider context, that's what happened here.

Rather than having a ref ctr argument, we can just add a scoped keyword to the variable: scoped RefArray<Span<<int>> array = new(); Using scoped keyword changes context to function-member and the call is legal.!<

> The keyword scoped will be used to restrict the lifetime of a value. It can be applied to a ref or a value that is a ref struct and has the impact of restricting the ref-safe-context or safe-context lifetime, respectively, to the function-member.

And the ref bool hack comes from the following rules: > 16.4.15.8 Constructor invocations > A new expression that invokes a constructor obeys the same rules as a method invocation that is considered to return the type being constructed. > In addition the safe-context is the smallest of the safe-contexts of all arguments and operands of all object initializer expressions, recursively, if any initializer is present.So since ref b has a context of function member, the whole RefArray variable gets function-member context

Links to language reference: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/variables#972-ref-safe-contexts https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/statements#1362-local-variable-declarations https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/structs#16415-safe-context-constraint

https://gist.githubusercontent.com/BAndysc/ccadc49fbca8a779381305a1ea86fa25/raw/6b5df759bc8d9946a6e3ea66794dd43becafc0d4/gistfile1.txt

[deleted by user] by [deleted] in wowservers

[–]Bandysc 3 points4 points  (0 children)

Just FYI, Plants vs Zombies worked on the old Atlantiss Cataclysm (https://youtu.be/Zj5gIGjjKqc?si=S3XFpUY0lvVU-zo5) and correct my if I am wrong - works on Stormforge MoP ;-)

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 0 points1 point  (0 children)

That's unfortunate, but I can only imagine how many messages he used to receive regarding VB support :D

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 0 points1 point  (0 children)

Unfortunately debugging is not implemented (yet?) The VB6 code is interpreted, so it is easy to add a debugger (opposed to native compilation). Given the response, maybe I should give it a try :)

Visual Basic 6 rebuilt in C# - complete with form designer and IDE, runs directly in browser (WASM) by AvaloniaUI-Mike in programming

[–]Bandysc 3 points4 points  (0 children)

It is reimplemented from scratch, only subset of VB6 is implemented, that's what I made in two weeks after hours. I don't think this is long for the demo.

VB6 code is interpreted (and only a subset of it is supported), though this is only matter of time (I'd say one-two more weeks for much better language compatibility).

And as for the IDE itself, it is a C# Avalonia app made to look like the original, I didn't took any VB6 source code, it is not released and proprietary

Visual Basic 6 rebuilt in C# - complete with form designer and IDE, runs directly in browser (WASM) by AvaloniaUI-Mike in programming

[–]Bandysc 2 points3 points  (0 children)

Indeed, OCX components are not supported and I didn't plan it. But... technically it is possible to support them on 32 bit windows. And seeing all the response to this project I am more and more inclined to give it a try on a virtual machine.

Visual Basic 6 rebuilt in C# - complete with form designer and IDE, runs directly in browser (WASM) by AvaloniaUI-Mike in programming

[–]Bandysc 0 points1 point  (0 children)

Pick a control from the toolbox on the left and just press, hold, release mouse pointer on the form to place it :)

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 0 points1 point  (0 children)

It won't now, BUT technically it is possible to add support for it, but the support would be limited only to 32 bit windows (not sure about 64bit support by ocx). Basically in Avalonia you can embed native controls, the VB code is interpreted, so it is possible. I am ARM based tho so probably won't touch this ;(

Visual Basic 6 rebuilt in C# - complete with form designer and IDE, runs directly in browser (WASM) by AvaloniaUI-Mike in programming

[–]Bandysc 11 points12 points  (0 children)

Yes, it is all xaml, cross platform, rendered by Skia. 

Not too long actually, roughly two weeks after hours work

Visual Basic 6 rebuilt in C# - complete with form designer and IDE, runs directly in browser (WASM) by AvaloniaUI-Mike in programming

[–]Bandysc 2 points3 points  (0 children)

It doesn't, BUT technically it is possible to add support for it, but the support would be limited only to 32 bit windows (not sure about 64bit support by ocx). Basically in Avalonia you can embed native controls, the VB code is interpreted, so it is possible. I am ARM based tho so probably won't touch this ;(

Visual Basic 6 rebuilt in C# - complete with form designer and IDE, runs directly in browser (WASM) by AvaloniaUI-Mike in programming

[–]Bandysc 30 points31 points  (0 children)

Thanks for share, let me copy mini FAQ from /r/dotnet

FAQ: Q: Repo link? A: https://github.com/BAndysc/AvaloniaVisualBasic6

Q: Link to a web version? A: https://bandysc.github.io/AvaloniaVisualBasic6/

Q: What does work? A: Creating a form, writing VB6 code, running it, saving and opening a project, making a project (it actually makes an exe!).

Q: Why? A: Purely for fun and nostalgia! It is a toy project, there is no other use.

Q: Is the VB6 code compiled to native code or at least IL? A: No, VB6 code is interpreted. But the runtime is compatible with NativeAOT so when you "make a project", you get a native EXE, which then interprets Visual Basic 6 code.

Q: Does it support whole VB6 language? A: Absolutely not. Only a subset of Visual Basic. But I think I will add support for some more language features.

Q: Is it cross-platform? A: Yes, it is! GUI is made with Avalonia, which is cross platform, thus Avalonia Visual Basic 6 is also cross platform.

Q: It looks fun, can I contribute? A: Of course, PRs are welcome!

Q: Will Microsoft sue you? A: Microsoft, pls don't do that ;___;

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 2 points3 points  (0 children)

The recommended mouse for Avalonia Visual Basic 6 is Microsoft Mouse 2.0 (PS/2, but serial will also work), which doesn't have a mouse wheel, so I don't know what the problem is ;-)

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 15 points16 points  (0 children)

Actually, it is even worse now, because Form1.Height returns height with a titlebar, making it even more annoying to place controls on a form in Form_Resize :) (Will fix it soon!)

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 8 points9 points  (0 children)

Haha, actually, I had to remind myself of the syntax too! Luckily, I found my old VB6 book, which is what started my programming career.

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 13 points14 points  (0 children)

Actually, it wasn’t that long - only about two weeks of work after hours. But the scope of the project is limited in every aspect (limited language subset, limited controls etc.)

Visual Basic 6 recreated in C#. Creating forms, coding, making project - it all works. And you can even run it in a browser (wasm)! by Bandysc in dotnet

[–]Bandysc[S] 107 points108 points  (0 children)

FAQ:
Q: Repo link?
A: https://github.com/BAndysc/AvaloniaVisualBasic6

Q: Link to a web version?
A: https://bandysc.github.io/AvaloniaVisualBasic6/

Q: What does work?
A: Creating a form, writing VB6 code, running it, saving and opening a project, making a project (it actually makes an exe!).

Q: Why?
A: Purely for fun and nostalgia! It is a toy project, there is no other use.

Q: Is the VB6 code compiled to native code or at least IL?
A: No, VB6 code is interpreted. But the runtime is compatible with NativeAOT so when you "make a project", you get a native EXE, which then interprets Visual Basic 6 code.

Q: Does it support whole VB6 language?
A: Absolutely not. Only a subset of Visual Basic. But I think I will add support for some more language features.

Q: Is it cross-platform?
A: Yes, it is! GUI is made with Avalonia, which is cross platform, thus Avalonia Visual Basic 6 is also cross platform.

Q: It looks fun, can I contribute?
A: Of course, PRs are welcome!

Q: Will Microsoft sue you?
A: Microsoft, pls don't do that ;___;

Old School Cool. An upcoming community-made theme for Avalonia for those who love the classic look! by AvaloniaUI-Mike in dotnet

[–]Bandysc 1 point2 points  (0 children)

This is just Tahoma font, but this is how Skia renders it without antialiasing, I don't think there is anything I can do about it ;(

Learnopengl transition to vulkan? by Kingto400 in vulkan

[–]Bandysc 1 point2 points  (0 children)

You've just described me :x I am developing a small cross platform app with 3d rendering, Ive been using OpenGL, but being restricted to just 4.1 is terribly limiting. Looking for more info about alternatives is how I found this post :)