summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/ProductionTransforms/FixScriptSharp.xsl
blob: a30310ddb6daf70d6e9ea210dda749751100d71d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">

	<xsl:output indent="yes" encoding="UTF-8" />

	<xsl:template match="node() | @*">
		<xsl:copy>
			<xsl:apply-templates select="node() | @*" />
		</xsl:copy>
	</xsl:template>

	<!-- Fix subgroups for enumerations -->
	<xsl:template match="reflection/apis/api[apidata/@group='type' and family/ancestors/type/@api='T:System.Enum']/apidata/@subgroup">
		<xsl:attribute name="subgroup">
			<xsl:value-of select="'enumeration'"/>
		</xsl:attribute>
	</xsl:template>

	<!-- Strip ancestors from enumerations -->
	<xsl:template match="reflection/apis/api[apidata/@group='type' and family/ancestors/type/@api='T:System.Enum']/family">
	</xsl:template>

	<!-- Strip invalid members from enumerations -->
	<xsl:template match="reflection/apis/api[apidata/@group='type' and family/ancestors/type/@api='T:System.Enum']/elements">
		<elements>
			<xsl:for-each select="element">
				<xsl:if test="(starts-with(@api, 'F:') and not(contains(@api, 'value__')))">
					<xsl:copy>
						<xsl:apply-templates select="node() | @*" />
					</xsl:copy>
				</xsl:if>
			</xsl:for-each>
		</elements>
	</xsl:template>

	<!-- Fix subgroups for enumerations -->
	<xsl:template match="reflection/apis/api[apidata/@group='type' and family/ancestors/type/@api='T:System.MulticastDelegate']/apidata/@subgroup">
		<xsl:attribute name="subgroup">
			<xsl:value-of select="'delegate'"/>
		</xsl:attribute>
	</xsl:template>

	<!-- Strip ancestors from delegates -->
	<xsl:template match="reflection/apis/api[apidata/@group='type' and family/ancestors/type/@api='T:System.MulticastDelegate']/family">
	</xsl:template>

	<!-- Strip elements from delegates -->
	<xsl:template match="reflection/apis/api[apidata/@group='type' and family/ancestors/type/@api='T:System.MulticastDelegate']/elements">
	</xsl:template>

	<!-- Insert parameters into delegates -->
	<xsl:template match="reflection/apis/api[apidata/@group='type' and family/ancestors/type/@api='T:System.MulticastDelegate']/apidata">
		<xsl:copy>
			<xsl:apply-templates select="node() | @*" />
		</xsl:copy>
		<xsl:variable name="id" select="../@id" />
		<xsl:copy-of select="/reflection/apis/api[starts-with(@id, concat('M:', substring-after($id, 'T:'), '.Invoke('))]/parameters">
		</xsl:copy-of>
	</xsl:template>

	<!-- Annotate members whose types have the GlobalMethodsAttribute -->
	<xsl:template match="reflection/apis/api[apidata/@group='member']/apidata/@name">
			<xsl:copy>
				<xsl:apply-templates select="node() | @*" />
			</xsl:copy>
			<xsl:variable name="type" select="../../containers/type/@api" />
			<xsl:if test="/reflection/apis/api[@id=$type]/attributes/attribute/type/@api='T:System.GlobalMethodsAttribute'">
				<xsl:attribute name="global">
					<xsl:value-of select="'true'"/>
				</xsl:attribute>
			</xsl:if>
	</xsl:template>

	<!-- Annotate constructors whose types have the RecordAttribute -->
	<xsl:template match="reflection/apis/api[apidata/@group='member']/apidata[@subgroup='constructor']/@subgroup">
			<xsl:copy>
				<xsl:apply-templates select="node() | @*" />
			</xsl:copy>
			<xsl:variable name="type" select="../../containers/type/@api" />
			<xsl:if test="/reflection/apis/api[@id=$type]/attributes/attribute/type/@api='T:System.RecordAttribute'">
				<xsl:attribute name="record">
					<xsl:value-of select="'true'"/>
				</xsl:attribute>
			</xsl:if>
	</xsl:template>

</xsl:stylesheet>