srcML v1.0.0 C# Documentation

Base Elements XML Element Subelements
comment <comment type="line|block">
<comment type="line" format="doxygen">
<comment type="block" format="doxygen">
literal <literal type="boolean|char|null|number|string">
escape <escape char="0xXX">
name <name>
Statements XML Element Subelements
block <block> <block_content>
break statement <break>
case statement <case> <expr>
continue statement <continue>
default statement <default>
do while statement <do> <block>,<condition>
empty statement <empty_stmt>
expression statement <expr_stmt> <expr>
fixed statement <fixed> <init>,<block>
for statement <for> <control>,<block>
foreach statement <foreach> <control>,<block>
goto statement <goto> <name>
if statement <if_stmt> <if>,<if type="elseif">,<else>
label statement <label> <name>
lock statement <lock> <init>,<block>
pseudo block <block type="pseudo"> <block_content>
return statement <return> <expr>
switch statement <switch> <condition>,<block>,<case>,<default>
unsafe statement <unsafe> <block>
using statement <using_stmt> <init>,<block>
while statement <while> <condition>,<block>
Statement Subelements XML Element Subelements
block content <block_content>
condition <condition> <expr>
control <control> <init>,<condition>,<incr>
else <else> <block>
else if <if type="elseif"> <condition>,<block>
expression <expr> <name>,<operator>,<call>,<ternary>
if <if> <condition>,<block>
incr <incr> <expr>
then <then> <expr>
type <type> <specifier>,<name>
Specifiers XML Element Subelements
async <specifier>async</specifier>
const <specifier>const</specifier>
explicit <specifier>explicit</specifier>
extern specifier <specifier>extern</specifier>
implicit <specifier>implicit</specifier>
internal <specifier>internal</specifier>
new specifier <specifier>new</specifier>
out (output parameter) <modifier>out</modifier>
override <specifier>override</specifier>
params <specifier>params</specifier>
partial <specifier>partial</specifier>
private <specifier>private</specifier>
protected <specifier>protected</specifier>
public <specifier>public</specifier>
readonly <specifier>readonly</specifier>
ref <modifier>ref</modifier>
sealed <specifier>sealed</specifier>
stackalloc <operator>stackalloc</operator>
static <specifier>static</specifier>
this specifier <specifier>this</specifier>
virtual <specifier>virtual</specifier>
volatile <specifier>volatile</specifier>
yield <specifier>yield</specifier>
Declarations, Definitions, and Initializations XML Element Subelements
default parameters <init> <expr>
delegate type definition <delegate> <type>,<name>,<parameter_list>
extern alias <extern> <specifier>,<name>
function <function> <type>,<name>,<parameter_list>,<block>
function declaration <function_decl> <type>,<name>,<parameter_list>
indexer property <parameter_list type="indexer"> <type>,<name>,<block>
lambda <lambda> <parameter_list>,<block>
namespace <namespace> <name>,<block>
operator overloading <function type="operator"> <type>,<name>,<parameter_list>,<block>
pointer declaration <modifier>*</modifier>
using directive <using> <name>,<init>
variable declaration <decl> <name>,<init>,<index>,<type>
variable declaration statement <decl_stmt> <decl>
Classes, Structs, Interfaces, and Enums XML Element Subelements
base constructor selection <name>base</name>
class <class> <name>,<super_list>,<super>,<block>
constructor <constructor> <name>,<parameter_list>,<specifier>,<block>
destructor <destructor> <specifier>,<name>,<parameter_list>,<block>
enum <enum> <name>,<block>
event <event> <type>,<name>,<block>
inheritance list <super_list> <super>
interface <interface> <name>,<super>,<block>,<super_list>
property <property> <type>,<name>,<block>
struct <struct> <name>,<super_list>,<block>
Expressions XML Element Subelements
base object <name>base</name>
function call <call> <name>,<argument_list>
new operator <operator>new</operator>
operator <operator>
ternary operator <ternary> <condition>,<then>,<else>
this <name>this</name>
Other XML Element Subelements
attribute <attribute> <expr>
cast <operator> <name>
checked <checked> <block>
default object construction <default> <argument_list>
dynamic <name>dynamic</name>
global <name>global</name>
object <name>object</name>
sizeof <sizeof> <argument_list>
string <name>string</name>
typeof <typeof> <argument_list>
unchecked <unchecked> <block>
var <name>var</name>
Generics XML Element Subelements
class constraint <constraint>class</constraint>
in generic parameter constraint <specifier>in</specifier>
new constraint <constraint>new</constraint>
out generic parameter constraint <specifier>out</specifier>
struct constraint <constraint>struct</constraint>
where constraint <constraint>where</constraint> <name>,<constraint>
Exceptions XML Element Subelements
catch <catch> <parameter_list>,<block>
finally <finally> <block>
throw <throw> <expr>
try <try> <block>,<catch>,<member_init_list>
LINQ XML Element Subelements
by <by>
equals <equals>
from <from> <expr>,<in>
group <group> <by>,<into>
in <in> <expr>
into <into>
join <join> <in>,<on>,<equals>,<into>
let <let> <expr>
linq <linq> <from>,<where>,<let>,<orderby>,<select>,<group>,<join>
on <on>
orderby <orderby> <expr>,<name>
select <select> <expr>
where (clause) <where> <expr>
C# Preprocessor XML Element Subelements
#define <cpp:define> <cpp:directive>,<cpp:macro>
#elif <cpp:elif> <cpp:directive>,<expr>
#else <cpp:else> <cpp:directive>
#endif <cpp:endif> <cpp:directive>
#endregion <cpp:endregion> <cpp:directive>
#error <cpp:error> <cpp:directive>
#if <cpp:if> <cpp:directive>,<expr>
#line <cpp:line> <cpp:directive>,<cpp:number>,<cpp:file>
#pragma <cpp:pragma> <cpp:directive>,<name>
#region <cpp:region> <cpp:directive>,<name>
#undef <cpp:undef> <cpp:directive>,<name>
#warning <cpp:warning> <cpp:directive>

line comment


Element

  • <comment type="line">

XPath Queries

  • comments

    //src:comment
  • line comments

    //src:comment[@type='line']

Example

// line
<comment type="line">// line</comment>

block comment


Element

  • <comment type="block">

XPath Queries

  • comments

    //src:comment
  • block comments

    //src:comment[@type='block']

Example

/*
    block
*/
<comment type="block">/*
    block
*/</comment>

doxygen line comment


Element

  • <comment type="line" format="doxygen">

XPath Queries

  • comments

    //src:comment
  • doxygen comments

    //src:comment[@format='doxygen']

doxygen block comment


Element

  • <comment type="block" format="doxygen">

XPath Queries

  • comments

    //src:comment
  • doxygen comments

    //src:comment[@format='doxygen']

Example

/**
 * doxygen comment
 */
/*!
 * text
 */
<comment type="block" format="doxygen">/**
 * doxygen comment
 */</comment>
<comment type="block" format="doxygen">/*!
 * text
 */</comment>

number literal


Element

  • <literal type="number">

XPath Query

  • number literals

    //src:literal[@type='number']

character literal


Element

  • <literal type="char">

XPath Query

  • character literals

    //src:literal[@type='char']

string literal


Element

  • <literal type="string">

XPath Query

  • string literals

    //src:literal[@type='string']

Examples

regular string literal

string fruit = "apple";
<decl_stmt><decl><type><name>string</name></type> <name>fruit</name> <init>= <expr><literal type="string">"apple"</literal></expr></init></decl>;</decl_stmt>

verbatim string literal

string fruit = @"apple";
<decl_stmt><decl><type><name>string</name></type> <name>fruit</name> <init>= <expr><literal type="string">@"apple"</literal></expr></init></decl>;</decl_stmt>

raw string literal - single line

