fsprojects-archive / zzarchive-VisualFSharpPowerTools

[ARCHIVED] Power commands for F# in Visual Studio
http://fsprojects.github.io/VisualFSharpPowerTools/
Apache License 2.0
310 stars 77 forks source link

Functional wrappers to make VS SDK code easier to cope with #1426

Closed smoothdeveloper closed 8 years ago

smoothdeveloper commented 8 years ago

I'm looking at few usage of SnapshotSpan / SnapshotPoint and it seems:

  1. we don't use properly the VS API
  2. we could make few F# helpers to keep API more F# idiomatic

    proper usage of VS API

in our existing code:

SnapshotSpan(x.Start, (SnapshotPoint (x.Snapshot,x.End.Position + num)))

If I'm right this is identical to:

SnapshotSpan(x.Start, x.End + num)

I think we should use the shorter instead, it also probably amounts to less allocations and require less tracking of state (passing correct ITextSnapshot, etc.)

F# Helpers

VS.Snapshot.mkSpan x.Start (x.End + num)

Would few of those helpers keep our code more friendly to potential contributors who don't have much knowledge of VS API?

This also makes a first step toward a higher level DSL to deal with those while having 0 overhead with usage of small inline functions.

cloudRoutine commented 8 years ago

This is a good time to tackle this since we're reworking a large amount of the codebase and these changes can happen with the migrations.

smoothdeveloper commented 8 years ago

1438 implements this