Skip to content

Commit 2813034

Browse files
authored
Merge pull request #4 from roboter/feature/publish-release-workflow-2267251993978408117
2 parents 456cb38 + eb9834c commit 2813034

File tree

13 files changed

+365
-39
lines changed

13 files changed

+365
-39
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ on:
88
- 'v*'
99
workflow_dispatch:
1010

11+
permissions:
12+
contents: write
13+
1114
jobs:
1215
build:
13-
name: Build and Publish
16+
name: Build and Publish (${{ matrix.runtime }})
1417
runs-on: ${{ matrix.os }}
18+
defaults:
19+
run:
20+
shell: bash
1521
strategy:
22+
fail-fast: false
1623
matrix:
1724
include:
1825
- os: windows-latest
@@ -34,20 +41,30 @@ jobs:
3441
- name: Setup .NET
3542
uses: actions/setup-dotnet@v4
3643
with:
37-
dotnet-version: 10.0.x
44+
dotnet-version: |
45+
10.0.x
46+
47+
- name: List SDKs
48+
run: dotnet --list-sdks
3849

3950
- name: Restore dependencies
40-
run: dotnet restore CSharpCad6/CSharpCad6.csproj
51+
run: dotnet restore OpenSharpCAD.sln
52+
53+
- name: Run Tests
54+
run: dotnet test CSharpCad.UnitTests/CSharpCad.UnitTests.csproj -f ${{ matrix.framework }}
4155

4256
- name: Publish
4357
run: |
4458
dotnet publish CSharpCad6/CSharpCad6.csproj -c Release -r ${{ matrix.runtime }} -f ${{ matrix.framework }} --self-contained true -p:PublishSingleFile=true -o ./publish/${{ matrix.runtime }}
4559
4660
- name: Zip Artifact
47-
shell: bash
4861
run: |
4962
cd publish/${{ matrix.runtime }}
50-
zip -r ../../CSharpCAD-${{ matrix.runtime }}.zip .
63+
if [[ "${{ runner.os }}" == "Windows" ]]; then
64+
7z a ../../CSharpCAD-${{ matrix.runtime }}.zip .
65+
else
66+
zip -r ../../CSharpCAD-${{ matrix.runtime }}.zip .
67+
fi
5168
5269
- name: Upload Artifact
5370
uses: actions/upload-artifact@v4
@@ -65,10 +82,12 @@ jobs:
6582
uses: actions/download-artifact@v4
6683
with:
6784
path: ./artifacts
85+
pattern: CSharpCAD-*
86+
merge-multiple: true
6887