string fruit = """apple""";
<decl_stmt><decl><type><name>string</name></type> <name>fruit</name> <init>= <expr><literal type="string">"""</literal><name>apple</name><literal type="string">"""</literal></expr></init></decl>;</decl_stmt>

raw string literal - multiple lines

string fruits = """
apple
banana
orange
mango
""";
<decl_stmt><decl><type><name>string</name></type> <name>fruits</name> <init>= <expr><literal type="string">"""</literal>
<name>apple</name>
<name>banana</name>
<name>orange</name>
<name>mango</name>
<literal type="string">"""</literal></expr></init></decl>;</decl_stmt>

interpolated string

var fruits = (favorite: "apple", worst: "kiwi");
string favoriteFruit = $"{fruits.favorite} is my favorite fruit.";
<decl_stmt><decl><type><name>var</name></type> <name>fruits</name> <init>= <expr><operator>(</operator><name>favorite</name><operator>:</operator> <literal type="string">"apple"</literal>, <name>worst</name><operator>:</operator> <literal type="string">"kiwi"</literal><operator>)</operator></expr></init></decl>;</decl_stmt>
<decl_stmt><decl><type><name>string</name></type> <name>favoriteFruit</name> <init>= <expr><name>$</name><literal type="string">"{fruits.favorite} is my favorite fruit."</literal></expr></init></decl>;</decl_stmt>

boolean literal


Element

  • <literal type="boolean">

XPath Query

  • boolean literals

    //src:literal[@type='boolean']

null literal


Element

  • <literal type="null">

XPath Query

  • null literals

    //src:literal[@type='null']

if statement


Element

  • <if_stmt>

Subelements

  • <if>
  • <if type="elseif">
  • <else>

XPath Queries

  • if conditions

    //src:if/src:condition
  • then

    //src:if/src:block
  • else

    //src:else/src:block
  • if statements without an else

    //src:if_stmt[not(src:else)]
  • else if

    //src:if[@type='elseif']
  • First if in a nested if statement

    //src:if_stmt/src:if[1]
  • Second if in a nested if statement

    //src:if_stmt/src:if[2]
  • Last if in a nested if statement

    //src:if_stmt/src:if[last()]

Examples

if then

if (A)
    B;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if></if_stmt>

if then else

if (A)
    B;
else
    C;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

if then elseif

if (A)
    B;
else if (A2)
    C;
else
    D:
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<if type="elseif">else if <condition>(<expr><name>A2</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <label><name>D</name>:</label></block_content></block></else></if_stmt>
if(x > 5)
    y+=4;
<if_stmt><if>if<condition>(<expr><name>x</name> <operator>&gt;</operator> <literal type="number">5</literal></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name><operator>+=</operator><literal type="number">4</literal></expr>;</expr_stmt></block_content></block></if></if_stmt>
if ( i > 0 ) {
    y = x / i;
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt>
</block_content>}</block></if></if_stmt>
if ( i > 0 )
    y = x / i;
else {
    x = i;
    y = f( x );
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt></block_content></block></if>
<else>else <block>{<block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <call><name>f</name><argument_list>( <argument><expr><name>x</name></expr></argument> )</argument_list></call></expr>;</expr_stmt>
</block_content>}</block></else></if_stmt>

Without braces

if ( i > 0 )
    if ( j > i )
        x = j;
    else
        x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if>
    <else>else<block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt></block_content></block></if></if_stmt>

With braces

if ( i > 0 ) {
    if ( j > i )
        x = j;
}
else
    x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if></if_stmt>
</block_content>}</block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt>
if ( i > 0 ) {
 	x = i;
}
else if( i < 0)
	x = q;
else
    x = j;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
 	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>
</block_content>}</block></if>
<if type="elseif">else if<condition>( <expr><name>i</name> <operator>&lt;</operator> <literal type="number">0</literal></expr>)</condition><block type="pseudo"><block_content>
	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>q</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

while statement


Element

  • <while>

Subelements

  • <condition>
  • <block>

XPath Queries

  • while loops

    //src:while
  • while-loop conditions

    //src:while/src:condition
  • while loops with a condition containing the variable i

    //src:while[src:condition//src:name='i']

for statement


Element

  • <for>

Subelements

  • <control>
  • <block>

XPath Queries

  • for loops

    //src:for
  • for-loop initialization statements

    //src:for/src:control/src:init
  • for-loop conditions

    //src:for/src:control/src:condition
  • for-loop increments

    //src:for/src:control/src:incr
  • for loops that declare a variable with a single character name (e.g. x, i or y)

    //src:for[string-length(src:control/src:init/src:decl/src:name)=1]
  • for loops with post-increment in the increment expression

    //src:for[src:control/src:incr/src:expr//following-sibling::src:operator='++']

Examples

for( ;; ) { }
<for>for<control>( <init>;</init><condition>;</condition> <incr/>)</control> <block>{<block_content> </block_content>}</block></for>
for (i = 0; i < max; i++ ) {
    if ( line[i] == ' ' ) {
        space++;
    }
    if ( line[i] == '\t' ) {
        tab++;
    }
}
<for>for <control>(<init><expr><name>i</name> <operator>=</operator> <literal type="number">0</literal></expr>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <name>max</name></expr>;</condition> <incr><expr><name>i</name><operator>++</operator></expr></incr> )</control> <block>{<block_content>
    <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">' '</literal></expr> )</condition> <block>{<block_content>
        <expr_stmt><expr><name>space</name><operator>++</operator></expr>;</expr_stmt>
    </block_content>}</block></if></if_stmt>
    <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">'\t'</literal></expr> )</condition> <block>{<block_content>
        <expr_stmt><expr><name>tab</name><operator>++</operator></expr>;</expr_stmt>
    </block_content>}</block></if></if_stmt>
</block_content>}</block></for>
for (int i = 0; i < 10; ++i)
    a += x[i];
<for>for <control>(<init><decl><type><name>int</name></type> <name>i</name> <init>= <expr><literal type="number">0</literal></expr></init></decl>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <literal type="number">10</literal></expr>;</condition> <incr><expr><operator>++</operator><name>i</name></expr></incr>)</control><block type="pseudo"><block_content>
    <expr_stmt><expr><name>a</name> <operator>+=</operator> <name><name>x</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt></block_content></block></for>

Empty for statement

for (auto  p = v.begin(); p != v.end() && *p != 0; ++p)
    ;
<for>for <control>(<init><decl><type><name>auto</name></type>  <name>p</name> <init>= <expr><call><name><name>v</name><operator>.</operator><name>begin</name></name><argument_list>()</argument_list></call></expr></init></decl>;</init> <condition><expr><name>p</name> <operator>!=</operator> <call><name><name>v</name><operator>.</operator><name>end</name></name><argument_list>()</argument_list></call> <operator>&amp;&amp;</operator> <operator>*</operator><name>p</name> <operator>!=</operator> <literal type="number">0</literal></expr>;</condition> <incr><expr><operator>++</operator><name>p</name></expr></incr>)</control><block type="pseudo"><block_content>
    <empty_stmt>;</empty_stmt></block_content></block></for>

return statement


Element

  • <return>

Subelement

  • <expr>

XPath Queries

  • return statements

    //src:return
  • return expressions

    //src:return/src:expr
  • return statements that return true

    //src:return[src:expr='true']
  • functions with more then one return

    //src:function[count(.//src:return)>1]

switch statement


Element

  • <switch>

Subelements

  • <condition>
  • <block>
  • <case>
  • <default>

XPath Queries

  • switch statements

    //src:switch
  • switch-statement conditions

    //src:switch/src:condition

case statement


Element

  • <case>

Subelement

  • <expr>

XPath Queries

  • case labels

    //src:case
  • case labels that use SATURDAY

    //src:case[.//src:name='SATURDAY']
  • switch statements with a case that uses SATURDAY

    //src:switch[src:block/src:block_content/src:case//src:name='SATURDAY']

Examples

