Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# 8 Support #40

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5966d28
Start of C# 8 Support
HurricanKai Aug 10, 2019
56fba14
Start C# 8.0 Support for Core/BuildTools
HurricanKai Aug 10, 2019
a97509a
Nullable support for ArrayParameterOverloader
HurricanKai Aug 10, 2019
f31b13d
Nullable support for Core/BuildTools/Common/Functions/Function.cs
HurricanKai Aug 10, 2019
595b705
Nullable support for Core/BuildTools/Bind/Overloading/FlowPointerOver…
HurricanKai Aug 10, 2019
f08f357
Nullable support for Core/BuildTools/Common/Builders/FunctionSignatur…
HurricanKai Aug 10, 2019
d50a822
Nullable support for Core/BuildTools/Bind/Overloading/IFunctionOverlo…
HurricanKai Aug 10, 2019
51f6a91
Nullable support for Core/BuildTools/Bind/Overloading/Overload.cs
HurricanKai Aug 10, 2019
4958a46
Nullable support for Core/BuildTools/Bind/Overloading/IntPtrOverloade…
HurricanKai Aug 10, 2019
eed1e28
Nullable support for Core/BuildTools/Bind/Overloading/Overloader.cs
HurricanKai Aug 10, 2019
53a49a2
Nullable support for Core/BuildTools/Bind/Overloading/PointerParamete…
HurricanKai Aug 10, 2019
614be58
Nullable support for Core/BuildTools/Bind/Overloading/PointerReturnVa…
HurricanKai Aug 10, 2019
d34cb52
Nullable support for Core/BuildTools/Bind/Overloading/ReturnTypeOverl…
HurricanKai Aug 10, 2019
56e5b5a
Nullable support for Core/BuildTools/Bind/Overloading/StaticCountOver…
HurricanKai Aug 10, 2019
50d8b95
Nullable support for Core/BuildTools/Bind/Binder.cs
HurricanKai Aug 10, 2019
c82689d
Nullable support for Core/BuildTools/Bind/BindOptions.cs
HurricanKai Aug 10, 2019
a4f163d
Nullable support for Core/BuildTools/Bind/ProfileWriter.cs
HurricanKai Aug 10, 2019
c2aa592
Nullable support for Core/BuildTools/Common/Builders/ParameterSignatu…
HurricanKai Aug 10, 2019
89e10d2
Merge branch 'master' into C#-8
Perksey Aug 11, 2019
4a246a8
Build Tools .Net Core 3 (#42)
HurricanKai Aug 11, 2019
dc6c5c9
Merge branch 'master' into C#-8
Perksey Aug 11, 2019
64733e7
Resolve Net Core 3 introduced Warnings
HurricanKai Aug 11, 2019
3be672c
Nullable support for Core/BuildTools/Common/Builders/TypeSignatureBui…
HurricanKai Aug 11, 2019
b659de5
Nullable support for Core/BuildTools/Common/Enums/Enum.cs
HurricanKai Aug 11, 2019
16e20f1
Nullable support for Core/BuildTools/Common/Enums/Token.cs
HurricanKai Aug 11, 2019
5d6da75
Nullable support for Core/BuildTools/Common/Functions/Count.cs
HurricanKai Aug 11, 2019
b0c66fe
Nullable support for Core/BuildTools/Common/Functions/FlowDirection.cs
HurricanKai Aug 11, 2019
6da1853
Further changes to Core/BuildTools/Common/Functions/Function.cs
HurricanKai Aug 11, 2019
c718aea
Nullable support for Core/BuildTools/Common/Functions/GenericTypePara…
HurricanKai Aug 11, 2019
2efd0af
Nullable support for Core/BuildTools/Common/Functions/Parameter.cs
HurricanKai Aug 11, 2019
4b1eed1
Nullable support for Core/BuildTools/Common/Functions/Type.cs
HurricanKai Aug 11, 2019
b2973b7
Nullable support for Core/BuildTools/Common/Structs/Field.cs
HurricanKai Aug 11, 2019
17123c7
Refactoring for JSON use
HurricanKai Aug 11, 2019
21d5156
Nullable support for Core/BuildTools/Common/Attribute.cs
HurricanKai Aug 11, 2019
2355f9c
Nullable support for Core/BuildTools/Common/Interface.cs
HurricanKai Aug 11, 2019
8ab40d0
Nullable support for Core/BuildTools/Common/NameContainer.cs
HurricanKai Aug 11, 2019
52c2a89
Nullable support for Core/BuildTools/Common/Profile.cs
HurricanKai Aug 11, 2019
bca330a
Nullable support for Core/BuildTools/Common/Project.cs
HurricanKai Aug 11, 2019
949eabe
Nullable support for Core/BuildTools/Common/Struct.cs
HurricanKai Aug 11, 2019
6d59a38
Nullable support for Core/BuildTools/Common/Utilities.cs + minor refa…
HurricanKai Aug 11, 2019
d228f3d
Nullable support for Core/BuildTools/GLXmlConvert/Baking/ProfileBaker…
HurricanKai Aug 11, 2019
c252a17
Update CI to Preview 8.
HurricanKai Aug 14, 2019
e6ce03f
Final Fixes
HurricanKai Aug 14, 2019
0fdb2c3
Merge branch 'C#-8' of https://github.com/HurricanKai/Silk.NET into C#-8
HurricanKai Aug 14, 2019
c4b89ce
Spec changes
HurricanKai Aug 14, 2019
af89e04
Fix the colourful exceptions we were getting
Perksey Aug 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Expand Up @@ -12,7 +12,7 @@ jobs:

variables:
buildConfiguration: 'Release'
dotnetCoreVersion: '3.0.100-preview6-012264'
dotnetCoreVersion: '3.0.100-preview8-013656'

steps:
- task: DotNetCoreInstaller@0
Expand Down
8 changes: 5 additions & 3 deletions build/binder_specifications/GLES.json
Expand Up @@ -20869,14 +20869,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters containing the name of the uniform block whose index\n/// to retrieve.\r\n/// This parameter contains 0 elements.\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters containing the name of the uniform block whose index\n/// to retrieve.\r\n/// This parameter's element count is computed from .\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"ExtensionName": "Core"
},
{
Expand Down Expand Up @@ -81994,7 +81996,7 @@
"OutputFolder": "OpenGL",
"Name": "GLES",
"ClassName": "GL",
"Version": null,
"Version": "",
"FunctionPrefix": "gl",
"SymbolLoaderName": "Silk.NET.Core.Loader.EGLSymbolLoader.Loader",
"Names": {
Expand Down
50 changes: 33 additions & 17 deletions build/binder_specifications/OpenGL (Compatibility Profile).json
Expand Up @@ -21340,14 +21340,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter contains 0 elements.\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter's element count is computed from .\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"ExtensionName": "Core"
},
{
Expand Down Expand Up @@ -54698,7 +54700,9 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 2
}
Expand All @@ -54712,7 +54716,7 @@
]
}
],
"Doc": "/// <summary>\r\n/// Return the polygon stipple pattern.\r\n/// </summary>\r\n/// <param name=\"mask\">\r\n/// To be added.\r\n/// This parameter contains 0 elements.\r\n///\r\n/// </param>\r\n",
"Doc": "/// <summary>\r\n/// Return the polygon stipple pattern.\r\n/// </summary>\r\n/// <param name=\"mask\">\r\n/// To be added.\r\n/// This parameter's element count is computed from .\r\n///\r\n/// </param>\r\n",
"ExtensionName": "Core"
},
{
Expand Down Expand Up @@ -59557,7 +59561,9 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
Expand All @@ -59571,7 +59577,7 @@
]
}
],
"Doc": "/// <summary>\r\n/// Set the polygon stippling pattern.\r\n/// </summary>\r\n/// <param name=\"mask\">\r\n/// To be added.\r\n/// This parameter contains 0 elements.\r\n///\r\n/// </param>\r\n",
"Doc": "/// <summary>\r\n/// Set the polygon stippling pattern.\r\n/// </summary>\r\n/// <param name=\"mask\">\r\n/// To be added.\r\n/// This parameter's element count is computed from .\r\n///\r\n/// </param>\r\n",
"ExtensionName": "Core"
},
{
Expand Down Expand Up @@ -89082,14 +89088,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter contains 0 elements.\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter's element count is computed from .\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"ExtensionName": "Core"
},
{
Expand Down Expand Up @@ -281753,14 +281761,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"code\">\r\n/// To be added.\r\n/// This parameter contains 0 elements.\r\n/// </param>\r\n",
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"code\">\r\n/// To be added.\r\n/// This parameter's element count is computed from .\r\n/// </param>\r\n",
"ExtensionName": "SUN"
},
{
Expand Down Expand Up @@ -281823,14 +281833,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"code\">\r\n/// To be added.\r\n/// This parameter contains 0 elements.\r\n/// </param>\r\n",
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"code\">\r\n/// To be added.\r\n/// This parameter's element count is computed from .\r\n/// </param>\r\n",
"ExtensionName": "SUN"
},
{
Expand Down Expand Up @@ -281893,14 +281905,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"code\">\r\n/// To be added.\r\n/// This parameter contains 0 elements.\r\n/// </param>\r\n",
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"code\">\r\n/// To be added.\r\n/// This parameter's element count is computed from .\r\n/// </param>\r\n",
"ExtensionName": "SUN"
}
],
Expand Down Expand Up @@ -284688,14 +284702,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 2
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"points\">\r\n/// To be added.\r\n/// This parameter contains 0 elements.\r\n/// </param>\r\n",
"Doc": "/// <summary>\r\n/// To be added.\r\n/// </summary>\r\n/// <param name=\"points\">\r\n/// To be added.\r\n/// This parameter's element count is computed from .\r\n/// </param>\r\n",
"ExtensionName": "SGIS"
}
],
Expand Down Expand Up @@ -288908,7 +288924,7 @@
"OutputFolder": "OpenGL",
"Name": "OpenGL (Compatibility Profile)",
"ClassName": "GL",
"Version": null,
"Version": "",
"FunctionPrefix": "gl",
"SymbolLoaderName": "Silk.NET.Core.Loader.GLSymbolLoader.Loader",
"Names": {
Expand Down
14 changes: 9 additions & 5 deletions build/binder_specifications/OpenGL.json
Expand Up @@ -15334,14 +15334,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter contains 0 elements.\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter's element count is computed from .\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"ExtensionName": "Core"
},
{
Expand Down Expand Up @@ -62130,14 +62132,16 @@
"Count": {
"_count": 0,
"ValueReference": null,
"ComputedFromNames": []
"ComputedFromNames": [
""
]
},
"Flow": 1
}
],
"GenericTypeParameters": [],
"Attributes": [],
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter contains 0 elements.\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"Doc": "/// <summary>\r\n/// Retrieve the index of a named uniform block.\r\n/// </summary>\r\n/// <param name=\"program\">\r\n/// Specifies the name of a program containing the uniform block.\r\n/// </param>\r\n/// <param name=\"uniformBlockName\">\r\n/// Specifies the address an array of characters to containing the name of the uniform block whose\n/// index to retrieve.\r\n/// This parameter's element count is computed from .\r\n///\r\n/// </param>\r\n/// <returns>See summary.</returns>\r\n",
"ExtensionName": "Core"
},
{
Expand Down Expand Up @@ -155904,7 +155908,7 @@
"OutputFolder": "OpenGL",
"Name": "OpenGL",
"ClassName": "GL",
"Version": null,
"Version": "",
"FunctionPrefix": "gl",
"SymbolLoaderName": "Silk.NET.Core.Loader.GLSymbolLoader.Loader",
"Names": {
Expand Down
12 changes: 12 additions & 0 deletions src/Core/BuildTools/Bind/BindOptions.cs
Expand Up @@ -4,8 +4,16 @@
// of the MIT license. See the LICENSE file for details.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using CommandLine;

// nullable stays disabled since else the compiler produces warnings cause we don't initialize the variables.
// all of the properties are required, therefore all of them will be not-null anyways.
// marked them with the attribute.

// !! TAKE CARE IF ADDING ADDITIONAL ARGUMENTS !!
#nullable disable

namespace Silk.NET.BuildTools.Bind
{
/// <summary>
Expand All @@ -23,6 +31,7 @@ public sealed class BindOptions
HelpText = "The input files to write.",
Required = true
)]
[NotNull]
public IEnumerable<string> InputFiles { get; set; }

/// <summary>
Expand All @@ -35,6 +44,7 @@ public sealed class BindOptions
HelpText = "The base output path where the binder will write the generated files.",
Required = true
)]
[NotNull]
public string OutputPath { get; set; }

