microsoft / MIDI

Windows MIDI Services
MIT License
285 stars 23 forks source link

Preview 5 sample folder projects won't build #308

Closed MusicMaker closed 2 months ago

MusicMaker commented 2 months ago

Issue Sample projects won't build when using Visual Studio 2022.

How to reproduce Install Visual Studio 2022 with SDK's Open nuget package manager Add the path where the nuget package is located Add the reference for MIDI2 to the project

Expected behavior Open the project.sln file in Visual studio Add the nuget package for MIDI 2.0 Preview 5 Build No Errors

**Cause*** Sample projects for git (now preview 5) visual studio project files show: `

`

Solution (Edited)

  1. Add the path to the nuget for preview 5 in nuget package manager (the nuget package is in the project folder or download it separately and place in a folder)
  2. Add the reference for midi2 preview 5 in mage packages for project
  3. Save project and close Visual studio
  4. Delete ALL references to preview 3 from the project file (there are 3 areas to delete) Why manual ? a. Somehow VS "uninstall" button does not work to remove the preview 3 reference in the package manager b. Somehow VS does not delete old references in project files even they are removed
  5. Open VS
  6. Update main.c with code as below by Psychlist1972
  7. Build the project
Psychlist1972 commented 2 months ago

Thanks.

I assume this is the api-watch-endpoints sample you mentioned on Discord. If so, the event handler signatures changed per the release notes (they each take proper args classes as parameters now), but I missed updating this sample for Preview 5.

    auto OnWatcherStopped = [&](MidiEndpointDeviceWatcher const& /*sender*/, foundation::IInspectable const& /*args*/)
        {
            std::cout << std::endl;
            std::cout << "Watcher stopped." << std::endl;
        };

    auto OnWatcherEnumerationCompleted = [&](MidiEndpointDeviceWatcher const& /*sender*/, foundation::IInspectable const& args)
        {
            std::cout << std::endl;
            std::cout << "Initial enumeration completed." << std::endl;
        };

    auto OnWatcherDeviceRemoved = [&](MidiEndpointDeviceWatcher const& /*sender*/, MidiEndpointDeviceInformationRemovedEventArgs const& args)
        {
            std::cout << std::endl;
            std::cout << "Removed: " << winrt::to_string(args.Id()) << std::endl;
        };

    auto OnWatcherDeviceUpdated = [&](MidiEndpointDeviceWatcher const& /*sender*/, MidiEndpointDeviceInformationUpdatedEventArgs const& args)
        {
            std::cout << std::endl;
            std::cout << "Updated: " << winrt::to_string(args.Id()) << std::endl;

            // Show how to use the various data update flags here

            if (args.UpdatedName())                     std::cout << "- Name" << std::endl;
            if (args.UpdatedUserMetadata())             std::cout << "- User Metadata" << std::endl;
            if (args.UpdatedEndpointInformation())      std::cout << "- Endpoint Information" << std::endl;
            if (args.UpdatedStreamConfiguration())      std::cout << "- Stream Configuration" << std::endl;
            if (args.UpdatedFunctionBlocks())           std::cout << "- Function Blocks" << std::endl;
            if (args.UpdatedDeviceIdentity())           std::cout << "- Device Identity" << std::endl;
            if (args.UpdatedAdditionalCapabilities())   std::cout << "- Additional Capabilities" << std::endl;

        };

    auto OnWatcherDeviceAdded = [&](MidiEndpointDeviceWatcher const& /*sender*/, MidiEndpointDeviceInformationAddedEventArgs const& args)
        {
            std::cout << std::endl;
            std::cout << "Added  : " << winrt::to_string(args.AddedDevice().Name()) << std::endl;
            std::cout << "         " << winrt::to_string(args.AddedDevice().Id()) << std::endl ;
        };
Psychlist1972 commented 2 months ago

Did you mean to have something in this part of the report?

image

Psychlist1972 commented 2 months ago

Thanks for catching this one. Will be fixed in next PR to main.

MusicMaker commented 2 months ago

image Github hid the content. Fixed now.

Psychlist1972 commented 2 months ago

Completed. Samples are updated in main. Everything will be synchronized with the next dev preview.