-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A complete rewrite of the C# language to support almost every feature of C# 8.0.
- Loading branch information
1 parent
43efde2
commit 42b1546
Showing
24 changed files
with
1,934 additions
and
177 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
[Foo] | ||
[Foo(1, 2)] | ||
[Foo(1, 2, Name = "bar")] | ||
[Foo, Bar] | ||
[Foo("()"), Bar("[]"), Baz] | ||
|
||
[return: MaybeNull] | ||
[assembly: InternalsVisibleTo("Tests")] | ||
|
||
[assembly: Foo] | ||
[module: Foo] | ||
[field: Foo] | ||
[event: Foo] | ||
[method: Foo] | ||
[param: Foo] | ||
[property: Foo] | ||
[return: Foo] | ||
[type: Foo] | ||
|
||
// not attributes | ||
|
||
var a = d | ||
[Foo]; | ||
var b = new Foo<int>?[Count]; | ||
var c = new (int, int)[Count]; | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "["], | ||
["attribute", [ | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["class-name", [ | ||
"Foo" | ||
]], | ||
["attribute-arguments", [ | ||
["punctuation", "("], | ||
["number", "1"], | ||
["punctuation", ","], | ||
["number", "2"], | ||
["punctuation", ")"] | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["class-name", [ | ||
"Foo" | ||
]], | ||
["attribute-arguments", [ | ||
["punctuation", "("], | ||
["number", "1"], | ||
["punctuation", ","], | ||
["number", "2"], | ||
["punctuation", ","], | ||
" Name ", | ||
["operator", "="], | ||
["string", "\"bar\""], | ||
["punctuation", ")"] | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["class-name", [ | ||
"Foo" | ||
]], | ||
["punctuation", ","], | ||
["class-name", [ | ||
"Bar" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["class-name", [ | ||
"Foo" | ||
]], | ||
["attribute-arguments", [ | ||
["punctuation", "("], | ||
["string", "\"()\""], | ||
["punctuation", ")"] | ||
]], | ||
["punctuation", ","], | ||
["class-name", [ | ||
"Bar" | ||
]], | ||
["attribute-arguments", [ | ||
["punctuation", "("], | ||
["string", "\"[]\""], | ||
["punctuation", ")"] | ||
]], | ||
["punctuation", ","], | ||
["class-name", [ | ||
"Baz" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "return"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"MaybeNull" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "assembly"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"InternalsVisibleTo" | ||
]], | ||
["attribute-arguments", [ | ||
["punctuation", "("], | ||
["string", "\"Tests\""], | ||
["punctuation", ")"] | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "assembly"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "module"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "field"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "event"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "method"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "param"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "property"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "return"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["punctuation", "["], | ||
["attribute", [ | ||
["target", "type"], | ||
["punctuation", ":"], | ||
["class-name", [ | ||
"Foo" | ||
]] | ||
]], | ||
["punctuation", "]"], | ||
["comment", "// not attributes"], | ||
["class-name", [ | ||
["keyword", "var"] | ||
]], | ||
" a ", | ||
["operator", "="], | ||
" d\n", | ||
["punctuation", "["], | ||
"Foo", | ||
["punctuation", "]"], | ||
["punctuation", ";"], | ||
["class-name", [ | ||
["keyword", "var"] | ||
]], | ||
" b ", | ||
["operator", "="], | ||
["keyword", "new"], | ||
["constructor-invocation", [ | ||
"Foo", | ||
["punctuation", "<"], | ||
["keyword", "int"], | ||
["punctuation", ">"], | ||
["punctuation", "?"] | ||
]], | ||
["punctuation", "["], | ||
"Count", | ||
["punctuation", "]"], | ||
["punctuation", ";"], | ||
["class-name", [ | ||
["keyword", "var"] | ||
]], | ||
" c ", | ||
["operator", "="], | ||
["keyword", "new"], | ||
["constructor-invocation", [ | ||
["punctuation", "("], | ||
["keyword", "int"], | ||
["punctuation", ","], | ||
["keyword", "int"], | ||
["punctuation", ")"] | ||
]], | ||
["punctuation", "["], | ||
"Count", | ||
["punctuation", "]"], | ||
["punctuation", ";"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for class names of attributes. |
110 changes: 110 additions & 0 deletions
110
tests/languages/csharp/class-name-declaration_feature.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
class Foo | ||
interface BarBaz | ||
struct Foo | ||
enum Foo | ||
class Foo<A, B> | ||
interface Bar<out T> | ||
|
||
// not variables | ||
public static RGBColor FromRainbow(Rainbow colorBand) => | ||
colorBand switch | ||
{ | ||
Rainbow.Red => new RGBColor(0xFF, 0x00, 0x00), | ||
_ => throw new ArgumentException(message: "invalid enum value", paramName: nameof(colorBand)), | ||
}; | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "class"], | ||
["class-name", ["Foo"]], | ||
|
||
["keyword", "interface"], | ||
["class-name", ["BarBaz"]], | ||
|
||
["keyword", "struct"], | ||
["class-name", ["Foo"]], | ||
|
||
["keyword", "enum"], | ||
["class-name", ["Foo"]], | ||
|
||
["keyword", "class"], | ||
["class-name", [ | ||
"Foo", | ||
["punctuation", "<"], | ||
"A", | ||
["punctuation", ","], | ||
" B", | ||
["punctuation", ">"] | ||
]], | ||
|
||
["keyword", "interface"], | ||
["class-name", [ | ||
"Bar", | ||
["punctuation", "<"], | ||
["keyword", "out"], | ||
" T", | ||
["punctuation", ">"] | ||
]], | ||
|
||
["comment", "// not variables"], | ||
|
||
["keyword", "public"], | ||
["keyword", "static"], | ||
["return-type", [ | ||
"RGBColor" | ||
]], | ||
["function", "FromRainbow"], | ||
["punctuation", "("], | ||
["class-name", [ | ||
"Rainbow" | ||
]], | ||
" colorBand", | ||
["punctuation", ")"], | ||
["operator", "=>"], | ||
"\n\tcolorBand ", | ||
["keyword", "switch"], | ||
["punctuation", "{"], | ||
"\n\t\tRainbow", | ||
["punctuation", "."], | ||
"Red ", | ||
["operator", "=>"], | ||
["keyword", "new"], | ||
["constructor-invocation", [ | ||
"RGBColor" | ||
]], | ||
["punctuation", "("], | ||
["number", "0xFF"], | ||
["punctuation", ","], | ||
["number", "0x00"], | ||
["punctuation", ","], | ||
["number", "0x00"], | ||
["punctuation", ")"], | ||
["punctuation", ","], | ||
"\n\t\t_ ", | ||
["operator", "=>"], | ||
["keyword", "throw"], | ||
["keyword", "new"], | ||
["constructor-invocation", [ | ||
"ArgumentException" | ||
]], | ||
["punctuation", "("], | ||
["named-parameter", "message"], | ||
["punctuation", ":"], | ||
["string", "\"invalid enum value\""], | ||
["punctuation", ","], | ||
["named-parameter", "paramName"], | ||
["punctuation", ":"], | ||
["keyword", "nameof"], | ||
["punctuation", "("], | ||
"colorBand", | ||
["punctuation", ")"], | ||
["punctuation", ")"], | ||
["punctuation", ","], | ||
["punctuation", "}"], | ||
["punctuation", ";"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for class names at the class declaration. |
Oops, something went wrong.