/// <summary>
Expand All @@ -47,6 +57,7 @@ public sealed class BindOptions
HelpText = "The path to the license header.",
Required = true
)]
[NotNull]
public string License { get; set; }

/// <summary>
Expand All @@ -59,6 +70,7 @@ public sealed class BindOptions
HelpText = "The path to the binding's props file.",
Required = true
)]
[NotNull]
public string Props { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/Core/BuildTools/Bind/Binder.cs
Expand Up @@ -10,6 +10,8 @@
using Newtonsoft.Json;
using Silk.NET.BuildTools.Common;

#nullable disable

namespace Silk.NET.BuildTools.Bind
{
/// <summary>
Expand Down
Expand Up @@ -50,7 +50,7 @@ public static bool IsApplicable(Function function)

var lastParameter = function.Parameters.Last();

if (!lastParameter.Type.IsPointer)
if (lastParameter.Type != null && !lastParameter.Type.IsPointer)
{
return false;
}
Expand Down Expand Up @@ -83,6 +83,11 @@ public IEnumerable<Overload> CreateOverloads(Function function)

var arrayParameter = function.Parameters.Last();
var arrayParameterType = arrayParameter.Type;

if (arrayParameterType is null)
{
throw new ArgumentNullException(nameof(Function) + "." + nameof(Function.Parameters) + "." + nameof(Parameter.Type));
}

var newName = function.Name.Singularize(false);
var newParameters = SkipLastExtension.SkipLast(new List<Parameter>(function.Parameters), 2).ToList();
Expand Down
Expand Up @@ -17,7 +17,7 @@ public class FlowPointerOverloader : IFunctionOverloader
{
public IEnumerable<Overload> CreateOverloads(Function function)
{
if (!function.Parameters.Any(x => x.Type.IsPointer && !x.Type.IsVoidPointer()))
if (!function.Parameters.Any(x => x.Type != null && x.Type.IsPointer && !x.Type.IsVoidPointer()))
{
yield break;
}
Expand All @@ -32,6 +32,9 @@ public IEnumerable<Overload> CreateOverloads(Function function)
for (var i = 0; i < function.Parameters.Count; i++)
{
var param = function.Parameters[i];
if (param.Type is null || param.Name is null)
continue;

if (param.Type.IsPointer && !param.Type.IsVoidPointer())
{
var newParameterType = new TypeSignatureBuilder(param.Type)
Expand Down
3 changes: 1 addition & 2 deletions src/Core/BuildTools/Bind/Overloading/IFunctionOverloader.cs
Expand Up @@ -19,7 +19,6 @@ public interface IFunctionOverloader
/// </summary>
/// <param name="function">The base function.</param>
/// <returns>A set of code blocks.</returns>
[NotNull]
IEnumerable<Overload> CreateOverloads([NotNull] Function function);
IEnumerable<Overload> CreateOverloads(Function function);
}
}
5 changes: 5 additions & 0 deletions src/Core/BuildTools/Bind/Overloading/IntPtrOverloader.cs
Expand Up @@ -28,6 +28,11 @@ public IEnumerable<Overload> CreateOverloads(Function function)
for (var i = 0; i < function.Parameters.Count; i++)
{
var parameter = function.Parameters[i];
if (parameter.Type is null)
{
continue;
}

if (parameter.Type.IsIntPtr())
{
@params[i] = new ParameterSignatureBuilder(parameter)
Expand Down
4 changes: 0 additions & 4 deletions src/Core/BuildTools/Bind/Overloading/Overload.cs
Expand Up @@ -10,10 +10,6 @@ namespace Silk.NET.BuildTools.Bind.Overloading
{
public class Overload
{
public Overload()
{
}

public Overload(Function sig, StringBuilder code, bool @unsafe = false)
{
Signature = sig;
Expand Down