Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Move sln to root making it easier to find #75

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ csharp_indent_switch_labels = false
# Prefer "var" everywhere it's apparent
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion
csharp_style_var_elsewhere = true:suggestion

# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
Expand Down
2 changes: 1 addition & 1 deletion .jenkins.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ for (x in alltargets) {
stage("Test on ${mainlabel}") {
ws {
git credentialsId: '56f5f1ca-b5a7-41b5-8318-c84dd4364e72', url: 'git://github.com/mono/gir-sharp.git'
chroot additionalPackages: 'ca-certificates-mono nuget msbuild mono-devel libgtk2.0-dev libgtk-3-dev', chrootName: "${mainlabel}-stable", command: "nuget restore src/Gir.sln && nuget install NUnit.ConsoleRunner -Version 3.8.0 -OutputDirectory testrunner && msbuild /p:Configuration=Release src/Gir.sln && mono ./testrunner/NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe ./src/Gir.Tests/bin/Release/Gir.Tests.dll"
chroot additionalPackages: 'ca-certificates-mono nuget msbuild mono-devel libgtk2.0-dev libgtk-3-dev', chrootName: "${mainlabel}-stable", command: "nuget restore Gir.sln && nuget install NUnit.ConsoleRunner -Version 3.8.0 -OutputDirectory testrunner && msbuild /p:Configuration=Release Gir.sln && mono ./testrunner/NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe ./src/Gir.Tests/bin/Release/Gir.Tests.dll"
step([$class: 'XUnitPublisher', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '5', failureThreshold: '5', unstableNewThreshold: '1', unstableThreshold: '1'], [$class: 'SkippedThreshold', failureNewThreshold: '5', failureThreshold: '5', unstableNewThreshold: '1', unstableThreshold: '1']], tools: [[$class: 'NUnit3TestType', deleteOutputFiles: true, failIfNotNew: true, pattern: '**/TestResult.xml', skipNoTestFiles: true, stopProcessingIfError: true]]])
}
}
Expand Down
2 changes: 1 addition & 1 deletion .jenkins.pullrequest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ for (x in alltargets) {
stage("Test on ${mainlabel}") {
ws {
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: "${sha1}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[refspec: "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*", url: 'git://github.com/mono/gir-sharp.git']]]
chroot additionalPackages: 'ca-certificates-mono nuget msbuild mono-devel libgtk2.0-dev libgtk-3-dev', chrootName: "${mainlabel}-stable", command: "nuget restore src/Gir.sln && nuget install NUnit.ConsoleRunner -Version 3.8.0 -OutputDirectory testrunner && msbuild /p:Configuration=Release src/Gir.sln && mono ./testrunner/NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe ./src/Gir.Tests/bin/Release/Gir.Tests.dll"
chroot additionalPackages: 'ca-certificates-mono nuget msbuild mono-devel libgtk2.0-dev libgtk-3-dev', chrootName: "${mainlabel}-stable", command: "nuget restore Gir.sln && nuget install NUnit.ConsoleRunner -Version 3.8.0 -OutputDirectory testrunner && msbuild /p:Configuration=Release Gir.sln && mono ./testrunner/NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe ./src/Gir.Tests/bin/Release/Gir.Tests.dll"
step([$class: 'XUnitPublisher', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '5', failureThreshold: '5', unstableNewThreshold: '1', unstableThreshold: '1'], [$class: 'SkippedThreshold', failureNewThreshold: '5', failureThreshold: '5', unstableNewThreshold: '1', unstableThreshold: '1']], tools: [[$class: 'NUnit3TestType', deleteOutputFiles: true, failIfNotNew: true, pattern: '**/TestResult.xml', skipNoTestFiles: true, stopProcessingIfError: true]]])
}
}
Expand Down
16 changes: 16 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

