Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Terribly Helpful #35269

Open
markolbert opened this issue May 5, 2023 · 3 comments
Open

Not Terribly Helpful #35269

markolbert opened this issue May 5, 2023 · 3 comments
Assignees
Labels
discussion Indicates issues that are being discussed dotnet-csharp/svc 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@markolbert
Copy link

markolbert commented May 5, 2023

How about some explanation of using the interactive window with custom methods? When I try to do that, all I get is an unending sequence of error messages saying "The name 'MethodName' does not exist in the current context". Which is amazingly funny, since I right-clicked Execute in Interactive from >>inside<< the source code for the method.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 400539

@BillWagner
Copy link
Member

Hi @markolbert

Can you paste the code you used? It should have worked, and I'm not sure how best to explain what happened.

@BillWagner BillWagner added the needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] label May 8, 2023
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label May 8, 2023
@markolbert
Copy link
Author

It was a static method in a static class:

   public static Distance GetDistance( Coordinate c1, Coordinate c2 )
    {
        var miles = GetDistance( new PointPair( new Coordinate2( c1.Latitude, c1.Longitude ),
                                                new Coordinate2( c2.Latitude, c2.Longitude ) ) );

        return new Distance( UnitTypes.mi, miles );
    }

    public static double GetDistance( this PointPair pointPair, bool inKilometers = true )
    {
        var deltaLat = ( pointPair.Second.Latitude - pointPair.First.Latitude ) * GeoConstants.RadiansPerDegree;
        var deltaLong = ( pointPair.Second.Longitude - pointPair.First.Longitude ) * GeoConstants.RadiansPerDegree;

        var h1 = Math.Sin( deltaLat / 2 ) * Math.Sin( deltaLat / 2 )
          + Math.Cos( pointPair.First.Latitude * GeoConstants.RadiansPerDegree )
          * Math.Cos( pointPair.Second.Latitude * GeoConstants.RadiansPerDegree )
          * Math.Sin( deltaLong / 2 )
          * Math.Sin( deltaLong / 2 );

        var h2 = 2 * Math.Asin( Math.Min( 1, Math.Sqrt( h1 ) ) );

        return h2 * ( inKilometers ? GeoConstants.EarthRadiusInKilometers : GeoConstants.EarthRadiusInMiles );
    }

As I recall, the interactive window complained about not being able to find System.Math.

But the basic point of my suggestion is to include one or more examples of using methods defined in an assembly (ideally, which require the need for other assemblies to be loaded, like my case).

@github-actions github-actions bot removed the needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] label May 8, 2023
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label May 8, 2023
@BillWagner
Copy link
Member

Thanks @markolbert

That's a limitation of the interactive implementation, and how it's used on the learn.microsoft.com site.

Our goal for the interactive tutorials is to help beginners, or provide very small, focused, samples in API documentation.

That led us to limit the assemblies that are loaded. We want to limit the cost of running the deployment, which means limiting which assemblies are loaded.

We're looking at long-term solutions such as using polyglot notebooks, where it's easier to enable content authors and users to load assemblies.

I'd like your thoughts on those technologies as well.

For this issue, we should have a side-bar article that clearly explains the limitations. These include:

  • Listing the assemblies that are loaded.
  • List the namespaces that are imported.
  • Documenting how the code in the interactive window is inserted into a console application. Details: Effectively, it's inserted into the static void Main method. That explains the issue above: you can't add member methods. Any functions you add are local functions.

@BillWagner BillWagner added doc-enhancement discussion Indicates issues that are being discussed labels May 9, 2023
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label May 9, 2023
@BillWagner BillWagner self-assigned this Feb 28, 2025
@BillWagner BillWagner added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Feb 28, 2025
@dotnetrepoman dotnetrepoman bot added the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Feb 28, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Feb 28, 2025
@dotnetrepoman dotnetrepoman bot added the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Feb 28, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Feb 28, 2025
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Indicates issues that are being discussed dotnet-csharp/svc 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Status: 🔖 Ready
Development

No branches or pull requests

3 participants