Skip to content

Commit 0e7efab

Browse files
SFML.Net 3 (#277)
* Update SFML.Net to CSFML/SFML 3 - Update all SFML modules to use the latest CSFML methods - Switch to NET Analyzer from StyleCop * Add tests for SFML.System --------- Co-authored-by: Lukas Dürrenberger <[email protected]>
1 parent 4d8fc23 commit 0e7efab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3961
-1075
lines changed

.editorconfig

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ indent_style = space
1717
indent_size = 4
1818
insert_final_newline = false
1919
trim_trailing_whitespace = true
20+
csharp_using_directive_placement = outside_namespace:silent
21+
csharp_prefer_simple_using_statement = true:suggestion
22+
csharp_prefer_braces = true:warning
23+
csharp_style_namespace_declarations = file_scoped:silent
24+
csharp_style_prefer_method_group_conversion = true:silent
25+
csharp_style_prefer_top_level_statements = false:warning
26+
csharp_style_prefer_primary_constructors = true:suggestion
27+
csharp_style_expression_bodied_methods = true:warning
28+
csharp_style_expression_bodied_constructors = true:warning
29+
csharp_style_expression_bodied_operators = true:warning
30+
csharp_style_expression_bodied_properties = true:warning
31+
csharp_style_expression_bodied_indexers = true:warning
32+
csharp_style_expression_bodied_accessors = true:warning
33+
csharp_style_expression_bodied_lambdas = true:silent
34+
csharp_style_expression_bodied_local_functions = false:silent
35+
csharp_indent_labels = no_change
2036

2137
#########################
2238
# File Extension Settings
@@ -350,4 +366,7 @@ dotnet_diagnostic.IDE0130.severity = suggestion
350366
dotnet_diagnostic.IDE0060.severity = suggestion
351367

352368
# CA1805: Do not initialize unnecessarily
353-
dotnet_diagnostic.CA1805.severity = warning
369+
dotnet_diagnostic.CA1805.severity = warning
370+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
371+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
372+
tab_width = 4

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ jobs:
4141
run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
4242
- name: Verify SDK Installation
4343
run: dotnet --info
44+
continue-on-error: true
4445

4546
- name: Install SFML.Net Dependencies
4647
run: dotnet restore
4748
- name: Build SFML.Net
4849
run: dotnet build --configuration Release --no-restore
50+
- name: Test SFML.Net
51+
if: matrix.dotnet.name == '.NET 6'
52+
run: dotnet test --configuration Release --no-restore
4953
- name: Pack SFML.Net
5054
run: dotnet pack --configuration Release -o Publish
5155

@@ -58,4 +62,4 @@ jobs:
5862
uses: actions/upload-artifact@v4
5963
with:
6064
name: SFML.Net (${{ matrix.platform.name }} ${{ matrix.dotnet.name }})
61-
path: Publish/SFML.*.*.nupkg
65+
path: Publish/SFML.*.*.nupkg

SFML.CodeStyle.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22

33
<!-- This file contains code style configurations for projects. -->
4-
4+
55
<PropertyGroup>
66
<EnableNETAnalyzers>true</EnableNETAnalyzers>
77
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>

SFML.Module.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="CSFML" Version="[2.6.1, 2.7)" />
21+
<PackageReference Include="CSFML" Version="[3.0.0-rc.1, 3.1)" />
2222
</ItemGroup>
2323

2424
</Project>

SFML.NuGet.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PropertyGroup>
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
77

8-
<Version>2.6.0</Version>
8+
<Version>3.0.0-rc.1</Version>
99
<Authors>Laurent Gomila</Authors>
1010
<PackageTags>sfml sfml.net</PackageTags>
1111
<Copyright>Copyright © Laurent Gomila</Copyright>

SFML.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ EndProject
1616
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4BBA7B74-E003-4D9B-826A-43BD6BA48111}"
1717
ProjectSection(SolutionItems) = preProject
1818
.editorconfig = .editorconfig
19+
SFML.Module.props = SFML.Module.props
20+
SFML.NuGet.props = SFML.NuGet.props
21+
SFML.CodeStyle.props = SFML.CodeStyle.props
1922
EndProjectSection
2023
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SFML.System.Test", "test\SFML.System.Test\SFML.System.Test.csproj", "{958AC8B0-2D99-4C65-97C1-2979A090C82D}"
25+
EndProject
26+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D98B564D-6F79-4429-87C3-ECDDC54F731B}"
27+
EndProject
2128
Global
2229
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2330
Debug|Any CPU = Debug|Any CPU
@@ -88,11 +95,26 @@ Global
8895
{88DD6B5D-3013-4737-A77C-EC2563FCED38}.Release|x64.Build.0 = Release|x64
8996
{88DD6B5D-3013-4737-A77C-EC2563FCED38}.Release|x86.ActiveCfg = Release|x86
9097
{88DD6B5D-3013-4737-A77C-EC2563FCED38}.Release|x86.Build.0 = Release|x86
98+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
99+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Debug|Any CPU.Build.0 = Debug|Any CPU
100+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Debug|x64.ActiveCfg = Debug|x64
101+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Debug|x64.Build.0 = Debug|x64
102+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Debug|x86.ActiveCfg = Debug|x86
103+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Debug|x86.Build.0 = Debug|x86
104+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Release|Any CPU.ActiveCfg = Release|Any CPU
105+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Release|Any CPU.Build.0 = Release|Any CPU
106+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Release|x64.ActiveCfg = Release|x64
107+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Release|x64.Build.0 = Release|x64
108+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Release|x86.ActiveCfg = Release|x86
109+
{958AC8B0-2D99-4C65-97C1-2979A090C82D}.Release|x86.Build.0 = Release|x86
91110
EndGlobalSection
92111
GlobalSection(SolutionProperties) = preSolution
93112
HideSolutionNode = FALSE
94113
EndGlobalSection
95114
GlobalSection(ExtensibilityGlobals) = postSolution
96115
SolutionGuid = {384AFDD8-7EEF-462A-B496-B5F71D0EEF1D}
97116
EndGlobalSection
117+
GlobalSection(NestedProjects) = preSolution
118+
{958AC8B0-2D99-4C65-97C1-2979A090C82D} = {D98B564D-6F79-4429-87C3-ECDDC54F731B}
119+
EndGlobalSection
98120
EndGlobal

