dotnet / vblang

The home for design of the Visual Basic .NET programming language and runtime library.
288 stars 66 forks source link

Update on My in .NET Core 3.0 #471

Open KathleenDollard opened 5 years ago

KathleenDollard commented 5 years ago

So, we were overly optimistic/made a mistake regarding one aspect of the port of the Visual Basic Runtime (microsoft.visualbasic.dll) to .NET Core. This is "fixed" in Preview 9.

As some of you may know the roots of WinForms run deep in Visual Basic. It's used by a variety of things that you might not think use it. WinForms dependent parts of the Visual Basic Runtime will be in the WinForms library - and the link to your app is expected to be invisible if you are using WinForms. The WinForms part of the Visual Basic Runtime is not in .NET Core 3.0 but will be in the next version of Visual Basic.

For types that have a WinForms dependency, but WinForms is irrelevant to other parts of the class, in earlier previews we ported the non-WinForms part, with the expectation of using Reflection to access the WinForms part. This was a mistake. The experience is terrible when the Reflection fails. As such, we were forced to back out this portion of the port in Preview 9. ApplicationBase, the My subsystem, and other things are no longer there. You can see this in the PR which is now in the Master/daily builds.

We messed up and we had to fix it. I'm sorry for the inconvenience if you are using the previews, and I'd love to hear how things went overall. I hate that we had to pull this out, but while we can move things from WinForms back to CoreFx, we cannot do the reverse and had to take this change.

One module remains a problem. There was no good choice here. Interactions has both IIf and 'ErrObject' and 'MsgBox'. For this module, we are leaving it in CoreFx. IIf was the compelling case here, because API Port Telemetry shows quite high use.

Bill-McC commented 5 years ago

Is IIf and side effects better than If ? I would have thought IIf is legacy that looks like a ternary but is a function. An error on porting would be a good thing ;)

Cheers, Bill.


From: Kathleen Dollard notifications@github.com Sent: Tuesday, August 20, 2019 7:47:57 AM To: dotnet/vblang vblang@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [dotnet/vblang] Update on My in .NET Core 3.0 (#471)

So, we were overly optimistic/made a mistake regarding one aspect of the port of the Visual Basic Runtime (microsoft.visualbasic.dll) to .NET Core. This is "fixed" in Preview 9.

As some of you may know the roots of WinForms run deep in Visual Basic. It's used by a variety of things that you might not think use it. WinForms dependent parts of the Visual Basic Runtime will be in the WinForms library - and the link to your app is expected to be invisible if you are using WinForms. The WinForms part of the Visual Basic Runtime is not in .NET Core 3.0 but will be in the next version of Visual Basic.

For types that have a WinForms dependency, but WinForms is irrelevant to other parts of the class, in earlier previews we ported the non-WinForms part, with the expectation of using Reflection to access the WinForms part. This was a mistake. The experience is terrible when the Reflection fails. As such, we were forced to back out this portion of the port in Preview 9. ApplicationBase, the My subsystem, and other things are no longer there. You can see this in the PRhttps://github.com/dotnet/corefx/pull/39972 which is now in the Master/daily buildshttps://github.com/dotnet/core-sdk.

We messed up and we had to fix it. I'm sorry for the inconvenience if you are using the previews, and I'd love to hear how things went overall. I hate that we had to pull this out, but while we can move things from WinForms back to CoreFx, we cannot do the reverse and had to take this change.

One module remains a problem. There was no good choice here. Interactions has both IIf and 'ErrObject' and 'MsgBox'. For this module, we are leaving it in CoreFx. IIf was the compelling case here, because API Port Telemetryhttps://apisof.net/catalog/Microsoft.VisualBasic.Interaction.IIf(Boolean,Object,Object) shows quite high use.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/vblang/issues/471?email_source=notifications&email_token=ACAP7BC2DNFXEBLJGGKGKZ3QFMII3A5CNFSM4ING7NL2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGDBJGQ, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACAP7BHFESCQBJ2JAUDJWCTQFMII3ANCNFSM4ING7NLQ.

jrmoreno1 commented 5 years ago

IIF was an understandable, if unfortunate, bit of legacy support in 2001. In 2019, it’s useless junk that should be dropped. While it may have a high usage rate (i.e. used in a lot of applications), I doubt if it has an extensive usage rate (used a lot inside individual applications) and it is easily fixed one way or another. If I was contemplating switching an app to Core, I would consider having to drop IIF a bonus.

paul1956 commented 5 years ago

I would have though MsgBox usage would be extremely high and depending on WinForms for it is not a great idea it would be better if it were portable or if a subset of functionality was portable (somehow get a message to the user and get it acknowledged), Most .NET Standard libraries I deal with use MsgBox and a version that does not depend on WinForms is possible (though the behavior may not be 100% identical without VBHost). I agree with everyone that dropping IFF is a very good thing. The port to core requires work (a lot today) replacing IFF is trivial.

KathleenDollard commented 5 years ago

You can always search for IIf yourself to remove it. You could also write an analyzer and I'd love to see an analyzer from the community that was a "best-practice" VB.

But for the port - this is a direct port. We aren't reworking anything since compatibility is a major goal.

The links between WinForms and the rest of Visual Basic has been frustrating over the last few weeks. The current location in CoreFx allows it to be in Standard libraries, although putting an implementation in CoreFx would be problematic.

Once we get things working, we can explore whether there's a route to have a MsgBox version in an additional DLL that is not WinForms specific.

paul1956 commented 5 years ago

Where would you host a "best-practice" VB Analyzer, I already have a free public NuGet MsgBox but think a Remove ByRef VSIX would also be useful and then there need to be an easy way for VB developers to these Best practices analyzers.

paul1956 commented 5 years ago

@KathleenDollard I have been trying to port several application to Core 3.0 lately and I keep running into the same issues reported by Portability Analyzer. All of these come from the Form or Resource Template so every WinForm application is affected by them. When you publish VB support for Core document this month can you make sure these are specifically addressed so everyone does not have to reinvent the wheel and if it is going to be a long time before there is a solution maybe an article that addresses workarounds like there is for C#.

T:Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler
M:Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler.#ctor(System.Object,System.IntPtr)
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.#ctor(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode)
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.add_Shutdown(Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler)
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.get_SaveMySettingsOnExit
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.get_UseCompatibleTextRendering
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(System.String[])
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_EnableVisualStyles(System.Boolean)
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_IsSingleInstance(System.Boolean)
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_MainForm(System.Windows.Forms.Form)
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_SaveMySettingsOnExit(System.Boolean)
M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_ShutdownStyle(Microsoft.VisualBasic.ApplicationServices.ShutdownMode)
T:Microsoft.VisualBasic.ApplicationServices.AuthenticationMode
T:Microsoft.VisualBasic.ApplicationServices.ShutdownMode
M:Microsoft.VisualBasic.Interaction.MsgBox(System.Object,Microsoft.VisualBasic.MsgBoxStyle,System.Object)