case x:
<case>case <expr><name>x</name></expr>:</case>
case SATURDAY:
<case>case <expr><name>SATURDAY</name></expr>:</case>

default statement


Element

  • <default>

XPath Queries

  • default labels

    //src:default
  • switch statements with a default label

    //src:switch[src:block/src:block_content/src:default]

Example

default:
<default>default:</default>

block


Element

  • <block>

Subelement

  • <block_content>

XPath Queries

  • blocks

    //src:block
  • variable declarations in a block

    //src:block//src:decl_stmt
  • top-level variable declarations in a block

    //src:block/src:block_content/src:decl_stmt

pseudo block


Element

  • <block type="pseudo">

Subelement

  • <block_content>

XPath Queries

  • all pseudo blocks

    //src:block[@type='pseudo']
  • all non pseudo blocks

    //src:block[not(@type='pseudo')]
  • variable declarations in a pseudo block

    //src:block[@type='pseudo']//src:decl_stmt
  • top-level variable declarations in a pseudo block

    //src:block[@type='pseudo']/src:block_content/src:decl_stmt

expression statement


Element

  • <expr_stmt>

Subelement

  • <expr>

XPath Query

  • expression statements

    //src:expr_stmt

label statement


Element

  • <label>

Subelement

  • <name>

XPath Queries

  • labels

    //src:label
  • label names

    //src:label/src:name
  • labels with a goto statement

    //src:label[src:name=//src:goto/src:name]
  • labels without a goto statement

    //src:label[not(src:name[.=//src:goto/src:name])]

Example

stop:
<label><name>stop</name>:</label>

goto statement


Element

  • <goto>

Subelement

  • <name>

XPath Query

  • goto statements

    //src:goto

Examples

goto stop;
<goto>goto <name>stop</name>;</goto>
goto case 1;
<goto>goto <name>case <literal type="number">1</literal></name>;</goto>
goto default;
<goto>goto default;</goto>

empty statement


Element

  • <empty_stmt>

XPath Query

  • empty statements

    //src:empty_stmt

lock statement


Element

  • <lock>

Subelements

  • <init>
  • <block>

XPath Query

  • lock statements

    //src:lock

using statement


Element

  • <using_stmt>

Subelements

  • <init>
  • <block>

XPath Queries

  • using statements

    //src:using_stmt
  • using statements with a StreamReader variable

    //src:using_stmt[src:init/src:decl/src:type/src:name='StreamReader']

unsafe statement


Element

  • <unsafe>

Subelement

  • <block>

XPath Query

  • unsafe statements

    //src:unsafe

condition


Element

  • <condition>

Subelement

  • <expr>

XPath Queries

  • conditions, including ternary conditions

    //src:condition
  • condition expressions

    //src:condition/src:expr
  • if conditions

    //src:if/src:condition
  • while conditions

    //src:while/src:condition
  • do while conditions

    //src:do/src:condition
  • ternary conditions

    //src:ternary/src:condition

block content


Element

  • <block_content>

XPath Queries

  • block contents

    //src:block_content
  • declaration block_contents

    //src:decl/src:block/src:block_content
  • function block_contents

    //src:function/src:block/src:block_content

expression


Element

  • <expr>

Subelements

  • <name>
  • <operator>
  • <call>
  • <ternary>

XPath Queries

  • expressions

    //src:expr
  • array indexes

    //src:index
  • array index expressions

    //src:index/src:expr
  • expressions that contain an anonymous class

    //src:expr[src:operator[.='new']/following-sibling::src:block]

Examples

a + b
<expr><name>a</name> <operator>+</operator> <name>b</name></expr>
Console.WriteLine("out");
<expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"out"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
a ? x : y;
<expr_stmt><expr><ternary><condition><expr><name>a</name></expr> ?</condition><then> <expr><name>x</name></expr> </then><else>: <expr><name>y</name></expr></else></ternary></expr>;</expr_stmt>

array index

Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length);
<expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"Length of row {0} is {1}"</literal></expr></argument>, <argument><expr><name>i</name></expr></argument>, <argument><expr><name><name>scores</name><index>[<expr><name>i</name></expr>]</index></name><operator>.</operator><name>Length</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>
numbers[1, 1] = 5;
<expr_stmt><expr><name><name>numbers</name><index>[<expr><literal type="number">1</literal></expr>, <expr><literal type="number">1</literal></expr>]</index></name> <operator>=</operator> <literal type="number">5</literal></expr>;</expr_stmt>
var v = new { Amount = 108, Message = "Hello" };
<decl_stmt><decl><type><name>var</name></type> <name>v</name> <init>= <expr><operator>new</operator> <block>{ <expr><name>Amount</name> <operator>=</operator> <literal type="number">108</literal></expr>, <expr><name>Message</name> <operator>=</operator> <literal type="string">"Hello"</literal></expr> }</block></expr></init></decl>;</decl_stmt>

const


Element

  • <specifier>const</specifier>

XPath Query

  • const variables

    //src:decl[src:type/src:specifier='const']

static


Element

  • <specifier>static</specifier>

XPath Queries

  • static classes

    //src:class[src:specifier='static']
  • static function

    //src:function[src:type/src:specifier='static']
  • static fields

    //src:decl_stmt[src:decl/src:type/src:specifier='static']
  • static events

    //src:event[src:type/src:specifier='static']
  • static properties

    //src:property[src:type/src:specifier='static']
  • static constructors

    //src:constructor[src:specifier='static']

readonly


Element

  • <specifier>readonly</specifier>

XPath Query

  • readonly variables

    //src:decl[src:type/src:specifier='readonly']

volatile


Element

  • <specifier>volatile</specifier>

XPath Query

  • volatile variables

    //src:decl[src:type/src:specifier='volatile']

extern specifier


Element

  • <specifier>extern</specifier>

XPath Query

  • extern functions declarations

    //src:function_decl[src:type/src:specifier='extern']

private


Element

  • <specifier>private</specifier>

XPath Queries

  • private methods

    //src:function[src:type/src:specifier='private']
  • private properties

    //src:property[src:type/src:specifier='private']

protected


Element

  • <specifier>protected</specifier>

XPath Queries

  • protected methods

    //src:function[src:type/src:specifier='protected']
  • protected properties

    //src:property[src:type/src:specifier='protected']
  • protected internal fields

    //src:decl_stmt[src:decl[not(src:block)]/src:type[src:specifier='protected'][src:specifier='internal']]

internal


Element

  • <specifier>internal</specifier>

XPath Queries

  • internal classes

    //src:class[src:specifier='internal']
  • protected internal fields

    //src:decl_stmt[src:decl[not(src:block)]/src:type[src:specifier='protected'][src:specifier='internal']]

public


Element

  • <specifier>public</specifier>

XPath Queries

  • public classes

    //src:class[src:specifier='public']
  • public methods

    //src:function[src:type/src:specifier='public']
  • public properties

    //src:property[src:type/src:specifier='public']

ref


Element

  • <modifier>ref</modifier>

XPath Query

  • functions with ref parameters

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:modifier='ref']

params


Element

  • <specifier>params</specifier>

XPath Query

  • functions with a variable number of arguments

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:specifier='params']

virtual


Element

  • <specifier>virtual</specifier>

XPath Query

  • virtual functions

    //src:function[src:type/src:specifier='virtual']

override


Element

  • <specifier>override</specifier>

XPath Query

  • overridden functions

    //src:function[src:type/src:specifier='override']

new specifier


Element

  • <specifier>new</specifier>

XPath Query

  • functions which hide a previous implementation using new

    //src:function[src:type/src:specifier='new']

stackalloc


Element

  • <operator>stackalloc</operator>

XPath Query

  • expressions which call stackalloc

    //src:expr[.//src:operator='stackalloc']

sealed


Element

  • <specifier>sealed</specifier>

XPath Queries

  • sealed classes

    //src:class[src:specifier='sealed']
  • sealed methods

    //src:function[src:type/src:specifier='sealed']

