Skip to content

Commit d903f70

Browse files
committed
More stuff.
* Multiple target frameworks. * Fix a couple of memory issues. * Documentation.
1 parent 4c5e85a commit d903f70

File tree

17 files changed

+517
-146
lines changed

17 files changed

+517
-146
lines changed

.github/workflows/nuget.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: nuget
22

33
on:
4-
push:
5-
branches:
6-
- feature/dotnet-bindings
4+
pull_request:
5+
paths:
6+
- 'binding/dotnet/**'
7+
- '.github/workflows/nuget.yml'
78
workflow_dispatch:
89
inputs:
910
release:
@@ -72,9 +73,12 @@ jobs:
7273
path: bindings/dotnet/ironcalc-dotnet/IronCalc/runtimes/
7374
merge-multiple: true
7475

75-
- uses: actions/setup-dotnet@v3
76+
- uses: actions/setup-dotnet@v5
7677
with:
77-
dotnet-version: '9.0.x'
78+
dotnet-version: |
79+
8.0.x
80+
9.0.x
81+
10.0.x
7882
7983
- name: dotnet test
8084
run: dotnet test ironcalc-dotnet
@@ -94,9 +98,12 @@ jobs:
9498
path: bindings/dotnet/ironcalc-dotnet/IronCalc/runtimes/
9599
merge-multiple: true
96100

97-
- uses: actions/setup-dotnet@v3
101+
- uses: actions/setup-dotnet@v5
98102
with:
99-
dotnet-version: '9.0.x'
103+
dotnet-version: |
104+
8.0.x
105+
9.0.x
106+
10.0.x
100107
101108
- name: dotnet pack
102109
run: dotnet pack ironcalc-dotnet/IronCalc
@@ -131,17 +138,22 @@ jobs:
131138
name: ironcalc-nuget
132139
path: bindings/dotnet/nuget_source
133140

134-
- uses: actions/setup-dotnet@v3
141+
- uses: actions/setup-dotnet@v5
135142
with:
136-
dotnet-version: '9.0.x'
143+
dotnet-version: |
144+
8.0.x
145+
9.0.x
146+
10.0.x
137147
138148
- name: test nuget package
139149
run: |
140150
dotnet new console -n temp-console-app
141151
cd temp-console-app
142152
dotnet add package IronCalc --source ../nuget_source
143153
cp ../ironcalc-dotnet/IronCalc.Playground/Program.cs ./
144-
dotnet run
154+
dotnet run --framework net8.0
155+
dotnet run --framework net9.0
156+
dotnet run --framework net10.0
145157
146158
push-nuget:
147159
if: ${{ github.event.inputs.release == 'true' }}
@@ -158,9 +170,12 @@ jobs:
158170
path: nuget
159171
merge-multiple: true
160172

161-
- uses: actions/setup-dotnet@v3
173+
- uses: actions/setup-dotnet@v5
162174
with:
163-
dotnet-version: '9.0.x'
175+
dotnet-version: |
176+
8.0.x
177+
9.0.x
178+
10.0.x
164179
165180
- name: upload nupkg
166181
uses: actions/upload-artifact@v4

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/dotnet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ironcalc-dotnet"
3-
version = "0.1.0"
3+
version = "0.0.1-beta1"
44
edition = "2021"
55

66
[lib]

