Skip to content

Adding keyword 'record' 'init' 'nullable' (new syntax of C# 8, 9) - #2991

Merged
RunDevelopment merged 4 commits into
PrismJS:masterfrom
kmycode:topic-csharp
Jul 11, 2021
Merged

RunDevelopment merged 4 commits into
PrismJS:masterfrom
kmycode:topic-csharp

Conversation

@kmycode

@kmycode kmycode commented Jul 11, 2021

Copy link
Copy Markdown
Contributor

New syntax keyword is added on c# 8, 9.
This pull request is adding keywords record, init and nullable.

nullable (C# 8)

https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8

record, init (C# 9)

https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9

example

#nullable enable

class TestClass
{
  public string Keyword { get; init; }
}

record TestModel(string Name, uint Id, int Age);

@github-actions

github-actions Bot commented Jul 11, 2021 •

Copy link
Copy Markdown

JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of +14 B (+0.6%).

Details
file master pull size diff % diff
components/prism-csharp.min.js 2.35 KB 2.37 KB +14 B +0.6%

Generated by 🚫 dangerJS against 8b76e8b

@RunDevelopment RunDevelopment left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @kmycode!

I left you 2 comments.

Also, you have to rebuild Prism. Just run npm ci && npm run build and commit the changes.

Also also, please add tests for the new keywords (1, 2). Adding tests is relatively easy: Just modify the text (ignore the JSON for now) and run npm run test:languages -- --update. For more information, see this page.

Comment thread components/prism-csharp.js Outdated
Comment thread components/prism-csharp.js Outdated
@kmycode

kmycode commented Jul 11, 2021

Copy link
Copy Markdown
Contributor Author

@RunDevelopment

Thank you for your review and works. I regret I didn't read development guides.
I see that the "record" keyword is difficult to implement.

I added some test codes. Please review again.

@RunDevelopment
RunDevelopment merged commit 9b56156 into PrismJS:master Jul 11, 2021
@RunDevelopment

Copy link
Copy Markdown
Member

Great work! Thank you for contributing @kmycode!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants