Skip to main content

Using the .NET SDK

You can now open the folder in VS Code and should be greeted with something that looks like this:

Library created successfully

Now we can create our very first calculation.

Basic calc

We can build the library using the command dotnet build. The created binaries will end up the in the directory <myprojectname>\bin\<releaseConfiguration>\<targetedVersion>, which will likely look like <myprojectname>\bin\Debug\netstandard2.0

tip

All dotnet commands should be executed from the same folder as the relevant .csproj file

This is as simple as a calculation can get! But by itself it's not enough to work, we'll need to add specific ArupCompute attributes. We'll see that in the next section.

IMPORTANT

Note that the both the class and function are now marked as public and static, unless you know what you are doing this is how you should set up your classes and function in order to work well with AC.

Next we need to add the using Arup.Compute.DotNetSdk.Attributes; and using Arup.Compute.DotNetSdk.Enums; directives to your files and start decorating your function with the ArupCompute attributes that are required to pass information to ArupCompute to use in the various user interfaces.

IMPORTANT

The only mandatory attribute is:

[Calculation("Calc Title", "Calc Description", "AuthorEmail", LevelOfReview)]

It can be added on the class or also on each method. If on both, the one on the method will be used. If not present the function or class will be ignored.

Our BasicCalc now looks like this:

    [Calculation("Basic Calc", "Example of how to write a simple calculation that sums numbers a and b.",
"[email protected]", Arup.Compute.DotNetSdk.Enums.LevelOfReview.Complete)]
[Output("sum","The sum of a and b","mm","sum")]
public static double BasicCalc([Input("a","First number","mm","a")]double a, [Input("b", "Second number", "mm", "b")]double b)
{
return a + b;
}

The input and output attributes are optional, but help to describe your calculation. There are more attributes the SDK offers, you can find them all by exploring Arup.Compute.DotNetSdk.Attributes:

image

The calculation above is now complete and will automatically display in ArupCompute as follows:

image