dotnet / vblang

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

Future of VB samples in Code Gallery #470

Open KathleenDollard opened 5 years ago

KathleenDollard commented 5 years ago

The Code Gallery is being replaced by the Samples Browser as discussed in Migrating Code Gallery examples to the Samples Browser.

If you'd like to contribute, that would be awesome and there are directions in that link. @rpetrusha can answer questions. For MVP status, this counts as OSS contributions (and I'd love more VB MVPs).

Also, here or on gitter, the things that are framework only, or are different on framework may need a home. I haven't explored copyright and similar, but if the community has a proposal for an alternate plan for framework samples, I'll work to connect with the right people. I do think review and restructuring is an excellent idea, and better coordination between samples (like the TechNet samples/tutorials) would be quite good.

paul1956 commented 5 years ago

A default empty VB WinForm 4.X app created by Visual Studio has 19 issues with the Platform Analyzer. I don't think you want to send a lot of developers down that rabbit hole yet. Maybe an example on getting that to work is a place to start. I also only see 1 sample of VB code that needs to be moved https://github.com/aspnet/EntityFramework.Docs/issues/1382 and I know nothing about EnityFramework. The link to finding stuff to migrate takes you back to #13921.

Some of the stuff below is easy to workaround, the stuff related toWindowsFormsApplicationBase and lack of My.Forms makes it hard to port WinForm stuff at this time, without some ugly workarounds.The list for a very small real VB application quickly gets into the 100's of issues. with a lot of false errors from the VB CoreFx work things like MsgBoxStyle which is there but reported as missing.

T:Microsoft.VisualBasic.Devices.Computer | T:Microsoft.VisualBasic.Devices.Computer
-- | --
T:Microsoft.VisualBasic.Devices.Computer | M:Microsoft.VisualBasic.Devices.Computer.#ctor
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.#ctor(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode)
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.add_Shutdown(Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler)
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.get_SaveMySettingsOnExit
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.get_UseCompatibleTextRendering
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(System.String[])
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_EnableVisualStyles(System.Boolean)
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_IsSingleInstance(System.Boolean)
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_MainForm(System.Windows.Forms.Form)
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_SaveMySettingsOnExit(System.Boolean)
T:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | M:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.set_ShutdownStyle(Microsoft.VisualBasic.ApplicationServices.ShutdownMode)
T:Microsoft.VisualBasic.ApplicationServices.ShutdownMode | T:Microsoft.VisualBasic.ApplicationServices.ShutdownMode
T:Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler | T:Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler
T:Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler | M:Microsoft.VisualBasic.ApplicationServices.ShutdownEventHandler.#ctor(System.Object,System.IntPtr)
T:Microsoft.VisualBasic.ApplicationServices.User | T:Microsoft.VisualBasic.ApplicationServices.User
T:Microsoft.VisualBasic.ApplicationServices.AuthenticationMode | T:Microsoft.VisualBasic.ApplicationServices.AuthenticationMode
T:Microsoft.VisualBasic.CompilerServices.Utils | M:Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString(System.String,System.String[])
rpetrusha commented 5 years ago

I think that the experience will vary depending on the application, @paul1956. I migrated a fairly simple Windows Forms app for which Portability Analyzer identified no issues and which required only slight modification. The major issue was that My.Resources did not work well, but I simply replaced it with calls to ResourceManager methods and eliminated all dependencies on the My namespaces.

paul1956 commented 5 years ago

@rpetrusha No VB WinForm app should pass Portability Analyzer, a VB WinForms Core 3.0 App will not even start without added a Main, you can't access a Form without creating an explicate reference to it, can't gracefully shutdown, (no End) and save Settings. The list above is correct for even the most trivial application. Yes you can work around most/all the issues but then will need to undo the workarounds when VB gets updated. Every app needs below which is normally hidden from VB developers.

   <STAThread>
    Public Shared Sub Main()
        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)
        Dim f As New Form1()
        Application.Run(f)
        f.Dispose()
    End Sub

Putting some of this plus replacement for My.Resources and dealing with Disposing Forms. is what is generally needed first to get things ported to Core. I would like to try contributing just need a place to start.

rrvenki commented 5 years ago