6988
- name: Create Release
70-
uses: softprops/action-gh-release@v1
89+
uses: softprops/action-gh-release@v2
7190
with:
72-
files: ./artifacts/**/*.zip
91+
files: ./artifacts/*.zip
7392
env:
7493
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(NetVersion);$(NetVersion)-windows</TargetFrameworks>
5+
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(NetVersion)</TargetFrameworks>
6+
<LangVersion>latest</LangVersion>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<IsPackable>false</IsPackable>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="coverlet.collector" Version="6.0.4" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
15+
<PackageReference Include="NUnit" Version="4.3.2" />
16+
<PackageReference Include="NUnit.Analyzers" Version="4.7.0" />
17+
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<Using Include="NUnit.Framework" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<ProjectReference Include="..\CSharpCad6\CSharpCad6.csproj" />
26+
</ItemGroup>
27+
28+
</Project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using CSharpCAD;
2+
using NUnit.Framework;
3+
4+
namespace CSharpCad.UnitTests;
5+
6+
[TestFixture]
7+
public class CompilerServiceTests
8+
{
9+
[Test]
10+
public void TestCompileValidScript()
11+
{
12+
string script = "Draw(new Box(8, 20, 10));";
13+
ICompilerService compiler = new CompilerService();
14+
List<string> errors;
15+
16+
var result = compiler.Compile(script, out errors);
17+
18+
Assert.That(errors, Is.Empty, "Should have no compilation errors");
19+
Assert.That(result, Is.Not.Null, "Should return a compiled object");
20+
}
21+
22+
[Test]
23+
public void TestCompileInvalidScript()
24+
{
25+
string script = "InvalidMethod();";
26+
ICompilerService compiler = new CompilerService();
27+
List<string> errors;
28+
29+
var result = compiler.Compile(script, out errors);
30+
31+
Assert.That(errors, Is.Not.Empty, "Should have compilation errors");
32+
Assert.That(result, Is.Null, "Should return null for invalid script");
33+
}
34+
}

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<Company>MatterHackers Inc.</Company>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<NetVersion>net10.0</NetVersion>
6+
<EnableWindowsTargeting>true</EnableWindowsTargeting>
67
</PropertyGroup>
78
</Project>

OpenSharpCAD.sln

Lines changed: 95 additions & 32 deletions
Large diffs are not rendered by default.

doc/README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# MatterCAD Documentation
2+
3+
Welcome to the MatterCAD documentation. This guide provides an overview of all available shapes, transformations, and operations in the MatterCAD library.
4+
5+
## Shapes
6+
7+
### Box
8+
Creates a rectangular box.
9+
- **Constructors**:
10+
- `Box(double sizeX, double sizeY, double sizeZ, string name = "", bool createCentered = true)`
11+
- `Box(Vector3 size, string name = "", bool createCentered = true)`
12+
13+
![Box](examples/box.svg)
14+
15+
### Cylinder
16+
Creates a cylinder or cone.
17+
- **Constructors**:
18+
- `Cylinder(double radius, double height, int sides, Alignment alignment = Alignment.z, string name = "")`
19+
- `Cylinder(double radius1, double radius2, double height, int sides, Alignment alignment = Alignment.z, string name = "")`
20+
21+
![Cylinder](examples/cylinder.svg)
22+
23+
### Sphere
24+
Creates a sphere.
25+
- **Constructors**:
26+
- `Sphere(double radius, string name = "")`
27+
28+
![Sphere](examples/sphere.svg)
29+
30+
### Torus
31+
Creates a torus (donut shape).
32+
- **Constructors**:
33+
- `Torus(double majorRadius, double minorRadius, int sides = 20, int segments = 20, string name = "")`
34+
35+
![Torus](examples/torus.svg)
36+
37+
### NGonExtrusion
38+
Creates an extrusion of a regular polygon.
39+
- **Constructors**:
40+
- `NGonExtrusion(double radius1, double numSides, double height, Alignment alignment = Alignment.z, string name = "")`
41+
42+
### LinearExtrude
43+
Extrudes a 2D shape along a linear path.
44+
- **Constructors**:
45+
- `LinearExtrude(double[] points, double height, Alignment alignment = Alignment.z, double twistRadians = 0, string name = "")`
46+
- `LinearExtrude(Vector2[] points, double height, Alignment alignment = Alignment.z, double twistRadians = 0, string name = "")`
47+
48+
### RotateExtrude
49+
Extrudes a 2D shape by rotating it around an axis.
50+
- **Constructors**:
51+
- `RotateExtrude(double[] points, double axisOffset = 0, Alignment alignment = Alignment.z, string name = "")`
52+
- `RotateExtrude(Vector2[] points, double axisOffset, Alignment alignment = Alignment.z, string name = "")`
53+
54+
### MeshContainer (Import STL)
55+
Loads a mesh from a file (e.g., STL).
56+
- **Constructors**:
57+
- `MeshContainer(string fileOnDisk, string name = "")`
58+
59+
### Round
60+
Creates a box with rounded edges or corners.
61+
- **Constructors**:
62+
- `Round(Vector3 size, string name = "")`
63+
- `Round(double xSize, double ySize, double zSize, string name = "")`
64+
- **Methods**:
65+
- `RoundFace(Face faceToRound, double radius)`
66+
- `RoundEdge(Edge edgeToRound, double radius)`
67+
- `RoundPoint(Face threeFacesThatSharePoint, double radius)`
68+
- `RoundAll(double radius)`
69+
70+
---
71+
72+
## Transformations
73+
74+
### Translate
75+
Moves an object in 3D space.
76+
- **Example**: `new Translate(myObject, x: 10, y: 0, z: 5);`
77+
- **Example**: `new Translate(myObject, new Vector3(10, 0, 5));`
78+
79+
### Rotate
80+
Rotates an object around the X, Y, and Z axes (in radians).
81+
- **Example**: `new Rotate(myObject, x: MathHelper.DegreesToRadians(45));`
82+
83+
### Scale
84+
Changes the size of an object.
85+
- **Example**: `new Scale(myObject, x: 2, y: 1, z: 1);`
86+
- **Example**: `new Scale(myObject, new Vector3(2, 1, 1));`
87+
88+
### Align
89+
Aligns one object to another based on their faces.
90+
- **Example**: `new Align(objectToMove, Face.Left, targetObject, Face.Right);`
91+
92+
### SetCenter
93+
Sets the center of an object to a specific position.
94+
- **Example**: `new SetCenter(myObject, x: 0, y: 0, z: 0);`
95+
- **Example**: `new SetCenter(myObject, new Vector3(0, 0, 0));`
96+
97+
### Mirror
98+
Mirrors an object across a plane.
99+
- **Methods**:
100+
- `myObject.NewMirrorAccrossX(double offsetFromOrigin = 0)`
101+
- `myObject.NewMirrorAccrossY(double offsetFromOrigin = 0)`
102+
- `myObject.NewMirrorAccrossZ(double offsetFromOrigin = 0)`
103+
104+
---
105+
106+
## Operations (CSG)
107+
108+
### Union
109+
Combines multiple objects into one.
110+
- **C# operator**: `obj1 + obj2`
111+
112+
![Union](examples/union.svg)
113+
114+
### Difference
115+
Subtracts one object from another.
116+
- **C# operator**: `obj1 - obj2`
117+
118+
![Difference](examples/difference.svg)
119+
120+
### Intersection
121+
Keeps only the overlapping part of two objects.
122+
- **C# operator**: `obj1 & obj2` (Not directly supported as operator in some versions, use `new Intersection(obj1, obj2)`)
123+
124+
![Intersection](examples/intersection.svg)
125+
126+
---
127+
128+
## Constants and Enums
129+
130+
### Alignment
131+
Used to specify the primary axis of a shape.
132+
- `Alignment.x`, `Alignment.y`, `Alignment.z`
133+
- `Alignment.negX`, `Alignment.negY`, `Alignment.negZ`
134+
135+
### Face
136+
Used for alignment and rounding.
137+
- `Face.Left`, `Face.Right`, `Face.Front`, `Face.Back`, `Face.Bottom`, `Face.Top`
138+
139+
### Edge
140+
Used for rounding edges.
141+
- `Edge.LeftFront`, `Edge.LeftBack`, `Edge.LeftTop`, `Edge.LeftBottom`, etc.

doc/examples/box.svg

Lines changed: 5 additions & 0 deletions
Loading

doc/examples/cylinder.svg

Lines changed: 5 additions & 0 deletions
Loading

doc/examples/difference.svg

Lines changed: 4 additions & 0 deletions
Loading

doc/examples/intersection.svg

Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)