<!-- Assembly Info -->
<PropertyGroup>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>GirSharp</Title>
<Description>CSharp binding generator</Description>
<Copyright>Copyright (C) 2018-2020 Microsoft</Copyright>
</PropertyGroup>
</Project>
8 changes: 8 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<ItemGroup>
<None Remove="*.txt" />
<None Remove="*.raw" />
<None Remove="*.custom" />
<None Remove="*.metadata" />
</ItemGroup>
</Project>
42 changes: 42 additions & 0 deletions Gir.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30014.187
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gir", "src\Gir\Gir.csproj", "{D8FC3B49-B1A1-4DEB-8E76-EE537195AD38}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gir.Tests", "src\Gir.Tests\Gir.Tests.csproj", "{51FB7677-5684-4664-A59C-075CA6976F57}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{489766B3-C14A-4C72-A8D1-F3340A835755}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
.jenkins.groovy = .jenkins.groovy
.jenkins.pullrequest.groovy = .jenkins.pullrequest.groovy
CODEOWNERS = CODEOWNERS
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D8FC3B49-B1A1-4DEB-8E76-EE537195AD38}.Debug|x86.ActiveCfg = Debug|Any CPU
{D8FC3B49-B1A1-4DEB-8E76-EE537195AD38}.Debug|x86.Build.0 = Debug|Any CPU
{D8FC3B49-B1A1-4DEB-8E76-EE537195AD38}.Release|x86.ActiveCfg = Release|Any CPU
{D8FC3B49-B1A1-4DEB-8E76-EE537195AD38}.Release|x86.Build.0 = Release|Any CPU
{51FB7677-5684-4664-A59C-075CA6976F57}.Debug|x86.ActiveCfg = Debug|Any CPU
{51FB7677-5684-4664-A59C-075CA6976F57}.Debug|x86.Build.0 = Debug|Any CPU
{51FB7677-5684-4664-A59C-075CA6976F57}.Release|x86.ActiveCfg = Release|Any CPU
{51FB7677-5684-4664-A59C-075CA6976F57}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {13C16ACC-6523-43F7-8F15-9CA70BDF9E81}
EndGlobalSection
EndGlobal
72 changes: 15 additions & 57 deletions src/Gir.Tests/Gir.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,54 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{51FB7677-5684-4664-A59C-075CA6976F57}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Gir.Tests</RootNamespace>
<AssemblyName>Gir.Tests</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworks>netcoreapp3.0;net472</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml">
<HintPath>..\..\..\..\..\..\..\Library\Frameworks\Mono.framework\Versions\5.13.0\lib\mono\4.7-api\System.Xml.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Gtk2\Atk\AtkTests.cs" />
<Compile Include="Test.cs" />
<Compile Include="EnumerationTests.cs" />
<Compile Include="GenerationTestBase.cs" />
<Compile Include="GenerationOptionsTests.cs" />
<Compile Include="BitFieldTests.cs" />
<Compile Include="SymbolTableTests.cs" />
<Compile Include="RecordTests.cs" />
<Compile Include="FunctionTests.cs" />
<Compile Include="ClassTests.cs" />
<Compile Include="InterfaceTests.cs" />
<Compile Include="CallbackTests.cs" />
<Compile Include="ImportantGeneratables\GObject.cs" />
<Compile Include="ImportantGeneratables\List.cs" />
<Compile Include="Gtk2GirTests.cs" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="TestFiles\Gtk2\Gtk-2.0.gir">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down Expand Up @@ -195,6 +150,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="TestFiles\Gtk3\cairo-1.0.gir">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down Expand Up @@ -230,16 +186,18 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Gir\Gir.csproj">
<Project>{D8FC3B49-B1A1-4DEB-8E76-EE537195AD38}</Project>
<Name>Gir</Name>
</ProjectReference>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnit">
<Version>3.10.1</Version>
</PackageReference>
<ProjectReference Include="..\Gir\Gir.csproj" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

</Project>
23 changes: 0 additions & 23 deletions src/Gir.sln

This file was deleted.

23 changes: 11 additions & 12 deletions src/Gir/Generation/Bitfield.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@


