The FsExcel repo has a few unusual features, so please give this a read before diving in to make changes.
Please aim to leave anyone you interact with happier than they were before you interacted with them.
You may find it easiest to work with this codebase using VS Code. The instructions below assume this.
The tutorial notebook Tutorial.dib has three important roles:
-
It gives users a downloadable resource which they can run to explore all FsExcel features.
-
It is used to generate the
README.mdfile which allows users to view these features inGitHub, together with expected results. -
It is used to generate a suite of regression tests.
To make all this work requires a little setup.
-
You will need to enable run-on-folder-open. To do this:
-
Open the command palette (SHIFT+CTRL+P) and choose "Tasks: Manage Automatic Tasks in Folder"
-
Choose "Allow Automatic Tasks in Folder". Note that this setting is not in the usual VS Code settings JSON files.
-
Close and re-open the workspace.
-
At this point you should see three items named "Start watching..." in your terminal list. This is the three dotnet 'watches' which automatically update the
README.mdand the regression tests, based onTutorial.dib.
-
-
To double check that all is working, make a trivial change to
Tutorial.diband save. After a moment you should see two changes appear in the source control panel, one inTutorial.diband one inREADME.md. Reverse and save your trivial change and both these file changes should disappear.
Don't edit README.md directly. Always change it by editing Tutorial.dib and saving.
It's not necessary for most development work, but to explore further how this aspect of the repo works, look at tasks.json in the repo root, and at the .fsx scripts which it calls.
As detailed above, the regression tests are generated based on the spreadsheets generated in Tutorial.dib. The process overall is:
-
You add or change some feature in FsExcel.
-
You make appropriate changes in
Tutorial.dibto demonstrate the feature. -
When you save
Tutorial.dib, a dotnet watch usesDibToActualsScript.fsxto generate a new script calledCreateRegressionTestActuals.fsx. The content ofCreateRegressionTestActuals.fsxis essentially the source from each of the F# cells in the tutorial. -
Another dotnet watch runs this newly-generated script to generate spreadsheets in
src/Tests/RegressionTests/Actual. -
When you run the tests using
dotnet test, the regression test compares every spreadsheet insrc/Tests/RegressionTests/Expectedwith those insrc/Tests/RegressionTests/Actualand reports an error where these differ.
Note that the regression tests don't yet compare every cell attribute that can be set using FsExcel. This is outstanding work.
With this in mind you'll need to take the following steps when making changes:
- If you are adding a feature, you'll need to demonstrate it in one or more F# cells (with appropriate markdown commentary) in
Tutorial.dib. The last line of markdown before the new F# cell should look like this:
<!-- Test -->This will not be visible in the rendered markdown, but tells the regression test generator script to include the code from the following F# cell in the test actuals generator.
-
If you are amending a feature and the change affects expected output, you'll need to amend existing F# cells and commentary in
Tutorial.dib. -
In order to run against the locally-built version of FsExcel you'll need to temporarily add the following lines to the beginning of each affected notebook cell:
#r "nuget: ClosedXML"
#r "../FsExcel/bin/Debug/netstandard2.1/FsExcel.dll"
let savePath = "/temp"-
You'll need to reset the notebook kernel each time you want to
dotnet buildthe local version (CTRL+SHIFT+P ->.NET Interactive: restart the current notebook's kernel). This is because running the cell locks the object code. -
Once your change is successfully generating a spreadsheet, take a carefully cropped screenshot and include it as an example after the code cell. (See existing markdown for many examples.) Your screenshot won't show in the markdown until you have pushed your changes, as the links are into GitHub.
-
When you are happy with the change, you'll need to copy any new or changed output spreadsheets from the
savePathwhere the notebook would have written them, intosrc/Tests/RegressionTests/Expected. -
Now run the tests with
dotnet test.
With the feature working and regression tests passing...
-
Remove the three lines you added to
Tutorial.dibcells to run the local copy. -
Verify in your git changes that the edits you made in
Tutorial.dibare reflected inREADME.md. -
Also in your git changes, check that any new/edited spreadsheets in
src/Tests/RegressionTests/Actual, and any screenshots, are reflected. -
If appropriate, upversion in
FsExcel.fsprojto ensure a new Nuget package is built. -
Push your changes!
-
Once the package has been published on
nuget.org, run the entire notebook again to ensure the changes work correctly from the published version.