Hi @KathleenDollard @rpetrusha i'm unable to locate the "Code Gallery" code. Please provide link so we can take the C# projects and write it into a VB project. I appreciate this effort and the one big reason for today's developers stating "No VB samples indicates Microsoft leaving VB behind" should turn into a myth. I urge all contributors to not only use language converters but work on the VB way of doing things.

rpetrusha commented 5 years ago

@rrvenki, Code Gallery samples are at https://code.msdn.microsoft.com. There is a list of Code Gallery projects that can be ported in the Code Gallery migration project.

rrvenki commented 5 years ago

Hi @rpetrusha, My apology for following up again. I was trying to do a New Pull Request to start working on "Universal Windows App Samples" to VB. But the pull request always takes me to Compare files and I'm unable to mark that I'm working on it. Or as a first time user to work on GitHub code repository, the steps are not clear. Can I request you to point to steps on how to start converting C# code into VB targeting .NET Core?

paul1956 commented 5 years ago

@KathleenDollard I have searched around and found lots of references to MVP, events, categories... but little that actually explains what it takes to become one and on https://mvp.microsoft.com/en-us/Pages/mvp-award-update, I don't see VB, C# or Roslyn, I do see other languages listed C++, Python... Your initial message makes it sound like there is a "count" as in "this counts as OSS contributions", for those new to MVP can you provide a link that explains becoming one?

paul1956 commented 5 years ago

This is all from my experience please feel free to correct or move elsewhere if this is not the place for it.

@rrvenki, from what I have been able to figure out, you start by

  1. Sign into GitHub.com
  2. From GitHub.com you "Fork" the repository you want to work on by clicking the button on the top of the page for example https://github.com/dotnet/samples/, this creates a copy of "Master" under your GitHub account.
  3. Assuming you want to do this is Visual Studio, open Visual Studio 2019 Preview 16.3.0 Preview 2.0 or later For Preview 2.0 select "Continue without Code"
  4. For preview 2.0 ONLY, Under Tools/Options/Package Sources, add a new source by clicking +, https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json with the name dotnet-core. This is necessary to work around MyType issues. Close VS.
  5. Open VS and Select Clone or Check Out Code.
  6. In Repository Location, enter the URL of your Fork which you can get by clicking the "Clone or Download" button on your GitHub site, Visual Studio will create a copy of your fork locally.
  7. Once its done, Select Team Explorer tab, and click on Home Button and then on Branch.
  8. Name your new branch for example "Remove ByVal" and then click Sync, then Push, this will create the copy you will eventually do a pull request on.

This is the part that gets a little fuzzy for me.

  1. In my case I was updating documentation and removing ByVal. For updating documentation you just edit the files directly in VS, for changing a VB project you may have to close the solution, open the project .vbproj file., Then edit what you need, if you openned a project file, close VS, delete the .SLN file that got created, if one already existed leave it. reopen the top level folder (samples or Docs..) and then "commit" the change from Team Explorer/changes. Only files you changed should be listed in the commit (I made errors here and still need to learn how to fix).

