open the app and make a spreadsheet. Then export to dll to get a compiled spreadsheet
- The
.dllwill contain one namespacesheetSpacewith one class type calledsheetLibrary - All cells that return a
"value"that is adoublewill result in aprivatedouble _{cellname}and apublicdouble Get_{cellname} - All cells that are constant value doubles and not formulas (for example not including
=25) will result inpublicvoid Put_{cellname} - Additionally,
privatevoid Compute_{cellname}exist for all formula based cells and these are used to recalculate cells on aPutof any dependency
here is a test that may show what exactly this means:
public void CompileTest()
{
Spreadsheet.Spreadsheet sheet = new();
sheet.SetContentsOfCell("a4", "= a3 + 20 * 10");
sheet.SetContentsOfCell("a3", "= a2 + 6 * 30");
sheet.SetContentsOfCell("a2", "= a1 / 2");
sheet.SetContentsOfCell("a1", "4");
sheet.GetCellContents("a3");
//compile to location
var location = sheet.Compile("name");
//load back in and get type data
var nameAssembly = Assembly.LoadFile(location);
var instance = nameAssembly.CreateInstance("sheetSpace.sheetLibrary");
var sheetType = instance?.GetType();
//get methods to test
var getA4 = sheetType?.GetMethod("Get_a4");
var setA1 = sheetType?.GetMethod("Put_a1");
//check constructor puts default values
Assert.AreEqual(sheet.GetCellValue("a4"), getA4?.Invoke(instance, []));
//change value for both
setA1?.Invoke(instance, [5]);
//calls hidden function to update dependent cells
sheet.SetContentsOfCell("a1", "5");
//check values are updated properly
Assert.AreEqual(sheet.GetCellValue("a4"), getA4?.Invoke(instance, []));
}The resulting assembly can be decompiled into this (by JetBrains Rider):
// Decompiled with JetBrains decompiler
// Type: sheetSpace.sheetLibrary
// Assembly: nameAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 859585CC-F549-4A37-81A0-8E30A7547E4B
// Assembly location: /Users/robertmorelli/Documents/personal-repos/assignment-six-gui-functioning-spreadsheet-team/Solution Items/name.dll
// Compiler-generated code is shown
using System.Runtime.InteropServices;
namespace sheetSpace
{
public class sheetLibrary
{
private double _a4;
private double _a3;
private double _a2;
private double _a1;
public double Get_a4()
{
return this._a4;
}
public double Get_a3()
{
return this._a3;
}
public double Get_a2()
{
return this._a2;
}
public double Get_a1()
{
return this._a1;
}
public sheetLibrary()
{
this._a4 = 382.0;
this._a3 = 182.0;
this._a2 = 2.0;
this._a1 = 4.0;
}
private void Compute_a4()
{
this._a4 = 200.0 + this._a3;
}
private void Compute_a3()
{
this._a3 = 180.0 + this._a2;
}
private void Compute_a2()
{
this._a2 = 0.5 * this._a1;
}
public void Put_a1([In] double obj0)
{
this._a1 = obj0;
this.Compute_a2();
this.Compute_a3();
this.Compute_a4();
}
}
}You can run this test with dotnet test SpreadsheetTests --filter "CompileTest" (It will create name.dll on your
desktop). The net9 cli might also be broken so maybe run in through a UI