Open markolbert opened 1 year ago
Hi @markolbert
Can you paste the code you used? It should have worked, and I'm not sure how best to explain what happened.
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).
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:
static void Main
method. That explains the issue above: you can't add member methods. Any functions you add are local functions.
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.