namespace Gir
{
public partial class Bitfield : IGeneratable, IDocumented, IEnumFormatter
{
public string FormatValue (string value)
{
int intValue = int.Parse (value);
var intValue = int.Parse (value);

// Maybe pad with leading zeroes based on the value?
return string.Format ("0x{0:X}", intValue);
return $"0x{intValue:X}";
}

public void Generate (GenerationOptions opts)
{
using (var writer = this.GetWriter (opts)) {
this.GenerateDocumentation (writer);
writer.WriteLine ("[Flags]");
writer.WriteLine ("public enum " + Name);
writer.WriteLine ("{");
using var writer = this.GetWriter (opts);
this.GenerateDocumentation (writer);
writer.WriteLine ("[Flags]");
writer.WriteLine ("public enum " + Name);
writer.WriteLine ("{");

using (writer.Indent ()) {
this.GenerateMembers (writer);
}
writer.WriteLine ("}");
using (writer.Indent ()) {
this.GenerateMembers (writer);
}
writer.WriteLine ("}");
}
}
}
46 changes: 22 additions & 24 deletions src/Gir/Generation/Callback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,35 @@ public partial class Callback : IGeneratable, IMethodLike
{
public void Generate (GenerationOptions opts)
{
using (var writer = this.GetWriter (opts))
{
// TODO: Validation if we have an userdata parameter we can use so we can write this code.
// Otherwise, we need to generate code which uses a non-static callback.
using var writer = this.GetWriter (opts);
// TODO: Validation if we have an userdata parameter we can use so we can write this code.
// Otherwise, we need to generate code which uses a non-static callback.

var returnType = this.GetReturnCSharpType (writer);
var parameters = this.BuildParameters (opts, true);
var returnType = this.GetReturnCSharpType (writer);
var parameters = this.BuildParameters (opts, true);

// Public API delegate which uses managed types.
writer.WriteLine ("[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
writer.WriteLine ($"public delegate {returnType} {Name} ({parameters.TypesAndNames})");
writer.WriteLine ();
// Public API delegate which uses managed types.
writer.WriteLine ("[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
writer.WriteLine ($"public delegate {returnType} {Name} ({parameters.TypesAndNames})");
writer.WriteLine ();

// Internal API delegate which uses unmanaged types.
writer.WriteLine ("[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
// TODO: Use native marshal types.
writer.WriteLine ($"internal delegate {returnType} {Name}Native ({parameters.TypesAndNames})");
writer.WriteLine ();
// Internal API delegate which uses unmanaged types.
writer.WriteLine ("[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
// TODO: Use native marshal types.
writer.WriteLine ($"internal delegate {returnType} {Name}Native ({parameters.TypesAndNames})");
writer.WriteLine ();

// Generate wrapper class - static if we can use gchandle, otherwise instance
// Check callback convention - async, notify, call
writer.WriteLine ($"internal static class {Name}Wrapper");
// Generate wrapper class - static if we can use gchandle, otherwise instance
// Check callback convention - async, notify, call
writer.WriteLine ($"internal static class {Name}Wrapper");
writer.WriteLine ("{");
using (writer.Indent ()) {
writer.WriteLine ($"public static void NativeCallback ({parameters.TypesAndNames})");
writer.WriteLine ("{");
using (writer.Indent ()) {
writer.WriteLine ($"public static void NativeCallback ({parameters.TypesAndNames})");
writer.WriteLine ("{");
// TODO: marshal params, call, handle exceptions
writer.WriteLine ("}");
}
// TODO: marshal params, call, handle exceptions
writer.WriteLine ("}");
}
writer.WriteLine ("}");
}
}
}
35 changes: 17 additions & 18 deletions src/Gir/Generation/Class.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;

namespace Gir
Expand All @@ -7,27 +7,26 @@ public partial class Class : IGeneratable, IDocumented
{
public void Generate (GenerationOptions opts)
{
using (var writer = this.GetWriter (opts)) {
this.GenerateDocumentation (writer);
using var writer = this.GetWriter (opts);
this.GenerateDocumentation (writer);

var inheritanceList = new List<string> ();
if (!string.IsNullOrEmpty (Parent))
inheritanceList.Add (Parent);
inheritanceList.AddRange (Implements.Select (x => opts.GenerateInterfacesWithIPrefix ? "I" + x.Name : x.Name));
var inheritanceList = new List<string> ();
if (!string.IsNullOrEmpty (Parent))
inheritanceList.Add (Parent);
inheritanceList.AddRange (Implements.Select (x => opts.GenerateInterfacesWithIPrefix ? "I" + x.Name : x.Name));

var inheritanceString = string.Join (", ", inheritanceList.ToArray ());
if (!string.IsNullOrEmpty (inheritanceString)) {
writer.WriteLine ($"public class {Name} : {inheritanceString}");
} else {
writer.WriteLine ($"public class {Name}");
}
writer.WriteLine ("{");
var inheritanceString = string.Join (", ", inheritanceList.ToArray ());
if (!string.IsNullOrEmpty (inheritanceString)) {
writer.WriteLine ($"public class {Name} : {inheritanceString}");
} else {
writer.WriteLine ($"public class {Name}");
}
writer.WriteLine ("{");

using (writer.Indent ()) {
this.GenerateMembers (writer);
}
writer.WriteLine ("}");
using (writer.Indent ()) {
this.GenerateMembers (writer);
}
writer.WriteLine ("}");
}
}
}
17 changes: 8 additions & 9 deletions src/Gir/Generation/Enumeration.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@


namespace Gir
{
public partial class Enumeration : IGeneratable, IDocumented
{
public void Generate (GenerationOptions opts)
{
using (var writer = this.GetWriter (opts)) {
this.GenerateDocumentation (writer);
writer.WriteLine ("public enum " + Name);
writer.WriteLine ("{");
using var writer = this.GetWriter (opts);
this.GenerateDocumentation (writer);
writer.WriteLine ("public enum " + Name);
writer.WriteLine ("{");

using (writer.Indent ()) {
this.GenerateMembers (writer);
}
writer.WriteLine ("}");
using (writer.Indent ()) {
this.GenerateMembers (writer);
}
writer.WriteLine ("}");
}
}
}
Loading