bindings/dotnet/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# IronCalc .NET Binding
2+
3+
This project provides a .NET binding for the [IronCalc](https://github.com/ironcalc/IronCalc) spreadsheet engine. It allows you to use the IronCalc engine from any .NET language (C#, F#, etc.).
4+
5+
## Requirements
6+
7+
To build and develop this project, you will need the following:
8+
9+
* [.NET SDK](https://dotnet.microsoft.com/download) (versions 8, 9, and 10)
10+
* [Rust](https://www.rust-lang.org/tools/install) (stable toolchain)
11+
12+
## Code Structure
13+
14+
The project is structured into two main parts:
15+
16+
* `src/`: This directory contains the Rust source code for the native library. It uses `cbindgen` to generate a C-compatible header for the FFI (Foreign Function Interface). The Rust code is responsible for interacting with the core `ironcalc_base` engine and exposing a C-compatible API.
17+
* `ironcalc-dotnet/`: This directory contains the .NET solution with the following projects:
18+
* `IronCalc/`: The main C# project that defines the public API for the .NET binding. It uses P/Invoke (`DllImport`) to call the native functions exposed by the Rust library.
19+
* `IronCalc.Tests/`: Unit tests for the .NET binding.
20+
* `IronCalc.Playground/`: A sample console application demonstrating how to use the library.
21+
22+
The native library (`.dll`, `.so`, or `.dylib` depending on the platform) is built by Cargo and then copied to the `ironcalc-dotnet/IronCalc/runtimes` directory, allowing the .NET runtime to find and load it.
23+
24+
## Building the Project
25+
26+
You can build the project using the provided `Makefile`:
27+
28+
```bash
29+
# Build the native library and the .NET projects
30+
make
31+
```
32+
33+
The `make` command compiles the Rust code into a dynamic library and then builds the .NET solution. The resulting artifacts will be in the `bindings/dotnet/ironcalc-dotnet/IronCalc/bin/` directory.
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# editorconfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Default settings:
7+
# A newline ending every file
8+
# Use 4 spaces as indentation
9+
[*]
10+
insert_final_newline = true
11+
indent_style = space
12+
indent_size = 4
13+
trim_trailing_whitespace = true
14+
15+
[project.json]
16+
indent_size = 2
17+
18+
# C# and Visual Basic files
19+
[*.{cs,vb}]
20+
charset = utf-8-bom
21+
22+
# Analyzers
23+
dotnet_analyzer_diagnostic.category-Security.severity = error
24+
dotnet_code_quality.ca1802.api_surface = private, internal
25+
# SYSLIB5001: Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
26+
dotnet_diagnostic.SYSLIB5001.severity = suggestion
27+
28+
# Miscellaneous style rules
29+
dotnet_sort_system_directives_first = true
30+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
31+
dotnet_style_predefined_type_for_member_access = true:suggestion
32+
33+
# avoid this. unless absolutely necessary
34+
dotnet_style_qualification_for_field = false:suggestion
35+
dotnet_style_qualification_for_property = false:suggestion
36+
dotnet_style_qualification_for_method = false:suggestion
37+
dotnet_style_qualification_for_event = false:suggestion
38+
39+
# name all constant fields using PascalCase
40+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
41+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
42+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
43+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
44+
dotnet_naming_symbols.constant_fields.required_modifiers = const
45+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
46+
47+
# static fields should have s_ prefix
48+
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
49+
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
50+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
51+
dotnet_naming_symbols.static_fields.applicable_kinds = field
52+
dotnet_naming_symbols.static_fields.required_modifiers = static
53+
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
54+
dotnet_naming_style.static_prefix_style.required_prefix = s_
55+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
56+
57+
# internal and private fields should be _camelCase
58+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
59+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
60+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
61+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
62+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
63+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
64+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
65+
66+
# Code quality
67+
dotnet_style_readonly_field = true:suggestion
68+
dotnet_code_quality_unused_parameters = non_public:suggestion
69+
70+
# Expression-level preferences
71+
dotnet_style_object_initializer = true:suggestion
72+
dotnet_style_collection_initializer = true:suggestion
73+
dotnet_style_explicit_tuple_names = true:suggestion
74+
dotnet_style_coalesce_expression = true:suggestion
75+
dotnet_style_null_propagation = true:suggestion
76+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
77+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
78+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
79+
dotnet_style_prefer_auto_properties = true:suggestion
80+
dotnet_style_prefer_conditional_expression_over_assignment = true:refactoring
81+
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
82+
83+
# CA2208: Instantiate argument exceptions correctly
84+
dotnet_diagnostic.CA2208.severity = error
85+
86+
# C# files
87+
[*.cs]
88+
# New line preferences
89+
csharp_new_line_before_open_brace = all
90+
csharp_new_line_before_else = true
91+
csharp_new_line_before_catch = true
92+
csharp_new_line_before_finally = true
93+
csharp_new_line_before_members_in_object_initializers = true
94+
csharp_new_line_before_members_in_anonymous_types = true
95+
csharp_new_line_between_query_expression_clauses = true
96+
97+
# Indentation preferences
98+
csharp_indent_block_contents = true
99+
csharp_indent_braces = false
100+
csharp_indent_case_contents = true
101+
csharp_indent_case_contents_when_block = true
102+
csharp_indent_switch_labels = true
103+
csharp_indent_labels = one_less_than_current
104+
105+
# Modifier preferences
106+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
107+
108+
# Code style defaults
109+
csharp_using_directive_placement = outside_namespace:suggestion
110+
csharp_prefer_braces = true:refactoring
111+
csharp_preserve_single_line_blocks = true:none
112+
csharp_preserve_single_line_statements = false:none
113+
csharp_prefer_static_local_function = true:suggestion
114+
csharp_prefer_simple_using_statement = false:none
115+
csharp_style_prefer_switch_expression = true:suggestion
116+
117+
# Expression-bodied members
118+
csharp_style_expression_bodied_methods = true:refactoring
119+
csharp_style_expression_bodied_constructors = true:refactoring
120+
csharp_style_expression_bodied_operators = true:refactoring
121+
csharp_style_expression_bodied_properties = true:refactoring
122+
csharp_style_expression_bodied_indexers = true:refactoring
123+
csharp_style_expression_bodied_accessors = true:refactoring
124+
csharp_style_expression_bodied_lambdas = true:refactoring
125+
csharp_style_expression_bodied_local_functions = true:refactoring
126+
csharp_style_expression_bodied_constructors = false
127+
128+
# Pattern matching
129+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
130+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
131+
csharp_style_inlined_variable_declaration = true:suggestion
132+
133+
# Expression-level preferences
134+
csharp_prefer_simple_default_expression = true:suggestion
135+
136+
# Null checking preferences
137+
csharp_style_throw_expression = true:suggestion
138+
csharp_style_conditional_delegate_call = true:suggestion
139+
140+
# Other features
141+
csharp_style_prefer_index_operator = false:none
142+
csharp_style_prefer_range_operator = false:none
143+
csharp_style_pattern_local_over_anonymous_function = false:none
144+
145+
# Space preferences
146+
csharp_space_after_cast = false
147+
csharp_space_after_colon_in_inheritance_clause = true
148+
csharp_space_after_comma = true
149+
csharp_space_after_dot = false
150+
csharp_space_after_keywords_in_control_flow_statements = true
151+
csharp_space_after_semicolon_in_for_statement = true
152+
csharp_space_around_binary_operators = before_and_after
153+
csharp_space_around_declaration_statements = do_not_ignore
154+
csharp_space_before_colon_in_inheritance_clause = true
155+
csharp_space_before_comma = false
156+
csharp_space_before_dot = false
157+
csharp_space_before_open_square_brackets = false
158+
csharp_space_before_semicolon_in_for_statement = false
159+
csharp_space_between_empty_square_brackets = false
160+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
161+
csharp_space_between_method_call_name_and_opening_parenthesis = false
162+
csharp_space_between_method_call_parameter_list_parentheses = false
163+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
164+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
165+
csharp_space_between_method_declaration_parameter_list_parentheses = false
166+
csharp_space_between_parentheses = false
167+
csharp_space_between_square_brackets = false
168+
169+
# Namespace preference
170+
csharp_style_namespace_declarations = file_scoped:suggestion
171+
172+
# Types: use keywords instead of BCL types, and permit var only when the type is clear
173+
csharp_style_var_for_built_in_types = true:suggestion
174+
csharp_style_var_when_type_is_apparent = true:suggestion
175+
csharp_style_var_elsewhere = true:suggestion
176+
177+
# Visual Basic files
178+
[*.vb]
179+
# Modifier preferences
180+
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
181+
182+
# C++ Files
183+
[*.{cpp,h,in}]
184+
curly_bracket_next_line = true
185+
indent_brace_style = Allman
186+
187+
# Xml project files
188+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
189+
indent_size = 2
190+
191+
# Xml build files
192+
[*.builds]
193+
indent_size = 2
194+
195+
# Xml files
196+
[*.{xml,stylecop,resx,ruleset}]
197+
indent_size = 2
198+
199+
# Xml config files
200+
[*.{props,targets,config,nuspec}]
201+
indent_size = 2
202+
203+
# Shell scripts
204+
[*.sh]
205+
end_of_line = lf
206+
207+
[*.{cmd, bat}]
208+
end_of_line = crlf
209+
210+
# Markdown files
211+
[*.md]
212+
# Double trailing spaces can be used for BR tags, and other instances are enforced by Markdownlint
213+
trim_trailing_whitespace = false
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<Project DefaultTargets="Build">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
44
<LangVersion>12</LangVersion>
55
<Nullable>enable</Nullable>
6-
<!--
76
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
87
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
98
<EnableNETAnalyzers>true</EnableNETAnalyzers>
109
<AnalysisModeStyle>Recommended</AnalysisModeStyle>
11-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12-
<NuGetAuditMode>direct</NuGetAuditMode>
13-
-->
1410
</PropertyGroup>
1511
</Project>

0 commit comments

Comments
 (0)