Skip to content

Commit 4584ae7

Browse files
committed
Fixed warnings in the generated code by properly using "new".
Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
1 parent 15ff04a commit 4584ae7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/AST/Class.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ public bool HasNonIgnoredBase
174174
}
175175
}
176176

177+
public bool NeedsBase
178+
{
179+
get { return HasNonIgnoredBase && IsGenerated; }
180+
}
181+
177182
// When we have an interface, this is the class mapped to that interface.
178183
public Class OriginalClass { get; set; }
179184

src/Generator/Generators/CSharp/CSharpTextTemplate.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ private void GenerateClassInternalHead(Class @class = null)
645645
{
646646
Write("public ");
647647

648-
if (@class != null && @class.HasBaseClass)
648+
if (@class != null && @class.NeedsBase && !@class.BaseClass.IsInterface)
649649
Write("new ");
650650

651651
WriteLine("partial struct Internal");
@@ -680,9 +680,7 @@ public void GenerateClassProlog(Class @class)
680680

681681
var bases = new List<string>();
682682

683-
var needsBase = @class.HasNonIgnoredBase && @class.IsGenerated;
684-
685-
if (needsBase)
683+
if (@class.NeedsBase)
686684
{
687685
bases.AddRange(
688686
from @base in @class.Bases
@@ -1907,7 +1905,7 @@ private void GenerateNativeConstructor(Class @class)
19071905
{
19081906
PushBlock(CSharpBlockKind.Method);
19091907
WriteLine("public static {0}{1} {2}(global::System.IntPtr native{3})",
1910-
@class.HasNonIgnoredBase && !@class.BaseClass.IsAbstract ? "new " : string.Empty,
1908+
@class.NeedsBase && !@class.BaseClass.IsInterface ? "new " : string.Empty,
19111909
@class.Name, Helpers.CreateInstanceIdentifier,
19121910
@class.IsRefType ? ", bool ownsNativeInstance = false" : string.Empty);
19131911
WriteStartBraceIndent();

0 commit comments

Comments
 (0)