Skip to content

Commit 4417dd9

Browse files
authored
Code cleanups and improvements (mono#1713)
* Code cleanups. * Run GetterSetterToPropertyPass for more generators. * Fixed compile warning when compiling parser bindings. * Cleanup driver code. * Remove dead 32-bit code. * Reduce verbosity when Options.Quiet is set. * Remove test compile-time warnings. * Move .NET tests to tests/dotnet. * Remove unused AST viewer code and premake-qt submodule. * Move tests2/ contents to tests/.
1 parent 117567d commit 4417dd9

File tree

160 files changed

+219
-2603
lines changed

Some content is hidden

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

160 files changed

+219
-2603
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "build/modules/premake-qt"]
2-
path = build/modules/premake-qt
3-
url = https://github.com/dcourtois/premake-qt.git

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<GeneratorFileExtension>dll</GeneratorFileExtension>
3535
<DotNetCmd Condition="'$(PlatformTarget)' == 'x86' AND Exists('$(MSBuildProgramFiles32)\dotnet\dotnet.exe')">"$(MSBuildProgramFiles32)\dotnet\dotnet.exe"</DotNetCmd>
3636
<DotNetCmd Condition="'$(PlatformTarget)' == 'x64' AND Exists('$(ProgramW6432)\dotnet\dotnet.exe')">"$(ProgramW6432)\dotnet\dotnet.exe"</DotNetCmd>
37-
<RID Condition="$(IsWindows)">win</RID>
37+
<RID Condition="$(IsWindows)">win</RID>
3838
<RID Condition="$(IsLinux)">linux</RID>
3939
<RID Condition="$(IsMacOSX)">osx</RID>
4040
<RID>$(RID)-$(PlatformTarget)</RID>

build/Helpers.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ rootdir = path.getabsolute("../")
4747
srcdir = path.join(rootdir, "src");
4848
incdir = path.join(rootdir, "include");
4949
examplesdir = path.join(rootdir, "examples");
50-
testsdir = path.join(rootdir, "tests");
50+
testsdir = path.join(rootdir, "tests/dotnet");
5151
builddir = path.join(rootdir, "build")
5252
bindir = path.join(rootdir, "bin")
5353
objsdir = path.join(builddir, "obj");

build/modules/premake-qt

-1
This file was deleted.

build/premake5.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ workspace "CppSharp"
4444
workspacefiles(path.join(builddir, "premake5.lua"))
4545
workspacefiles(path.join(builddir, "*.sh"))
4646
workspacefiles(path.join(rootdir, ".github/workflows/*.yml"))
47-
workspacefiles(path.join(rootdir, "tests/Test*.props"))
47+
workspacefiles(path.join(testsdir, "Test*.props"))
4848

4949
group "Libraries"
5050
if EnableNativeProjects() then

src/AST/Property.cs

+32-79
Original file line numberDiff line numberDiff line change
@@ -22,109 +22,62 @@ public Property(Property property)
2222
parameters.AddRange(property.Parameters);
2323
}
2424

25-
public Type Type
26-
{
27-
get { return QualifiedType.Type; }
28-
}
25+
public Type Type => QualifiedType.Type;
2926

3027
public QualifiedType QualifiedType { get; set; }
3128

32-
public bool IsStatic
33-
{
34-
get
35-
{
36-
return (GetMethod != null && GetMethod.IsStatic) ||
37-
(SetMethod != null && SetMethod.IsStatic);
38-
}
39-
}
29+
public bool IsStatic =>
30+
GetMethod is {IsStatic: true} ||
31+
SetMethod is {IsStatic: true};
4032

41-
public bool IsPure
42-
{
43-
get
44-
{
45-
return (GetMethod != null && GetMethod.IsPure) ||
46-
(SetMethod != null && SetMethod.IsPure);
47-
}
48-
}
33+
public bool IsPure =>
34+
GetMethod is {IsPure: true} ||
35+
SetMethod is {IsPure: true};
4936

50-
public bool IsVirtual
51-
{
52-
get
53-
{
54-
return (GetMethod != null && GetMethod.IsVirtual) ||
55-
(SetMethod != null && SetMethod.IsVirtual);
56-
}
57-
}
37+
public bool IsVirtual =>
38+
GetMethod is {IsVirtual: true} ||
39+
SetMethod is {IsVirtual: true};
5840

59-
public bool IsOverride
60-
{
61-
get
62-
{
63-
return (GetMethod != null && GetMethod.IsOverride) ||
64-
(SetMethod != null && SetMethod.IsOverride);
65-
}
66-
}
41+
public bool IsOverride =>
42+
GetMethod is {IsOverride: true} ||
43+
SetMethod is {IsOverride: true};
6744

6845
public Method GetMethod { get; set; }
6946

7047
public Method SetMethod { get; set; }
7148

72-
public bool HasGetter
73-
{
74-
get
75-
{
76-
return (GetMethod != null &&
77-
GetMethod.GenerationKind != GenerationKind.None) ||
78-
(Field != null &&
79-
Field.GenerationKind != GenerationKind.None);
80-
}
81-
}
49+
public bool HasGetter =>
50+
(GetMethod != null &&
51+
GetMethod.GenerationKind != GenerationKind.None) ||
52+
(Field != null &&
53+
Field.GenerationKind != GenerationKind.None);
8254

83-
public bool HasSetter
84-
{
85-
get
86-
{
87-
return (SetMethod != null &&
88-
SetMethod.GenerationKind != GenerationKind.None) ||
89-
(Field != null &&
90-
(!Field.QualifiedType.IsConst() ||
91-
Field.Type.IsConstCharString()) &&
92-
Field.GenerationKind != GenerationKind.None);
93-
}
94-
}
55+
public bool HasSetter =>
56+
(SetMethod != null &&
57+
SetMethod.GenerationKind != GenerationKind.None) ||
58+
(Field != null &&
59+
(!Field.QualifiedType.IsConst() ||
60+
Field.Type.IsConstCharString()) &&
61+
Field.GenerationKind != GenerationKind.None);
9562

9663
// The field that should be get and set by this property
9764
public Field Field { get; set; }
9865

9966
public Class ExplicitInterfaceImpl { get; set; }
10067

101-
private readonly List<Parameter> parameters = new List<Parameter>();
68+
private readonly List<Parameter> parameters = new();
10269

10370
/// <summary>
10471
/// Only applicable to index ([]) properties.
10572
/// </summary>
106-
public List<Parameter> Parameters
107-
{
108-
get { return parameters; }
109-
}
73+
public List<Parameter> Parameters => parameters;
11074

111-
public bool IsIndexer
112-
{
113-
get
114-
{
115-
return GetMethod != null &&
116-
GetMethod.OperatorKind == CXXOperatorKind.Subscript;
117-
}
118-
}
75+
public bool IsIndexer =>
76+
GetMethod is {OperatorKind: CXXOperatorKind.Subscript};
11977

120-
public bool IsSynthetized
121-
{
122-
get
123-
{
124-
return (GetMethod != null && GetMethod.IsSynthetized) ||
125-
(SetMethod != null && SetMethod.IsSynthetized);
126-
}
127-
}
78+
public bool IsSynthetized =>
79+
(GetMethod != null && GetMethod.IsSynthetized) ||
80+
(SetMethod != null && SetMethod.IsSynthetized);
12881

12982
public override T Visit<T>(IDeclVisitor<T> visitor)
13083
{

src/ASTViewer/AstModel.cpp

-141
This file was deleted.

src/ASTViewer/AstModel.h

-35
This file was deleted.

0 commit comments

Comments
 (0)