async


Element

  • <specifier>async</specifier>

XPath Queries

  • async methods in declaration

    //src:function_decl[src:type/src:specifier='async']
  • async methods in definition

    //src:function[src:type/src:specifier='async']

partial


Element

  • <specifier>partial</specifier>

XPath Queries

  • partial classes

    //src:class[src:specifier='partial']
  • partial functions

    //src:function[src:type/src:specifier='partial']
  • partial function declarations

    //src:function_decl[src:type/src:specifier='partial']

explicit


Element

  • <specifier>explicit</specifier>

XPath Query

  • explicit conversion operators

    //src:function[src:type/src:specifier='explicit']

implicit


Element

  • <specifier>implicit</specifier>

XPath Query

  • implicit conversion operators

    //src:function[src:type/src:specifier='implicit']

yield


Element

  • <specifier>yield</specifier>

XPath Queries

  • yield statements

    //src:specifier[.='yield']
  • yield-return statements

    //src:return[src:specifier='yield']
  • yield-break statements

    //src:break[src:specifier='yield']

Examples

yield return result;
<return><specifier>yield</specifier> return <expr><name>result</name></expr>;</return>
yield break;
<break><specifier>yield</specifier> break;</break>

this specifier


Element

  • <specifier>this</specifier>

XPath Query

  • extension methods

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:specifier='this']

variable declaration


Element

  • <decl>

Subelements

  • <name>
  • <init>
  • <index>
  • <type>

XPath Queries

  • variable declarations

    //src:decl
  • variable declarations with an initialization

    //src:decl[src:init]
  • explicit array declarations

    //src:decl[src:type/src:name/src:index]
  • nullable variable declarations

    //src:decl[src:type/src:modifier='?']
  • declarations of generic variables

    //src:decl[src:type/src:name/src:argument_list]
  • object initializations, this excludes array initialization

    //src:decl[src:init/src:expr/src:block]

Examples