examples/netcore/Program.cs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,43 @@
44
using SFML.System;
55
using SFML.Window;
66

7-
namespace netcore
7+
namespace netcore;
8+
9+
internal class Program
810
{
9-
internal class Program
11+
private static void Main()
1012
{
11-
private static void Main()
13+
var shape = new RectangleShape(new Vector2f(100, 100))
1214
{
13-
var shape = new RectangleShape(new Vector2f(100, 100))
14-
{
15-
FillColor = Color.Black
16-
};
17-
18-
var sound = new Sound(GenerateSineWave(frequency: 440.0, volume: .25, seconds: 1));
15+
FillColor = Color.Black
16+
};
1917

20-
var window = new RenderWindow(new VideoMode(800, 600), "SFML running in .NET Core");
21-
window.Closed += (_, _) => window.Close();
18+
var sound = new Sound(GenerateSineWave(frequency: 440.0, volume: .25, seconds: 1));
2219

23-
sound.Play();
20+
var window = new RenderWindow(new VideoMode((800, 600)), "SFML running in .NET Core");
21+
window.Closed += (_, _) => window.Close();
2422

25-
while (window.IsOpen)
26-
{
27-
window.DispatchEvents();
28-
window.Clear(Color.White);
29-
window.Draw(shape);
30-
window.Display();
31-
}
32-
}
23+
sound.Play();
3324

34-
private static SoundBuffer GenerateSineWave(double frequency, double volume, int seconds)
25+
while (window.IsOpen)
3526
{
36-
uint sampleRate = 44100;
37-
var samples = new short[seconds * sampleRate];
27+
window.DispatchEvents();
28+
window.Clear(Color.White);
29+
window.Draw(shape);
30+
window.Display();
31+
}
32+
}
3833

39-
for (var i = 0; i < samples.Length; i++)
40-
{
41-
samples[i] = (short)(Math.Sin(frequency * (2 * Math.PI) * i / sampleRate) * volume * short.MaxValue);
42-
}
34+
private static SoundBuffer GenerateSineWave(double frequency, double volume, int seconds)
35+
{
36+
uint sampleRate = 44100;
37+
var samples = new short[seconds * sampleRate];
4338

44-
return new SoundBuffer(samples, 1, sampleRate);
39+
for (var i = 0; i < samples.Length; i++)
40+
{
41+
samples[i] = (short)(Math.Sin(frequency * (2 * Math.PI) * i / sampleRate) * volume * short.MaxValue);
4542
}
43+
44+
return new SoundBuffer(samples, 1, sampleRate, new SoundChannel[] { SoundChannel.Mono });
4645
}
4746
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"profiles": {
3+
"netcore": {
4+
"commandName": "Project",
5+
"nativeDebugging": true
6+
}
7+
}
8+
}

examples/opengl/OpenGL.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private static void Main()
2424
};
2525

2626
// Create the main window
27-
var window = new RenderWindow(new VideoMode(800, 600), "SFML graphics with OpenGL", Styles.Default, contextSettings);
27+
var window = new RenderWindow(new VideoMode((800, 600)), "SFML graphics with OpenGL", Styles.Default, State.Windowed, contextSettings);
2828
window.SetVerticalSyncEnabled(true);
2929

3030
// Initialize OpenTK
@@ -41,7 +41,7 @@ private static void Main()
4141
var background = new Sprite(new Texture("resources/background.jpg"));
4242

4343
// Create a text to display on top of the OpenGL object
44-
var text = new Text("SFML / OpenGL demo", new Font("resources/sansation.ttf"))
44+
var text = new Text(new Font("resources/sansation.ttf"), "SFML / OpenGL demo")
4545
{
4646
Position = new Vector2f(250, 450),
4747
FillColor = new SFML.Graphics.Color(255, 255, 255, 170)
@@ -212,6 +212,6 @@ private static void OnKeyPressed(object sender, KeyEventArgs e)
212212
/// <summary>
213213
/// Function called when the window is resized
214214
/// </summary>
215-
private static void OnResized(object sender, SizeEventArgs e) => GL.Viewport(0, 0, (int)e.Width, (int)e.Height);
215+
private static void OnResized(object sender, SizeEventArgs e) => GL.Viewport(0, 0, (int)e.Size.X, (int)e.Size.Y);
216216
}
217217
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"profiles": {
3+
"opengl": {
4+
"commandName": "Project",
5+
"nativeDebugging": true
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)