Skip to content

Commit

Permalink
renamed 'display-text-member' to 'text-member'
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtoroq committed May 24, 2022
1 parent 0391d6b commit 2eee632
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 6 deletions.
2 changes: 1 addition & 1 deletion schemas/xcst.rng
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@
<ann:documentation>Specifies if an empty string is a valid value for this member.</ann:documentation>
<ref name="boolean"/>
</attribute>
<attribute name="display-text-member" docs:attrib-group="Presentation">
<attribute name="text-member" docs:attrib-group="Presentation">
<ann:documentation>The name of the member to use as the text representation for this type.</ann:documentation>
<ref name="identifier"/>
</attribute>
Expand Down
2 changes: 1 addition & 1 deletion schemas/xcst.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@
<xs:documentation>Specifies if an empty string is a valid value for this member.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="display-text-member" type="c:identifier">
<xs:attribute name="text-member" type="c:identifier">
<xs:annotation>
<xs:documentation>The name of the member to use as the text representation for this type.</xs:documentation>
</xs:annotation>
Expand Down
20 changes: 16 additions & 4 deletions src/Xcst.Compiler/CodeGeneration/_types.xcst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"data-type-message", "required-message", "min-length-message", "max-length-message", "pattern-message",
"range-message", "equal-to-message" }' as='string[]'/>

<variable name='xcst_type_or_member_attributes' value='new[] { "allow-empty-string", "display-text-member" }' as='string[]'/>
<variable name='xcst_type_or_member_attributes' value='new[] { "allow-empty-string", "text-member" }' as='string[]'/>

<template match='XElement el &amp;&amp; el.Name == c + "type"' mode='xcst:validate-top-level'/>

Expand Down Expand Up @@ -389,7 +389,7 @@
<param name='el' as='XElement' required='yes'/>

<apply-templates value='attributes(el)
.Where(p => p.Name == "display-text-member")' mode='src:attribute'/>
.Where(p => p.Name == "text-member")' mode='src:attribute'/>
</template>

<template name='src:member-attributes'>
Expand Down Expand Up @@ -625,15 +625,27 @@
</code:attribute>
</template>

<template match='XAttribute attr &amp;&amp; attr.Name == "display-text-member"' mode='src:attribute'>
<template match='XAttribute attr &amp;&amp; attr.Name == "text-member"' mode='src:attribute'>
<param name='language' as='string' tunnel='yes' required='yes'/>

<variable name='name' value='xcst_name(attr)'/>

<if test='!attr.Parent!.Elements(c + "member")
.Any(p => p.Attribute("name") is XAttribute nameAttr
&amp;&amp; xcst_unescape_identifier(xcst_name(nameAttr), language) == name)'>
<message terminate='yes' error-data='src_error_object(attr)' transform-text='trim'>
Unknown member specified in 'text-member'.
</message>
</if>

<code:attribute>
<call-template name='src:line-number'>
<with-param name='el' value='attr.Parent!'/>
</call-template>
<code:type-reference name='DisplayColumn' namespace='System.ComponentModel.DataAnnotations'/>
<code:arguments>
<code:string literal='true'>
<value-of value='xcst_name(attr)'/>
<value-of value='name'/>
</code:string>
</code:arguments>
</code:attribute>
Expand Down
10 changes: 10 additions & 0 deletions tests/Xcst.Tests/Types/Member/TextMemberUnknown.i.xcst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<c:module version='1.0' language='C#' xmlns:c='http://maxtoroq.github.io/XCST'>

<c:type name='Foo'>
<c:member name='bar' text-member='abc'>
<c:member name='baz'/>
</c:member>
</c:type>

</c:module>
10 changes: 10 additions & 0 deletions tests/Xcst.Tests/Types/Member/TextMemberVerbatim.c.xcst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<c:module version='1.0' language='C#' xmlns:c='http://maxtoroq.github.io/XCST'>

<c:type name='Foo'>
<c:member name='bar' text-member='class'>
<c:member name='@class'/>
</c:member>
</c:type>

</c:module>
10 changes: 10 additions & 0 deletions tests/Xcst.Tests/Types/Member/member.text-member.type.i.xcst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<c:module version='1.0' language='C#' xmlns:c='http://maxtoroq.github.io/XCST'>

<c:type name='Foo'>
<c:member name='bar' text-member=''>
<c:member name='baz'/>
</c:member>
</c:type>

</c:module>
8 changes: 8 additions & 0 deletions tests/Xcst.Tests/Types/TextMemberUnknown.i.xcst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<c:module version='1.0' language='C#' xmlns:c='http://maxtoroq.github.io/XCST'>

<c:type name='Foo' text-member='abc'>
<c:member name='bar'/>
</c:type>

</c:module>
8 changes: 8 additions & 0 deletions tests/Xcst.Tests/Types/TextMemberVerbatim.c.xcst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<c:module version='1.0' language='C#' xmlns:c='http://maxtoroq.github.io/XCST'>

<c:type name='Foo' text-member='class'>
<c:member name='@class'/>
</c:type>

</c:module>
8 changes: 8 additions & 0 deletions tests/Xcst.Tests/Types/type.text-member.type.i.xcst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<c:module version='1.0' language='C#' xmlns:c='http://maxtoroq.github.io/XCST'>

<c:type name='Foo' text-member=''>
<c:member name='bar'/>
</c:type>

</c:module>

0 comments on commit 2eee632

Please sign in to comment.