In your case you will need to Create a new directory (if this is the Samples Repo, you would create a new "VisualBasic" directory, because I don't see one or if what you are porting is under something else like WindowsForms and there is already a .SLN file there you would create a new directory with the same name and as the one you are porting with some additions to indicate its VB, I use _vb. then port the application into that directory adding it to the existing solutions file. There are several tools to Port C# to VB most free ones limit the amount of code to converted to 100 lines or less and I have not seen one that created a Core 3.0 project file for you, the free one on my GitHub page will port the entire solution but create a simple project files. Depending on the converter you might have to clean things up but just opening the project in VS should highlight most of the issues quickly. If there are tests you need to port them as well. I just did WindowsForms/Graphics as a test and it took just a few minutes and I only had to fix 2 lines in one file. You also need to make sure the VB project file has a different name (for example XYZ_vb.vbproj for XYZ.csproj) then the C# project file if you want both of them in your solution.

10 Go back to your GitHub page, and the repository you want to do the PR from and change the Branch from Master to whatever you named your new branch.

  1. Fill out the form and submit. 12 Respond to PR feedback.
rskar-git commented 5 years ago

@paul1956 Thumbs up from me in thanks for sharing your experiences/steps towards being a contributor, very helpful!

rrvenki commented 5 years ago

This is all from my experience please feel free to correct or move elsewhere if this is not the place for it. @rrvenki, from what I have been able to figure out, you start by

Sign into GitHub.com From GitHub.com you "Fork" the repository you want to work on by clicking the button on the top of the page for example https://github.com/dotnet/samples/, this creates a copy of "Master" under your GitHub account. Assuming you want to do this is Visual Studio, open Visual Studio 2019 Preview 16.3.0 Preview 2.0 or later For Preview 2.0 select "Continue without Code" For preview 2.0 ONLY, Under Tools/Options/Package Sources, add a new source by clicking +, https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json with the name dotnet-core. This is necessary to work around MyType issues. Close VS. Open VS and Select Clone or Check Out Code. In Repository Location, enter the URL of your Fork which you can get by clicking the "Clone or Download" button on your GitHub site, Visual Studio will create a copy of your fork locally. Once its done, Select Team Explorer tab, and click on Home Button and then on Branch. Name your new branch for example "Remove ByVal" and then click Sync, then Push, this will create the copy you will eventually do a pull request on.

This is the part that gets a little fuzzy for me.

  1. In my case I was updating documentation and removing ByVal. For updating documentation you just edit the files directly in VS, for changing a VB project you may have to close the solution, open the project .vbproj file., Then edit what you need, if you openned a project file, close VS, delete the .SLN file that got created, if one already existed leave it. reopen the top level folder (samples or Docs..) and then "commit" the change from Team Explorer/changes. Only files you changed should be listed in the commit (I made errors here and still need to learn how to fix). In your case you will need to Create a new directory (if this is the Samples Repo, you would create a new "VisualBasic" directory, because I don't see one or if what you are porting is under something else like WindowsForms and there is already a .SLN file there you would create a new directory with the same name and as the one you are porting with some additions to indicate its VB, I use _vb. then port the application into that directory adding it to the existing solutions file. There are several tools to Port C# to VB most free ones limit the amount of code to converted to 100 lines or less and I have not seen one that created a Core 3.0 project file for you, the free one on my GitHub page will port the entire solution but create a simple project files. Depending on the converter you might have to clean things up but just opening the project in VS should highlight most of the issues quickly. If there are tests you need to port them as well. I just did WindowsForms/Graphics as a test and it took just a few minutes and I only had to fix 2 lines in one file. You also need to make sure the VB project file has a different name (for example XYZ_vb.vbproj for XYZ.csproj) then the C# project file if you want both of them in your solution. 10 Go back to your GitHub page, and the repository you want to do the PR from and change the Branch from Master to whatever you named your new branch.
  2. Fill out the form and submit. 12 Respond to PR feedback.

@paul1956, I started with the steps you've mentioned. Once I get through with the process of creating VB.NET Core UWP/WPF/Winform apps from C# i'll keep you posted in a day. Thanks so much for giving the heads up. Appreciate and Thanks for the help.

paul1956 commented 5 years ago

@rrvenki I have been updating the converter and for the last 2 projects no manual changes were required to get the new project to execute. There is still some cleanup that VS 2019 recommends and can do automatically and I am doing them. These is still a disposal issue that I am not addressing at this time.

What I just realized is there is no way to coordinate who is porting what Sample. I have completed WindowsForms/matching-game and WindowsForms/Graphics and done a PR and am working through removing ByVal and doing other cleanup for VS 2019. I have found projects from VS 8 and VS 10 that need to be upgraded is this something you want me/us to do?

rrvenki commented 5 years ago

@paul1956 Thanks for the offer. I would be glad to work together. Earlier @rpetrusha and @KathleenDollard advised to pull code samples from https://code.msdn.microsoft.com/, convert/upgrade/migrate into https://docs.microsoft.com/en-us/samples/browse/ - Code sample browser.

I've converted many of the samples into VB for my own requirements earlier and bringing those into new samples browser would be easier. But i'm not aware of the process involved in the whole thing for which I needed help.

Besides the samples, I've also created VB programs using C# templates like "SQL CLR" which would be DLL addons into SQL server which are mostly not thought about in VB. If you know "Intelligent Kiosk" C# program which uses Azure cognitive services is converted in VB and it works fine. I can bring that to the samples browser too.

Getting accustomed to the process of "New Pull Request", Create destination repository, "PR" request etc. are the ones required now as I could not find documentation on that. Your heads-up has taken me half way now and once I'm up to speed we can do maximum as possible.

paul1956 commented 5 years ago

@rrenki you can IM me on Gitter rather then use GitHub for discussion.

rrvenki commented 5 years ago

@KathleenDollard, @rpetrusha The existing C# samples in WPF and WinForms are being translated into VB using converting tools by few of us. These tools help in bulk translation and hence it appears there is no point in working on single project at a time by the rest of us. So can we work on a structure of the projects and templates, group/categorize them so that other than Winforms and WPF there is whole lot of other things where we can add VB samples (may not be already available in C# too) which may include VS addons, SQLCLR, IoT, Working with OS information while running in Non Windows environment, etc. This gives a bit more free hand and enough time to build samples and test them while you are sure no other person does the same thing with a tool. Please note i'm working in a day job and I may not be able to dedicate my full day on it but have a need for VB templates and projects in real life scenarios used in Enterprise environments where I can contribute.

rrvenki commented 5 years ago

Hi @rpetrusha @KathleenDollard , I'm process of migrating few samples. As a first simple one I migrated "UsingSpeech". One using Cognitive Services (.NET Core) and other Full .NET using Speech SDK. I'm checking in https://github.com/dotnet/docs/projects/88 to find how to raise a PR to publish the new (Added/Updated) code back to GitHub repository. I could not find. Please help.

KathleenDollard commented 5 years ago

Adding @mairaw

rrvenki commented 4 years ago

@KathleenDollard @mairaw please help with steps to contribute VB code samples specifically for people like me who do not use github in day today day job.

rskar-git commented 4 years ago

@KathleenDollard @rpetrusha

I started on #13649 (https://github.com/dotnet/docs/issues/13649, Migrate Samples for Parallel Programming) for VB, but that's kind of road-blocked since most of the original samples for VB are GUI apps making use of WPF or Windows Forms. Is there a commitment and time-table/roadmap for .NET Core WPF and/or WinForms in VB?

With .NET Core 3.1, I've managed to get AcmePizza to work! So WPF on Core with VB can be done! :smile:

Also, now that the old MSDN Code Gallery was officially retired (https://docs.microsoft.com/en-us/teamblog/msdn-code-gallery-retired), is there an alternative place to get these original projects? I've made use of https://web.archive.org as a work-around so far, but was hoping that maybe there is a "safer" URL to use instead.

My apologies, I should have read https://docs.microsoft.com/en-us/teamblog/msdn-code-gallery-retired more carefully! (thx! @zspitz) I'll be looking at https://github.com/microsoftarchive from now on.

Thanks!

P.S. Here is one of the VB GUI apps I've migrated to .NET Core: AcmePizza!

TODO, convert these WinForms apps to WPF: GameOfLife, ImageColorizer, NQueens, Raytracer, ShakespeareanMonkeys, Sudoku, VisualizePartitioning

TODO, WPF apps: AcmePizza, BabyNames, DiningPhilosophers, SpellChecker

TODO, console apps: AsyncDownload, ComputePi, EditDistance, ParallelGrep.

paul1956 commented 4 years ago

I would love to port The Game of Life or Sudoku where do I get the source? With Version 16.5.0 Preview 1.0 and TryConvert it is worth trying.

zspitz commented 4 years ago

@paul1956 From the page describing the retirement of the gallery:

We have archived the most actively engaged code samples to public archive repositories on GitHub which can be accessed via the links below.

[Conway's] Game of Life seems to be here, while Sudoku seems to be here.

paul1956 commented 4 years ago

The archive for Game of Life is broken both the ZIP and Open in VS are both broken. Reported elsewhere. Repo is visible https://github.com/microsoftarchive/msdn-code-gallery-community-a-c The git below can't be opened or downloaded. https://github.com/microsoftarchive/msdn-code-gallery-community-a-c.git image

zspitz commented 4 years ago

@paul1956 Perhaps edit the link into your previous comment?

paul1956 commented 4 years ago

The VB samples in the archive that I have reviewed do not follow the coding style from dotnet/runtime and the .editorconfig file only has a C# rules. I put in a local one that I have used to port Sudoku and Life but I deleted it before I did Sudoku PR also the rules for ReadMe.MD has changed significantly so having a complete sample in the Repo would help avoid a lot of churn.

paul1956 commented 4 years ago

@zspitz done comment updated.