Skip to content

Commit

Permalink
ignore deprecated properties in csharp
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude committed Aug 8, 2023
1 parent c3e7e36 commit b20ee8e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,13 @@ fun QueryParameter.methodName(): String {
}
return "With" + StringCaseFormat.UPPER_CAMEL_CASE.apply(this.name.replace(".", "-"))
}

fun Property.deprecated() : Boolean {
val anno = this.getAnnotation("deprecated")
if (anno != null) {
return (anno.value as BooleanInstance).value
}
val typeAnno = this.type.getAnnotation("deprecated")
return (typeAnno != null && (typeAnno.value as BooleanInstance).value)
}

Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,4 @@ class CsharpModelInterfaceRenderer constructor(override val vrapTypeProvider: Vr
|[DeserializeAs(typeof(${vrapType.`package`.toCsharpPackage()}.${this.objectClassName()}))]
""".trimMargin()
}

private fun Property.deprecated() : Boolean {
val anno = this.getAnnotation("deprecated")
return (anno != null && (anno.value as BooleanInstance).value)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class CsharpObjectTypeRenderer constructor(override val vrapTypeProvider: VrapTy
}

private fun ObjectType.toProperties() : String = this.allProperties
.filterNot { it.deprecated() }
.filterNot { property -> property.isPatternProperty() }
.map { it.toCsharpProperty(this) }.joinToString(separator = "\n\n")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CsharpQueryPredicateRenderer constructor(val basePackage: String, override
| return new ${vrapType.builderDslName()}();
| }
|
| <${type.allProperties.filterNot { it.isPatternProperty() }.joinToString("\n") { it.toBuilderDsl(type) }}>
| <${type.allProperties.filterNot { it.deprecated() }.filterNot { it.isPatternProperty() }.joinToString("\n") { it.toBuilderDsl(type) }}>
|
| <${type.namedSubTypes().filterIsInstance<ObjectType>().joinToString("\n") { it.toBuilderDsl("As${it.subtypeName()}", vrapType) }}>
| }
Expand Down

0 comments on commit b20ee8e

Please sign in to comment.