diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..71e2d6cb
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,10 @@
+
+
+ true
+ 9.0
+ enable
+ true
+ Sergio Pedri
+ Copyright (c) 2021 Sergio Pedri
+
+
\ No newline at end of file
diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
index 749cfb89..5282758b 100644
--- a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
@@ -1,6 +1,5 @@
using System;
using System.Buffers;
-using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
@@ -35,42 +34,42 @@ namespace ComputeSharp.Benchmark.Blas
///
/// The input tensor.
///
- private float[] X;
+ private float[]? X;
///
/// The weights tensor.
///
- private float[] W;
+ private float[]? W;
///
/// The bias tensor.
///
- private float[] B;
+ private float[]? B;
///
/// The result tensor.
///
- private float[] Y;
+ private float[]? Y;
///
/// The input tensor (GPU).
///
- private ReadOnlyBuffer BufferX;
+ private ReadOnlyBuffer? BufferX;
///
/// The weights tensor (GPU).
///
- private ReadOnlyBuffer BufferW;
+ private ReadOnlyBuffer? BufferW;
///
/// The bias tensor (GPU).
///
- private ReadOnlyBuffer BufferB;
+ private ReadOnlyBuffer? BufferB;
///
/// The result tensor (GPU).
///
- private ReadWriteBuffer BufferY;
+ private ReadWriteBuffer? BufferY;
///
/// A instance to initialize the tensors.
@@ -87,10 +86,10 @@ namespace ComputeSharp.Benchmark.Blas
float[] CreateRandomArray(int size)
{
float[] array = ArrayPool.Shared.Rent(size);
- ref float r = ref array[0];
- for (int i = 0; i < size; i++)
+
+ foreach (ref float x in array.AsSpan())
{
- Unsafe.Add(ref r, i) = (float)Random.NextDouble();
+ x = (float)Random.NextDouble();
}
return array;
@@ -115,15 +114,15 @@ namespace ComputeSharp.Benchmark.Blas
[GlobalCleanup]
public void Dispose()
{
- ArrayPool.Shared.Return(X);
- ArrayPool.Shared.Return(W);
- ArrayPool.Shared.Return(B);
- ArrayPool.Shared.Return(Y);
+ ArrayPool.Shared.Return(X!);
+ ArrayPool.Shared.Return(W!);
+ ArrayPool.Shared.Return(B!);
+ ArrayPool.Shared.Return(Y!);
- BufferX.Dispose();
- BufferW.Dispose();
- BufferB.Dispose();
- BufferY.Dispose();
+ BufferX!.Dispose();
+ BufferW!.Dispose();
+ BufferB!.Dispose();
+ BufferY!.Dispose();
}
///
@@ -132,7 +131,7 @@ namespace ComputeSharp.Benchmark.Blas
[Benchmark(Baseline = true)]
public void Cpu()
{
- BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, X, W, B, Y);
+ BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, X!, W!, B!, Y!);
}
///
@@ -141,7 +140,7 @@ namespace ComputeSharp.Benchmark.Blas
[Benchmark]
public void GpuWithNoTemporaryBuffers()
{
- BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, BufferX, BufferW, BufferB, BufferY);
+ BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, BufferX!, BufferW!, BufferB!, BufferY!);
}
///
@@ -150,10 +149,10 @@ namespace ComputeSharp.Benchmark.Blas
[Benchmark]
public void GpuWithTemporaryBuffers()
{
- using ReadOnlyBuffer x = Gpu.Default.AllocateReadOnlyBuffer(X);
- using ReadOnlyBuffer w = Gpu.Default.AllocateReadOnlyBuffer(W);
- using ReadOnlyBuffer b = Gpu.Default.AllocateReadOnlyBuffer(B);
- using ReadWriteBuffer y = Gpu.Default.AllocateReadWriteBuffer(Y.Length);
+ using ReadOnlyBuffer x = Gpu.Default.AllocateReadOnlyBuffer(X!);
+ using ReadOnlyBuffer w = Gpu.Default.AllocateReadOnlyBuffer(W!);
+ using ReadOnlyBuffer b = Gpu.Default.AllocateReadOnlyBuffer(B!);
+ using ReadWriteBuffer y = Gpu.Default.AllocateReadWriteBuffer(Y!.Length);
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, x, w, b, y);
diff --git a/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs b/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
index e518da56..ef208625 100644
--- a/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
@@ -23,7 +23,7 @@ namespace ComputeSharp.Benchmark.Imaging
///
/// The loaded image.
///
- private Image image;
+ private Image? image;
///
/// Initial setup for a benchmarking session.
@@ -31,7 +31,7 @@ namespace ComputeSharp.Benchmark.Imaging
[GlobalSetup]
public void Setup()
{
- string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Imaging", "city.jpg");
+ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
this.image = Image.Load(path);
@@ -45,7 +45,7 @@ namespace ComputeSharp.Benchmark.Imaging
[GlobalCleanup]
public void Dispose()
{
- this.image.Dispose();
+ this.image!.Dispose();
}
///
@@ -55,7 +55,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("BOKEH")]
public void Bokeh_Cpu()
{
- this.image.Mutate(c => c.ApplyProcessor(new BokehBlurProcessor(80, 2, 3)));
+ this.image!.Mutate(c => c.ApplyProcessor(new BokehBlurProcessor(80, 2, 3)));
}
///
@@ -65,7 +65,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("BOKEH")]
public void Bokeh_Gpu()
{
- this.image.Mutate(c => c.ApplyProcessor(new HlslBokehBlurProcessor(80, 2)));
+ this.image!.Mutate(c => c.ApplyProcessor(new HlslBokehBlurProcessor(80, 2)));
}
///
@@ -75,7 +75,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("GAUSSIAN")]
public void Gaussian_Cpu()
{
- this.image.Mutate(c => c.ApplyProcessor(new GaussianBlurProcessor(80)));
+ this.image!.Mutate(c => c.ApplyProcessor(new GaussianBlurProcessor(80)));
}
///
@@ -85,7 +85,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("GAUSSIAN")]
public void Gaussian_Gpu()
{
- this.image.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
+ this.image!.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
}
}
}
diff --git a/samples/ComputeSharp.ImageProcessing/Program.cs b/samples/ComputeSharp.ImageProcessing/Program.cs
index 9924b200..ded812cd 100644
--- a/samples/ComputeSharp.ImageProcessing/Program.cs
+++ b/samples/ComputeSharp.ImageProcessing/Program.cs
@@ -14,7 +14,7 @@ namespace ComputeSharp.ImageProcessing
static void Main()
{
Console.WriteLine(">> Loading image");
- string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "city.jpg");
+ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "city.jpg");
using Image image = Image.Load(path);
// Apply a series of processors and save the results
@@ -29,7 +29,7 @@ namespace ComputeSharp.ImageProcessing
Console.WriteLine($">> Saving {effect.Name} to disk");
string targetPath = Path.Combine(
- Path.GetRelativePath(Path.GetDirectoryName(path), @"..\..\..\"),
+ Path.GetRelativePath(Path.GetDirectoryName(path)!, @"..\..\..\"),
$"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
copy.Save(targetPath);
}
diff --git a/src/ComputeSharp.Shaders/Renderer/Models/HlslFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/HlslFieldInfo.cs
index c63cab1b..baf1f12c 100644
--- a/src/ComputeSharp.Shaders/Renderer/Models/HlslFieldInfo.cs
+++ b/src/ComputeSharp.Shaders/Renderer/Models/HlslFieldInfo.cs
@@ -1,4 +1,6 @@
-namespace ComputeSharp.Shaders.Renderer.Models
+#pragma warning disable CS1572, CS1573
+
+namespace ComputeSharp.Shaders.Renderer.Models
{
///
/// A model that contains info on a shader field.
diff --git a/src/ComputeSharp.Shaders/Renderer/Models/HlslResourceInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/HlslResourceInfo.cs
index cbde91bb..455b287d 100644
--- a/src/ComputeSharp.Shaders/Renderer/Models/HlslResourceInfo.cs
+++ b/src/ComputeSharp.Shaders/Renderer/Models/HlslResourceInfo.cs
@@ -1,4 +1,6 @@
-namespace ComputeSharp.Shaders.Renderer.Models
+#pragma warning disable CS1572, CS1573
+
+namespace ComputeSharp.Shaders.Renderer.Models
{
///
/// A model that contains info on a shader typed resource field.
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index eec5b329..d780b22a 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,14 +1,11 @@
- true
- 9.0
- enable
- Sergio Pedri
- Copyright (c) 2021 Sergio Pedri
2.0.0.0
+
+
\ No newline at end of file
diff --git a/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj b/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj
index 0f9fc9f1..0f67c513 100644
--- a/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj
+++ b/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj
@@ -3,7 +3,6 @@
net5.0
false
- 9.0
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj b/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj
index 07b70aa9..48f8466e 100644
--- a/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj
@@ -2,7 +2,6 @@
net5.0
- 9.0
false
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs
index 86e61ea8..4705f20e 100644
--- a/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs
@@ -17,11 +17,11 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
[AssemblyInitialize]
public static void Initialize(TestContext _)
{
- string path = Path.GetDirectoryName(typeof(NativeLibrariesResolverTests).Assembly.Location);
+ string path = Path.GetDirectoryName(typeof(NativeLibrariesResolverTests).Assembly.Location)!;
while (Path.GetFileName(path) is not "ComputeSharp")
{
- path = Path.GetDirectoryName(path);
+ path = Path.GetDirectoryName(path)!;
}
SampleProjectDirectory = Path.Combine(path, "samples", "ComputeSharp.Sample.NuGet");
@@ -35,7 +35,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
///
/// Gets the directory of the ComputeSharp.Sample.NuGet project.
///
- private static string SampleProjectDirectory { get; set; }
+ private static string? SampleProjectDirectory { get; set; }
[TestMethod]
[DataRow(Configuration.Debug, RID.None)]
@@ -46,7 +46,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
{
CleanSampleProject(configuration, rid);
- Assert.AreEqual(0, Exec(SampleProjectDirectory, "dotnet", $"run -c {configuration} {ToOption(rid)}"));
+ Assert.AreEqual(0, Exec(SampleProjectDirectory!, "dotnet", $"run -c {configuration} {ToOption(rid)}"));
}
[TestMethod]
@@ -61,7 +61,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
string realtivePathToDll = Path.Combine("bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}", "ComputeSharp.Sample.NuGet.dll");
- Assert.AreEqual(0, Exec(SampleProjectDirectory, "dotnet", realtivePathToDll));
+ Assert.AreEqual(0, Exec(SampleProjectDirectory!, "dotnet", realtivePathToDll));
}
[TestMethod]
@@ -74,7 +74,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
CleanSampleProject(configuration, rid);
BuildSampleProject(configuration, rid);
- string pathToDllDirectory = Path.Combine(SampleProjectDirectory, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
+ string pathToDllDirectory = Path.Combine(SampleProjectDirectory!, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
Assert.AreEqual(0, Exec(pathToDllDirectory, "dotnet", "ComputeSharp.Sample.NuGet.dll"));
}
@@ -91,7 +91,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
string relativePathToAppHost = Path.Combine("bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}", "ComputeSharp.Sample.NuGet.exe");
- Assert.AreEqual(0, Exec(SampleProjectDirectory, relativePathToAppHost, ""));
+ Assert.AreEqual(0, Exec(SampleProjectDirectory!, relativePathToAppHost, ""));
}
[TestMethod]
@@ -104,7 +104,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
CleanSampleProject(configuration, rid);
BuildSampleProject(configuration, rid);
- string pathToAppHostDirectory = Path.Combine(SampleProjectDirectory, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
+ string pathToAppHostDirectory = Path.Combine(SampleProjectDirectory!, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
Assert.AreEqual(0, Exec(pathToAppHostDirectory, "ComputeSharp.Sample.NuGet.exe", ""));
}
@@ -123,11 +123,11 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
// Furthermore, only publishing in Release mode is tested.
CleanSampleProject(Configuration.Release, RID.Win_x64);
- Exec(SampleProjectDirectory, "dotnet", $"publish -c Release -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
+ Exec(SampleProjectDirectory!, "dotnet", $"publish -c Release -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
string pathToAppHost = Path.Combine("bin", $"Release", "net5.0", "win-x64", "publish", "ComputeSharp.Sample.NuGet.exe");
- Assert.AreEqual(0, Exec(SampleProjectDirectory, pathToAppHost, ""));
+ Assert.AreEqual(0, Exec(SampleProjectDirectory!, pathToAppHost, ""));
}
///
@@ -139,7 +139,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
/// The RID for which the output is cleaned.
private static void CleanSampleProject(Configuration configuration, RID rid)
{
- Exec(SampleProjectDirectory, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
+ Exec(SampleProjectDirectory!, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
}
///
@@ -149,7 +149,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
/// The RID to use to build the project.
private static void BuildSampleProject(Configuration configuration, RID rid)
{
- Exec(SampleProjectDirectory, "dotnet", $"build -c {configuration} {ToOption(rid)}");
+ Exec(SampleProjectDirectory!, "dotnet", $"build -c {configuration} {ToOption(rid)}");
}
///
@@ -171,7 +171,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
WorkingDirectory = workingDirectory
};
- using Process process = Process.Start(startInfo);
+ using Process process = Process.Start(startInfo)!;
process.WaitForExit();
diff --git a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
index b65efcb0..69ea6dec 100644
--- a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
+++ b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
@@ -3,9 +3,6 @@
net5.0
false
- 9.0
- enable
- true