int myInt;
<decl_stmt><decl><type><name>int</name></type> <name>myInt</name></decl>;</decl_stmt>
List<T> l = new List<T>();
<decl_stmt><decl><type><name><name>List</name><argument_list type="generic">&lt;<argument><name>T</name></argument>&gt;</argument_list></name></type> <name>l</name> <init>= <expr><operator>new</operator> <call><name><name>List</name><argument_list type="generic">&lt;<argument><name>T</name></argument>&gt;</argument_list></name><argument_list>()</argument_list></call></expr></init></decl>;</decl_stmt>
int[] numbers = new int[5];
<decl_stmt><decl><type><name><name>int</name><index>[]</index></name></type> <name>numbers</name> <init>= <expr><operator>new</operator> <name><name>int</name><index>[<expr><literal type="number">5</literal></expr>]</index></name></expr></init></decl>;</decl_stmt>
string[] names = new string[3] {"Matt", "Joanne", "Robert"};
<decl_stmt><decl><type><name><name>string</name><index>[]</index></name></type> <name>names</name> <init>= <expr><operator>new</operator> <name><name>string</name><index>[<expr><literal type="number">3</literal></expr>]</index></name> <block>{<expr><literal type="string">"Matt"</literal></expr>, <expr><literal type="string">"Joanne"</literal></expr>, <expr><literal type="string">"Robert"</literal></expr>}</block></expr></init></decl>;</decl_stmt>
string[,] siblings = new string[2, 2] { {"Mike","Amy"}, {"Mary","Albert"} };
<decl_stmt><decl><type><name><name>string</name><index>[<expr/>,<expr/>]</index></name></type> <name>siblings</name> <init>= <expr><operator>new</operator> <name><name>string</name><index>[<expr><literal type="number">2</literal></expr>, <expr><literal type="number">2</literal></expr>]</index></name> <block>{ <expr><block>{<expr><literal type="string">"Mike"</literal></expr>,<expr><literal type="string">"Amy"</literal></expr>}</block></expr>, <expr><block>{<expr><literal type="string">"Mary"</literal></expr>,<expr><literal type="string">"Albert"</literal></expr>}</block></expr> }</block></expr></init></decl>;</decl_stmt>
int[][] numbers = new int[2][] { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
<decl_stmt><decl><type><name><name>int</name><index>[]</index><index>[]</index></name></type> <name>numbers</name> <init>= <expr><operator>new</operator> <name><name>int</name><index>[<expr><literal type="number">2</literal></expr>]</index><index>[]</index></name> <block>{ <expr><operator>new</operator> <name><name>int</name><index>[]</index></name> <block>{<expr><literal type="number">2</literal></expr>,<expr><literal type="number">3</literal></expr>,<expr><literal type="number">4</literal></expr>}</block></expr>, <expr><operator>new</operator> <name><name>int</name><index>[]</index></name> <block>{<expr><literal type="number">5</literal></expr>,<expr><literal type="number">6</literal></expr>,<expr><literal type="number">7</literal></expr>,<expr><literal type="number">8</literal></expr>,<expr><literal type="number">9</literal></expr>}</block></expr> }</block></expr></init></decl>;</decl_stmt>
int[][] numbers = { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
<decl_stmt><decl><type><name><name>int</name><index>[]</index><index>[]</index></name></type> <name>numbers</name> <init>= <expr><block>{ <expr><operator>new</operator> <name><name>int</name><index>[]</index></name> <block>{<expr><literal type="number">2</literal></expr>,<expr><literal type="number">3</literal></expr>,<expr><literal type="number">4</literal></expr>}</block></expr>, <expr><operator>new</operator> <name><name>int</name><index>[]</index></name> <block>{<expr><literal type="number">5</literal></expr>,<expr><literal type="number">6</literal></expr>,<expr><literal type="number">7</literal></expr>,<expr><literal type="number">8</literal></expr>,<expr><literal type="number">9</literal></expr>}</block></expr> }</block></expr></init></decl>;</decl_stmt>

implicitly typed arrays

var b = new[] { "hello", null, "world" };
<decl_stmt><decl><type><name>var</name></type> <name>b</name> <init>= <expr><operator>new</operator><index>[]</index> <block>{ <expr><literal type="string">"hello"</literal></expr>, <expr><literal type="null">null</literal></expr>, <expr><literal type="string">"world"</literal></expr> }</block></expr></init></decl>;</decl_stmt>
int? i = null;
<decl_stmt><decl><type><name>int</name><modifier>?</modifier></type> <name>i</name> <init>= <expr><literal type="null">null</literal></expr></init></decl>;</decl_stmt>
List<int> x;
<decl_stmt><decl><type><name><name>List</name><argument_list type="generic">&lt;<argument><name>int</name></argument>&gt;</argument_list></name></type> <name>x</name></decl>;</decl_stmt>
Cat cat = new Cat { Age = 10, Name = "Fluffy" };
<decl_stmt><decl><type><name>Cat</name></type> <name>cat</name> <init>= <expr><operator>new</operator> <name>Cat</name> <block>{ <expr><name>Age</name> <operator>=</operator> <literal type="number">10</literal></expr>, <expr><name>Name</name> <operator>=</operator> <literal type="string">"Fluffy"</literal></expr> }</block></expr></init></decl>;</decl_stmt>

function declaration


Element

  • <function_decl>

Subelements

  • <type>
  • <name>
  • <parameter_list>

XPath Queries

  • function declarations

    //src:function_decl
  • function-declaration return types

    //src:function_decl/src:type
  • function-declaration parameters

    //src:function_decl/src:parameter_list/src:parameter
  • function declarations with only two parameters

    //src:function_decl[count(src:parameter_list/src:parameter)=2]
  • function declaration names

    //src:function_decl/src:name
  • function declarations that have variadic arguments

    //src:function_decl[src:parameter_list/src:parameter/src:decl/src:type/src:specifier='params']
  • set definitions with default implementations

    //src:function_decl[src:name='set']
  • get declarations with default implementions

    //src:function_decl[src:name='get']

function


Element

  • <function>

Subelements

  • <type>
  • <name>
  • <parameter_list>
  • <block>

XPath Queries

  • function definitions

    //src:function
  • function-definition return types

    //src:function/src:type
  • function-definition parameters

    //src:function/src:parameter_list/src:parameter
  • function definitions with only two parameters

    //src:function[count(src:parameter_list/src:parameter)=2]
  • generic methods

    //src:function[src:name/src:argument_list]
  • //src:function/src:name
  • remove definitions

    //src:function[src:name='remove']
  • add definitions

    //src:function[src:name='add']
  • set definitions

    //src:function[src:name='set']
  • get functions with their own implementation

    //src:function[src:name='get']

default parameters


Element

  • <init>

Subelement

  • <expr>

XPath Query

  • function declarations with default parameters

    //src:function_decl[src:parameter_list/src:parameter/src:decl/src:init]

delegate type definition


Element

  • <delegate>

Subelements

  • <type>
  • <name>
  • <parameter_list>

XPath Queries

  • delegate definitions

    //src:delegate
  • delegate types

    //src:delegate/src:type
  • delegate name

    //src:delegate/src:name
  • delegate parameters

    //src:delegate/src:parameter_list/src:parameter

namespace


Element

  • <namespace>

Subelements

  • <name>
  • <block>

XPath Query

  • namespaces

    //src:namespace

Example

namespace SampleNamespace {
}
<namespace>namespace <name>SampleNamespace</name> <block>{
}</block></namespace>

using directive


Element

  • <using>

Subelements

  • <name>
  • <init>

XPath Query

  • using directives

    //src:using

extern alias


Element

  • <extern>

Subelements

  • <specifier>
  • <name>

XPath Query

  • external alias declarations

    //src:extern[src:specifier='alias']

Example

extern alias GridV1;
<extern>extern <specifier>alias</specifier> <name>GridV1</name>;</extern>

operator overloading


Element

  • <function type="operator">

Subelements

  • <type>
  • <name>
  • <parameter_list>
  • <block>

XPath Queries

  • operator declarations

    //src:function[@type='operator']
  • implicit conversion operator overloads

    //src:function[@type='operator'][src:type/src:specifier='implicit']
  • explicit conversion operator overloads

    //src:function[@type='operator'][src:type/src:specifier='explicit']
  • true operator overloads

    //src:function[@type='operator'][src:name/src:name='true']
  • false operator overloads

    //src:function[@type='operator'][src:name/src:name='false']

Examples

public static Complex operator +(Complex c1, Complex c2) {
}
<function type="operator"><type><specifier>public</specifier> <specifier>static</specifier> <name>Complex</name></type> <name>operator <name>+</name></name><parameter_list>(<parameter><decl><type><name>Complex</name></type> <name>c1</name></decl></parameter>, <parameter><decl><type><name>Complex</name></type> <name>c2</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
public static implicit operator Digit(double d) {
}
<function type="operator"><type><specifier>public</specifier> <specifier>static</specifier> <specifier>implicit</specifier></type> <name>operator <name>Digit</name></name><parameter_list>(<parameter><decl><type><name>double</name></type> <name>d</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
public static implicit operator double(Digit d) {
}
<function type="operator"><type><specifier>public</specifier> <specifier>static</specifier> <specifier>implicit</specifier></type> <name>operator <name>double</name></name><parameter_list>(<parameter><decl><type><name>Digit</name></type> <name>d</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
public static explicit operator Celsius(Fahrenheit fahr) {
}
<function type="operator"><type><specifier>public</specifier> <specifier>static</specifier> <specifier>explicit</specifier></type> <name>operator <name>Celsius</name></name><parameter_list>(<parameter><decl><type><name>Fahrenheit</name></type> <name>fahr</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
public static bool operator true(DBBool x) {
}
<function type="operator"><type><specifier>public</specifier> <specifier>static</specifier> <name>bool</name></type> <name>operator <name>true</name></name><parameter_list>(<parameter><decl><type><name>DBBool</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
public static bool operator false(DBBool x) {
}
<function type="operator"><type><specifier>public</specifier> <specifier>static</specifier> <name>bool</name></type> <name>operator <name>false</name></name><parameter_list>(<parameter><decl><type><name>DBBool</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content>
</block_content>}</block></function>
set {
    x = value;
}
<function><name>set</name> <block>{<block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>value</name></expr>;</expr_stmt>
</block_content>}</block></function>

indexer property


Element

  • <parameter_list type="indexer">

Subelements

  • <type>
  • <name>
  • <block>

XPath Queries

  • indexer method declarations

    //src:property[src:parameter_list]
  • indexer method declarations with more then one dimension

    //src:property[count(src:parameter_list/src:parameter)>1]

pointer declaration


Element

  • <modifier>*</modifier>

XPath Query

  • of the declarations of pointers

    //src:decl[src:type/src:modifier='*']

class


Element

  • <class>

Subelements

  • <name>
  • <super_list>
  • <super>
  • <block>

XPath Queries

  • class definitions

    //src:class
  • classes with the name foo

    //src:class[src:name='foo']
  • function definitions in classes

    //src:class//src:function
  • function declarations in classes

    //src:class//src:function_decl
  • generic classes

    //src:class[src:name/src:argument_list]

constructor


Element

  • <constructor>

Subelements

  • <name>
  • <parameter_list>
  • <specifier>
  • <block>

XPath Queries

  • constructors

    //src:constructor
  • constructors with no parameters

    //src:constructor[not(src:parameter_list/src:parameter)]
  • possible default constructors, including constructors with all default parameters

    //src:constructor[src:parameter_list[not(src:parameter) or ( count(src:parameter_list/src:parameter)=count(src:parameter_list/src:parameter/src:decl/src:init))]
  • possible copy constructors, including those which are not defined with the body of class and those with default parameters

    //src:constructor[(src:name|src:name/src:name[last()])=(src:parameter_list/src:parameter[1]/src:decl/src:type/src:name|src:parameter_list/src:parameter[1]/src:decl/src:type/src:name[last()])][((count(src:parameter_list/src:parameter)-1)=count(src:parameter_list/src:parameter/src:decl/src:init))]

base constructor selection


Element

  • <name>base</name>

XPath Query

  • constructors which forward to a base classes constructor

    //src:constructor[src:member_list/src:call/src:name='base']

destructor


Element

  • <destructor>

Subelements

  • <specifier>
  • <name>
  • <parameter_list>
  • <block>

XPath Query

  • destructors

    //src:destructor

struct


Element

  • <struct>

Subelements

  • <name>
  • <super_list>
  • <block>

XPath Queries

  • structs

    //src:struct
  • struct members

    //src:struct/src:block/src:decl_stmt

interface


Element

  • <interface>

Subelements

  • <name>
  • <super>
  • <block>
  • <super_list>

XPath Query

  • interfaces

    //src:interface

Examples

interface IInterfaceExample {
}
<interface>interface <name>IInterfaceExample</name> <block>{
}</block></interface>
interface IInterfaceExample :ISortable, IComparable {
}
<interface>interface <name>IInterfaceExample</name> <super_list>:<super><name>ISortable</name></super>, <super><name>IComparable</name></super></super_list> <block>{
}</block></interface>

event


Element

  • <event>

Subelements

  • <type>
  • <name>
  • <block>

XPath Query

  • events

    //src:event

inheritance list


Element

  • <super_list>

Subelement

  • <super>

XPath Queries

  • classes with at least one super class

    //src:class[src:super_list/src:super]
  • classes that inherit from bar

    //src:class[src:super_list/src:super/src:name='bar']

function call


Element

  • <call>

Subelements

  • <name>
  • <argument_list>

XPath Queries

  • function calls

    //src:call
  • function calls with named parameters

    //src:call[src:argument_list/src:argument/src:name]

new operator


Element

  • <operator>new</operator>

XPath Queries

  • expressions which call new

    //src:operator[.='new']
  • expressions which call array new

    //src:expr[src:operator[.='new']/following-sibling::src:name/src:index]

ternary operator


Element

  • <ternary>

Subelements

  • <condition>
  • <then>
  • <else>

XPath Query

  • ternary operators

    //src:ternary

operator


Element

  • <operator>

XPath Queries

  • uses of the -> operator

    //src:operator[.='->']
  • uses of the . operator

    //src:operator[.='.']

base object


Element

  • <name>base</name>

XPath Query

  • uses of base

    //src:name[.='base']

typeof


Element

  • <typeof>

Subelement

  • <argument_list>

XPath Query

  • uses of typeof

    //src:typeof

default object construction


Element

  • <default>

Subelement

  • <argument_list>

XPath Query

  • uses of default to default construct an object

    //src:default[src:argument_list]

checked


Element

  • <checked>

Subelement

  • <block>

XPath Queries

  • uses of checked, in both a statement and expression form

    //src:checked
  • uses of checked when used as an expression

    //src:checked[not(src:block)]
  • uses of the checked statement

    //src:checked[src:block]

unchecked


Element

  • <unchecked>

Subelements

  • <block>

XPath Queries

  • uses of unchecked, in both statement and expression form

    //src:unchecked
  • uses of unchecked used as an expression

    //src:unchecked[not(src:block)]
  • uses of the unchecked statement

    //src:unchecked[src:block]

sizeof


Element

  • <sizeof>

Subelement

  • <argument_list>

XPath Query

  • uses of sizeof

    //src:sizeof

var


Element

  • <name>var</name>

XPath Query

  • var types

    //src:type[src:name='var']

string


Element

  • <name>string</name>

XPath Query

  • uses of the string keyword

    //src:name[.='string']

global


Element

  • <name>global</name>

XPath Query

  • uses of global as part of a complex name

    //src:name[src:name='global']

in generic parameter constraint


Element

  • <specifier>in</specifier>

XPath Query

  • generic parameters constrained with in

    //src:argument[src:specifier='in'][parent::src:argument_list/src:type='template']

out generic parameter constraint


Element

  • <specifier>out</specifier>

XPath Query

  • generic parameters constrained with out

    //src:argument[src:specifier='out'][parent::src:argument_list/src:type='template']

where constraint


Element

  • <constraint>where</constraint>

Subelements

  • <name>
  • <constraint>

XPath Queries

  • constrained generic classes

    //src:class[src:name/src:where]
  • constrained generic methods

    //src:function[src:where]
  • constrained generic delegates

    //src:delegate[src:where]

new constraint


Element

  • <constraint>new</constraint>

XPath Queries

  • uses of the new constraint

    //src:constraint[src:name='new']
  • classes which specify the new constraint

    //src:class[src:where/src:constraint/src:name='new']

class constraint


Element

  • <constraint>class</constraint>

XPath Query

  • classes with a class constraint

    //src:class[src:where/src:constraint.='class']

struct constraint


Element

  • <constraint>struct</constraint>

XPath Query

  • generic methods that specify a struct constraint

    //src:function[src:where/src:constraint.='struct']

finally


Element

  • <finally>

Subelement

  • <block>

XPath Query

  • finally blocks

    //src:finally

throw


Element

  • <throw>

Subelement

  • <expr>

XPath Query

  • uses of throw

    //src:throw

try


Element

  • <try>

Subelements

  • <block>
  • <catch>
  • <member_init_list>

XPath Queries

  • try block

    //src:try
  • try blocks with at least two catch blocks

    //src:try[count(src:catch)>=2]

group


Element

  • <group>

Subelements

  • <by>
  • <into>

XPath Query

  • group clauses

    //src:group

Examples

var studentQuery1 =
    from student in students
    group student by student.Last[0];
<decl_stmt><decl><type><name>var</name></type> <name>studentQuery1</name> <init>=
    <expr><linq><from>from <expr><name>student</name></expr> <in>in <expr><name>students</name></expr></in></from>
    <group>group <expr><name>student</name></expr> <by>by <expr><name><name>student</name><operator>.</operator><name>Last</name><index>[<expr><literal type="number">0</literal></expr>]</index></name></expr></by></group></linq></expr></init></decl>;</decl_stmt>
var studentQuery2 =
    from student in students
    group student by student.Last[0] into g
    orderby g.Key
    select g;
<decl_stmt><decl><type><name>var</name></type> <name>studentQuery2</name> <init>=
    <expr><linq><from>from <expr><name>student</name></expr> <in>in <expr><name>students</name></expr></in></from>
    <group>group <expr><name>student</name></expr> <by>by <expr><name><name>student</name><operator>.</operator><name>Last</name><index>[<expr><literal type="number">0</literal></expr>]</index></name></expr></by> <into>into <expr><name>g</name></expr></into></group>
    <orderby>orderby <expr><name><name>g</name><operator>.</operator><name>Key</name></name></expr></orderby>
    <select>select <expr><name>g</name></expr></select></linq></expr></init></decl>;</decl_stmt>
group student by student.Last[0] into g
<decl><type><name>group</name> <name>student</name> <name>by</name> <name><name>student</name><operator>.</operator><name>Last</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <name>into</name></type> <name>g</name></decl>

orderby


Element

  • <orderby>

Subelements

  • <expr>
  • <name>

XPath Queries

  • orderby clauses

    //src:orderby
  • orderby clauses which sort in descending order

    //src:orderby[src:name='descending']
  • orderby clauses which sort in ascending order

    //src:orderby[src:name='ascending' or not(src:name)]

Examples

IEnumerable<string> sortAscendingQuery =
    from fruit in fruits
    orderby fruit
    select fruit;
<decl_stmt><decl><type><name><name>IEnumerable</name><argument_list type="generic">&lt;<argument><name>string</name></argument>&gt;</argument_list></name></type> <name>sortAscendingQuery</name> <init>=
    <expr><linq><from>from <expr><name>fruit</name></expr> <in>in <expr><name>fruits</name></expr></in></from>
    <orderby>orderby <expr><name>fruit</name></expr></orderby>
    <select>select <expr><name>fruit</name></expr></select></linq></expr></init></decl>;</decl_stmt>
IEnumerable<string> sortDescendingQuery =
    from w in fruits
    orderby w descending 
    select w;
<decl_stmt><decl><type><name><name>IEnumerable</name><argument_list type="generic">&lt;<argument><name>string</name></argument>&gt;</argument_list></name></type> <name>sortDescendingQuery</name> <init>=
    <expr><linq><from>from <expr><name>w</name></expr> <in>in <expr><name>fruits</name></expr></in></from>
    <orderby>orderby <expr><name>w</name></expr> <name>descending</name></orderby> 
    <select>select <expr><name>w</name></expr></select></linq></expr></init></decl>;</decl_stmt>
IEnumerable<string> sortDescendingQuery =
    from w in fruits
    orderby w ascending 
    select w;  
<decl_stmt><decl><type><name><name>IEnumerable</name><argument_list type="generic">&lt;<argument><name>string</name></argument>&gt;</argument_list></name></type> <name>sortDescendingQuery</name> <init>=
    <expr><linq><from>from <expr><name>w</name></expr> <in>in <expr><name>fruits</name></expr></in></from>
    <orderby>orderby <expr><name>w</name></expr> <name>ascending</name></orderby> 
    <select>select <expr><name>w</name></expr></select></linq></expr></init></decl>;</decl_stmt>  

join


Element

  • <join>

Subelements

  • <in>
  • <on>
  • <equals>
  • <into>

XPath Query

  • clauses

    //src:join

Examples

inner join

var innerJoinQuery =
    from category in categories
    join prod in products on category.ID equals prod.CategoryID
    select new { ProductName = prod.Name, Category = category.Name };
<decl_stmt><decl><type><name>var</name></type> <name>innerJoinQuery</name> <init>=
    <expr><linq><from>from <expr><name>category</name></expr> <in>in <expr><name>categories</name></expr></in></from>
    <join>join <expr><name>prod</name></expr> <in>in <expr><name>products</name></expr></in> <on>on <expr><name><name>category</name><operator>.</operator><name>ID</name></name></expr></on> <equals>equals <expr><name><name>prod</name><operator>.</operator><name>CategoryID</name></name></expr></equals></join>
    <select>select <expr><operator>new</operator> <block>{ <expr><name>ProductName</name> <operator>=</operator> <name><name>prod</name><operator>.</operator><name>Name</name></name></expr>, <expr><name>Category</name> <operator>=</operator> <name><name>category</name><operator>.</operator><name>Name</name></name></expr> }</block></expr></select></linq></expr></init></decl>;</decl_stmt>

group join

var innerGroupJoinQuery =
    from category in categories
    join prod in products on category.ID equals prod.CategoryID into prodGroup
    select new { CategoryName = category.Name, Products = prodGroup };
<decl_stmt><decl><type><name>var</name></type> <name>innerGroupJoinQuery</name> <init>=
    <expr><linq><from>from <expr><name>category</name></expr> <in>in <expr><name>categories</name></expr></in></from>
    <join>join <expr><name>prod</name></expr> <in>in <expr><name>products</name></expr></in> <on>on <expr><name><name>category</name><operator>.</operator><name>ID</name></name></expr></on> <equals>equals <expr><name><name>prod</name><operator>.</operator><name>CategoryID</name></name></expr></equals> <into>into <expr><name>prodGroup</name></expr></into></join>
    <select>select <expr><operator>new</operator> <block>{ <expr><name>CategoryName</name> <operator>=</operator> <name><name>category</name><operator>.</operator><name>Name</name></name></expr>, <expr><name>Products</name> <operator>=</operator> <name>prodGroup</name></expr> }</block></expr></select></linq></expr></init></decl>;</decl_stmt>

subquery join

var innerGroupJoinQuery2 =
    from category in categories
    join prod in products on category.ID equals prod.CategoryID into prodGroup
    from prod2 in prodGroup
    where prod2.UnitPrice > 2.50M
    select prod2;
<decl_stmt><decl><type><name>var</name></type> <name>innerGroupJoinQuery2</name> <init>=
    <expr><linq><from>from <expr><name>category</name></expr> <in>in <expr><name>categories</name></expr></in></from>
    <join>join <expr><name>prod</name></expr> <in>in <expr><name>products</name></expr></in> <on>on <expr><name><name>category</name><operator>.</operator><name>ID</name></name></expr></on> <equals>equals <expr><name><name>prod</name><operator>.</operator><name>CategoryID</name></name></expr></equals> <into>into <expr><name>prodGroup</name></expr></into></join>
    <from>from <expr><name>prod2</name></expr> <in>in <expr><name>prodGroup</name></expr></in></from>
    <where>where <expr><name><name>prod2</name><operator>.</operator><name>UnitPrice</name></name> <operator>&gt;</operator> <literal type="number">2.50M</literal></expr></where>
    <select>select <expr><name>prod2</name></expr></select></linq></expr></init></decl>;</decl_stmt>

left outer join

var leftOuterJoinQuery =
    from category in categories
    join prod in products on category.ID equals prod.CategoryID into prodGroup
    from item in prodGroup.DefaultIfEmpty(new Product { Name = String.Empty, CategoryID = 0 })
    select new { CatName = category.Name, ProdName = item.Name };
<decl_stmt><decl><type><name>var</name></type> <name>leftOuterJoinQuery</name> <init>=
    <expr><linq><from>from <expr><name>category</name></expr> <in>in <expr><name>categories</name></expr></in></from>
    <join>join <expr><name>prod</name></expr> <in>in <expr><name>products</name></expr></in> <on>on <expr><name><name>category</name><operator>.</operator><name>ID</name></name></expr></on> <equals>equals <expr><name><name>prod</name><operator>.</operator><name>CategoryID</name></name></expr></equals> <into>into <expr><name>prodGroup</name></expr></into></join>
    <from>from <expr><name>item</name></expr> <in>in <expr><macro><name>prodGroup</name></macro><operator>.</operator><macro><name>DefaultIfEmpty</name><argument_list>(<argument>new Product { Name = String.Empty</argument>, <argument>CategoryID = <literal type="number">0</literal> }</argument>)</argument_list></macro></expr></in></from>
    <select>select <expr><operator>new</operator> <block>{ <expr><name>CatName</name> <operator>=</operator> <name><name>category</name><operator>.</operator><name>Name</name></name></expr>, <expr><name>ProdName</name> <operator>=</operator> <name><name>item</name><operator>.</operator><name>Name</name></name></expr> }</block></expr></select></linq></expr></init></decl>;</decl_stmt>

let


Element

  • <let>

Subelement

  • <expr>

XPath Query

  • let clauses

    //src:let

Example

var earlyBirdQuery =
    from sentence in strings
    let words = sentence.Split(' ')
    from word in words
    let w = word.ToLower()
    where w[0] == 'a' || w[0] == 'e'
        || w[0] == 'i' || w[0] == 'o'
        || w[0] == 'u'
    select word;
<decl_stmt><decl><type><name>var</name></type> <name>earlyBirdQuery</name> <init>=
    <expr><linq><from>from <expr><name>sentence</name></expr> <in>in <expr><name>strings</name></expr></in></from>
    <let>let <expr><name>words</name> <operator>=</operator> <call><name><name>sentence</name><operator>.</operator><name>Split</name></name><argument_list>(<argument><expr><literal type="char">' '</literal></expr></argument>)</argument_list></call></expr></let>
    <from>from <expr><name>word</name></expr> <in>in <expr><name>words</name></expr></in></from>
    <let>let <expr><name>w</name> <operator>=</operator> <call><name><name>word</name><operator>.</operator><name>ToLower</name></name><argument_list>()</argument_list></call></expr></let>
    <where>where <expr><name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'a'</literal> <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'e'</literal>
        <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'i'</literal> <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'o'</literal>
        <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'u'</literal></expr></where>
    <select>select <expr><name>word</name></expr></select></linq></expr></init></decl>;</decl_stmt>

linq


Element

  • <linq>

Subelements

  • <from>
  • <where>
  • <let>
  • <orderby>
  • <select>
  • <group>
  • <join>

XPath Query

  • linq usages

    //src:linq

Examples

var earlyBirdQuery =
    from sentence in strings
    let words = sentence.Split(' ')
    from word in words
    let w = word.ToLower()
    where w[0] == 'a' || w[0] == 'e'
        || w[0] == 'i' || w[0] == 'o'
        || w[0] == 'u'
    select word;
<decl_stmt><decl><type><name>var</name></type> <name>earlyBirdQuery</name> <init>=
    <expr><linq><from>from <expr><name>sentence</name></expr> <in>in <expr><name>strings</name></expr></in></from>
    <let>let <expr><name>words</name> <operator>=</operator> <call><name><name>sentence</name><operator>.</operator><name>Split</name></name><argument_list>(<argument><expr><literal type="char">' '</literal></expr></argument>)</argument_list></call></expr></let>
    <from>from <expr><name>word</name></expr> <in>in <expr><name>words</name></expr></in></from>
    <let>let <expr><name>w</name> <operator>=</operator> <call><name><name>word</name><operator>.</operator><name>ToLower</name></name><argument_list>()</argument_list></call></expr></let>
    <where>where <expr><name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'a'</literal> <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'e'</literal>
        <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'i'</literal> <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'o'</literal>
        <operator>||</operator> <name><name>w</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>==</operator> <literal type="char">'u'</literal></expr></where>
    <select>select <expr><name>word</name></expr></select></linq></expr></init></decl>;</decl_stmt>
IEnumerable<string> sortAscendingQuery =
    from fruit in fruits
    orderby fruit
    select fruit;
<decl_stmt><decl><type><name><name>IEnumerable</name><argument_list type="generic">&lt;<argument><name>string</name></argument>&gt;</argument_list></name></type> <name>sortAscendingQuery</name> <init>=
    <expr><linq><from>from <expr><name>fruit</name></expr> <in>in <expr><name>fruits</name></expr></in></from>
    <orderby>orderby <expr><name>fruit</name></expr></orderby>
    <select>select <expr><name>fruit</name></expr></select></linq></expr></init></decl>;</decl_stmt>
var studentQuery2 =
    from student in students
    group student by student.Last[0] into g
    orderby g.Key
    select g;
<decl_stmt><decl><type><name>var</name></type> <name>studentQuery2</name> <init>=
    <expr><linq><from>from <expr><name>student</name></expr> <in>in <expr><name>students</name></expr></in></from>
    <group>group <expr><name>student</name></expr> <by>by <expr><name><name>student</name><operator>.</operator><name>Last</name><index>[<expr><literal type="number">0</literal></expr>]</index></name></expr></by> <into>into <expr><name>g</name></expr></into></group>
    <orderby>orderby <expr><name><name>g</name><operator>.</operator><name>Key</name></name></expr></orderby>
    <select>select <expr><name>g</name></expr></select></linq></expr></init></decl>;</decl_stmt>
var innerJoinQuery =
    from category in categories
    join prod in products on category.ID equals prod.CategoryID
    select new { ProductName = prod.Name, Category = category.Name };
<decl_stmt><decl><type><name>var</name></type> <name>innerJoinQuery</name> <init>=
    <expr><linq><from>from <expr><name>category</name></expr> <in>in <expr><name>categories</name></expr></in></from>
    <join>join <expr><name>prod</name></expr> <in>in <expr><name>products</name></expr></in> <on>on <expr><name><name>category</name><operator>.</operator><name>ID</name></name></expr></on> <equals>equals <expr><name><name>prod</name><operator>.</operator><name>CategoryID</name></name></expr></equals></join>
    <select>select <expr><operator>new</operator> <block>{ <expr><name>ProductName</name> <operator>=</operator> <name><name>prod</name><operator>.</operator><name>Name</name></name></expr>, <expr><name>Category</name> <operator>=</operator> <name><name>category</name><operator>.</operator><name>Name</name></name></expr> }</block></expr></select></linq></expr></init></decl>;</decl_stmt>

into


Element

  • <into>

XPath Query

  • into clauses

    //src:into

#elif


Element

  • <cpp:elif>

Subelements

  • <cpp:directive>
  • <expr>

XPath Query

  • elif directives

    //cpp:elif

Examples

#elif
<cpp:elif>#<cpp:directive>elif</cpp:directive></cpp:elif>
#if (DEBUG && !MYTEST)
        Console.WriteLine("DEBUG is defined");
#elif (!DEBUG && MYTEST)
        Console.WriteLine("MYTEST is defined");
#elif (DEBUG && MYTEST)
        Console.WriteLine("DEBUG and MYTEST are defined");
#else
        Console.WriteLine("DEBUG and MYTEST are not defined");
#endif
<cpp:if>#<cpp:directive>if</cpp:directive> <expr><operator>(</operator><name>DEBUG</name> <operator>&amp;&amp;</operator> <operator>!</operator><name>MYTEST</name><operator>)</operator></expr></cpp:if>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"DEBUG is defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:elif>#<cpp:directive>elif</cpp:directive> <expr><operator>(</operator><operator>!</operator><name>DEBUG</name> <operator>&amp;&amp;</operator> <name>MYTEST</name><operator>)</operator></expr></cpp:elif>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"MYTEST is defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:elif>#<cpp:directive>elif</cpp:directive> <expr><operator>(</operator><name>DEBUG</name> <operator>&amp;&amp;</operator> <name>MYTEST</name><operator>)</operator></expr></cpp:elif>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"DEBUG and MYTEST are defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:else>#<cpp:directive>else</cpp:directive></cpp:else>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"DEBUG and MYTEST are not defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:endif>#<cpp:directive>endif</cpp:directive></cpp:endif>

#endif


Element

  • <cpp:endif>

Subelement

  • <cpp:directive>

XPath Query

  • endif directives

    //cpp:endif

Examples

#endif
<cpp:endif>#<cpp:directive>endif</cpp:directive></cpp:endif>
#if (DEBUG && !MYTEST)
        Console.WriteLine("DEBUG is defined");
#elif (!DEBUG && MYTEST)
        Console.WriteLine("MYTEST is defined");
#elif (DEBUG && MYTEST)
        Console.WriteLine("DEBUG and MYTEST are defined");
#else
        Console.WriteLine("DEBUG and MYTEST are not defined");
#endif
<cpp:if>#<cpp:directive>if</cpp:directive> <expr><operator>(</operator><name>DEBUG</name> <operator>&amp;&amp;</operator> <operator>!</operator><name>MYTEST</name><operator>)</operator></expr></cpp:if>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"DEBUG is defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:elif>#<cpp:directive>elif</cpp:directive> <expr><operator>(</operator><operator>!</operator><name>DEBUG</name> <operator>&amp;&amp;</operator> <name>MYTEST</name><operator>)</operator></expr></cpp:elif>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"MYTEST is defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:elif>#<cpp:directive>elif</cpp:directive> <expr><operator>(</operator><name>DEBUG</name> <operator>&amp;&amp;</operator> <name>MYTEST</name><operator>)</operator></expr></cpp:elif>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"DEBUG and MYTEST are defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:else>#<cpp:directive>else</cpp:directive></cpp:else>
        <expr_stmt><expr><call><name><name>Console</name><operator>.</operator><name>WriteLine</name></name><argument_list>(<argument><expr><literal type="string">"DEBUG and MYTEST are not defined"</literal></expr></argument>)</argument_list></call></expr>;</expr_stmt>
<cpp:endif>#<cpp:directive>endif</cpp:directive></cpp:endif>

#define


Element

  • <cpp:define>

Subelements

  • <cpp:directive>
  • <cpp:macro>

XPath Query

  • define directives

    //cpp:define

#undef


Element

  • <cpp:undef>

Subelements

  • <cpp:directive>
  • <name>

XPath Query

  • undef directives

    //cpp:undef

#warning


Element

  • <cpp:warning>

Subelement

  • <cpp:directive>

XPath Query

  • warning directives

    //cpp:warning

Examples

#warning
<cpp:warning>#<cpp:directive>warning</cpp:directive></cpp:warning>
#warning Deprecated code in this method.
<cpp:warning>#<cpp:directive>warning</cpp:directive> Deprecated code in this method.</cpp:warning>

#error


Element

  • <cpp:error>

Subelement

  • <cpp:directive>

XPath Query

  • error directives

    //cpp:error

Examples

#error
<cpp:error>#<cpp:directive>error</cpp:directive></cpp:error>
#error Deprecated code in this method.
<cpp:error>#<cpp:directive>error</cpp:directive> Deprecated code in this method.</cpp:error>

#line


Element

  • <cpp:line>

Subelements

  • <cpp:directive>
  • <cpp:number>
  • <cpp:file>

XPath Query

  • line directives

    //cpp:line

#region


Element

  • <cpp:region>

Subelements

  • <cpp:directive>
  • <name>

XPath Query

  • region directives

    //cpp:region

#endregion


Element

  • <cpp:endregion>

Subelement

  • <cpp:directive>

XPath Query

  • endregion directives

    //cpp:endregion

#pragma


Element

  • <cpp:pragma>

Subelements

  • <cpp:directive>
  • <name>

XPath Query

  • pragma directives

    //cpp:pragma