Skip to content

Commit cb6d2ae

Browse files
committed
Fixed the generated C# when a template specialization with extensions is used for a secondary base.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 52c754c commit cb6d2ae

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/Generator/Generators/CSharp/CSharpSources.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,29 +463,35 @@ private void GenerateInterface(Class @class)
463463
WriteStartBraceIndent();
464464

465465
foreach (var method in @class.Methods.Where(m =>
466-
!ASTUtils.CheckIgnoreMethod(m) && m.Access == AccessSpecifier.Public))
466+
!ASTUtils.CheckIgnoreFunction(m.OriginalFunction) &&
467+
m.Access == AccessSpecifier.Public))
467468
{
468469
PushBlock(BlockKind.Method);
469470
GenerateDeclarationCommon(method);
470471

471472
var functionName = GetMethodIdentifier(method);
472473

473-
Write("{0} {1}(", method.OriginalReturnType, functionName);
474+
Write($"{method.OriginalReturnType} {functionName}(");
474475

475476
Write(FormatMethodParameters(method.Parameters));
476477

477478
WriteLine(");");
478479

479480
PopBlock(NewLineKind.BeforeNextBlock);
480481
}
481-
foreach (var prop in @class.Properties.Where(p => p.IsGenerated && p.Access == AccessSpecifier.Public))
482+
foreach (var prop in @class.Properties.Where(p => p.IsGenerated &&
483+
(p.GetMethod == null || p.GetMethod.OriginalFunction == null ||
484+
!p.GetMethod.OriginalFunction.Ignore) &&
485+
(p.SetMethod == null || p.SetMethod.OriginalFunction == null ||
486+
!p.SetMethod.OriginalFunction.Ignore) &&
487+
p.Access == AccessSpecifier.Public))
482488
{
483489
PushBlock(BlockKind.Property);
484490
var type = prop.Type;
485491
if (prop.Parameters.Count > 0 && prop.Type.IsPointerToPrimitiveType())
486492
type = ((PointerType) prop.Type).Pointee;
487493
GenerateDeclarationCommon(prop);
488-
Write("{0} {1} {{ ", type, GetPropertyName(prop));
494+
Write($"{type} {GetPropertyName(prop)} {{ ");
489495
if (prop.HasGetter)
490496
Write("get; ");
491497
if (prop.HasSetter)

tests/CSharp/CSharpTemplates.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class DLL_API IndependentFields : public T1
3636
int getIndependent();
3737
const T* returnTakeDependentPointer(const T* p);
3838
T getDependent(const T& t);
39+
const T* propertyReturnDependentPointer();
3940
static T staticDependent(const T& t);
4041
template <typename AdditionalDependentType>
4142
void usesAdditionalDependentType(AdditionalDependentType additionalDependentType);
@@ -91,6 +92,12 @@ T IndependentFields<T>::getDependent(const T& t)
9192
return t;
9293
}
9394

95+
template <typename T>
96+
const T* IndependentFields<T>::propertyReturnDependentPointer()
97+
{
98+
return 0;
99+
}
100+
94101
template <typename T>
95102
T IndependentFields<T>::staticDependent(const T& t)
96103
{
@@ -425,7 +432,7 @@ class DLL_API HasVirtualTemplate
425432
HasDefaultTemplateArgument<bool, bool> explicitSpecialization;
426433
};
427434

428-
class DLL_API HasSpecializationForSecondaryBase : T1, DependentValueFields<int>
435+
class DLL_API HasSpecializationForSecondaryBase : T1, DependentValueFields<int>, IndependentFields<int>
429436
{
430437
public:
431438
HasSpecializationForSecondaryBase();

0 commit comments

Comments
 (0)