Great feature! Also, thank you for saying that "nobody knows regex". One of the senior devs at my first dev job told me that I "had to learn regex" because it was "important to know off the top of your head" and it's good to know I'm not alone 🤣
@Jennalcn2 жыл бұрын
I am no one.
@GarethBradley2 жыл бұрын
I think they were pulling your leg fella. Like when painters start the first day of a job and are sent to buy tartan paint....
@AJax20122 жыл бұрын
@@GarethBradley typically, I’d agree with you. This guy was weird though. I’ve been working in the field for 4 years and I have yet to find anyone else who can just write complex regex without looking it up. He went as far as to buy me and the other new dev a pocket handbook on regex and gave us homework, lol. They did give me a troll assignment on my first day though, so who knows…
@modernkennnern2 жыл бұрын
Regex, while rarely mandatory, are incredibly useful for doing small repetitive tasks. "Ugh, I have to convert all top-level structs and classes in my project from being Public to being Internal.. That'll take forever.". "public (class|record)" -> replace with -> "internal $1". This is not "production-ready," as it misses readonly structs, record structs, readonly record structs and so on, but the idea is there.
@AJax20122 жыл бұрын
@@modernkennnern yup, that’s almost entirely where I actually use regex. Find and replace
@litarea2 жыл бұрын
6:00 holy crap that is unbelievably useful. Most IDEs behavior of just broadly ignoring the contents of strings has always seemed like a missed opportunity to me. Countless times I've had to use separate validators and copy in from there.
@Nezbo2 жыл бұрын
I was chanting "Attribute Attribute Attribute" for about 3 minutes until the reveal :D Happy they went this way.
@Zashxq2 жыл бұрын
omg this is crazy. this is crazy!!! as a library dev this is an absolute gamechanger for me. wow wow wow
@jongeduard2 жыл бұрын
Great video. I didn't know about the older comment way indeed. I just tried and noticed that lang=date, lang=time or lang=datetime also works (trying with VSCode now). 1:03 Oh I know how to write them! 😃 Learning about them is like a gift, in coding, but also in Linux shell and Powershell or wherever you want to search for stuff, they are a great thing.
@Phraxas522 жыл бұрын
I have never seen a more useful programming channel. Thank you.
@Akumasama2 жыл бұрын
Oh wow, that is beautiful. And timely too because my current project uses Regexes a lot. Nice!
@briankesecker2 жыл бұрын
1) this feature will save many devs from typos and 2) I get the sense this feature could be toggled, such that string parameters can auto-inherit all the way up the stack, thus relieving devs from having to attribute params. That inline Json syntax checking is on fire for unit testing! Thank you Nick!
@alexclark67772 жыл бұрын
Me: "Huh, probably just a video about string literals, but it's a Nick Chapsas video so I'll watch it." Me after video: "Mind blown. I learned something new."
@th305192 жыл бұрын
This is a pretty cool feature, it would be fantastic if it supported other languages like SQL, JavaScript, or HTML. How many times have we had to format strings of other languages? to be able to validate them in the IDE without copy/pasting to their native editors would be great.
@drewkillion28122 жыл бұрын
Rider has some support for recognizing SQL strings.
@christianhowell31402 жыл бұрын
Oh my god if they add support for SQL and HTML I would literally cry of joy (and demand my company upgrade to Net7)
@vertxxyz2 жыл бұрын
JetBrains' Annotations has had RegexPatternAttribute for aaaages which does this same thing. Glad it's standardised and supporting other syntaxes
@codecoffee49522 жыл бұрын
I had to write a parser once, so regex was a large part of my day-to-day for a bit. This would have really come on handy then. Looking forward to using this. Thanks for sharing.
@uncommonbg2 жыл бұрын
Holy smokes, that's a pretty cool feature and I can see it becoming better and better with time. Thanks, Nick!
@jimread23542 жыл бұрын
That's amazing! I had no idea that was even a thing, but now I want to know how to write my own. I've had more than one instance where I wrote a proprietary scripting language and this would be a great feature to be able to add in.
@DerekWelton2 жыл бұрын
I would love to see us have the ability to create our own string syntax(yes I know, you should use an enum then) but there are special cases where this would be handy. Thanks for showing this Nick!
@nickchapsas2 жыл бұрын
It's would be pretty cool. I assume this can be done with a VS Extension or a RIder Plugin
@phizc2 жыл бұрын
The parameter to the attribute is just a string, so I assume you can make an extension and look for a custom syntax tag. I doubt the IDE would crash if the string is unexpected. It would probably be like XmlSyntax now.
@AnsisPlepis Жыл бұрын
1:03 truer words have never been spoken
@marklord76142 жыл бұрын
Wow, this was really useful. Thanks Nick!
@BananaTie2 жыл бұрын
Cool feature, thank you for showing us that! I did not know the comment part "/*lang=regex*/" was a thing! That will be helpful for the project I am working on at the moment (stuck at .NET 3.1)
@CordellLawrence Жыл бұрын
@Nick, interestingly, this doesn't work for Anonymous methods. not sure if the IDE's (I'm using VsCode 1.77.1 Windows) just don't look for them on Anonymous methods (I checked the low-level C# / IL and the compiler does include the attribute on the Anon method. e.g. Func find = (input, [StringSyntax(StringSyntaxAttribute.Regex)]expression) => Regex.Match(input, expression); BTW - Thanks for all the awesome content!
@krccmsitp28842 жыл бұрын
Awesome feature, thanks for showing!
@antonmartyniuk2 жыл бұрын
A really cool and handy thing! Thanks for the heads up
@xeoneraldo12542 жыл бұрын
I love Nick's number examples
@mandoschMUh2 жыл бұрын
Ooookay .. that's a cool feature, indeed! Thank you for sharing this.
@MRender322 жыл бұрын
I’m glad the argument is a string so custom formats can be written. I wanna see XPath syntax highlighting
@_emik2 жыл бұрын
Reminds me of TypeScript's awesome template literal feature. So excited to see this validation added in Rider!
@TheMAZZTer2 жыл бұрын
I thought this was going to be about a different feature but I guess that's coming in a later .NET. I am looking forward to being able to have string subtypes like Names, PhoneNumbers, etc that define what the contents of a string are for, which will help keep you from accidentally using the wrong string in the wrong place. This is really cool too and I'm going to have to keep it in mind, though I will probably not be able to use it until .NET 8 LTS.
@SlackwareNVM2 жыл бұрын
Looks awesome, especially the Json one. I'd be great if we could define our own suggestions. Not syntax highlighting, but just the available options like for the date time formatter.
@petrusion28272 жыл бұрын
This would make an amazing feature. Custom string syntax highlighting for arguments would make working with things like format strings 10000000% more convenient. Floats for example don't have format string suggestions like DateTime does and I hate having to always look up all the different ways to format a float somewhere online.
@cattman19702 жыл бұрын
Wow that is super sweet. Thank you!😊
@МихаилПлюснин-з8й2 жыл бұрын
Thank you! Great feature!
@GregUzelac2 жыл бұрын
Very informative and helpful. Thx.
@Crozz222 жыл бұрын
This is great. But ideally I'd wish for type alias in C# instead. So I could declare something like `type RegexPattern = [StringSyntax(StringSyntaxAttribute.Regex)] string`, and then just use the RegexPattern as the parameter without having to specify the attributes on every method (and also make it clearer because i'm passing around RegexPattern and not a plain string)
@TheKub1s2 жыл бұрын
You can write something like this with 'using' keyword: using NullableInt = System.Nullable; I don't know if it works with attributes.
@metaltyphoon2 жыл бұрын
Seriously, the attribute being long is getting out of hand.
@lordmetzgermeister2 жыл бұрын
in C# there's nothing even remotely similar to what you suggest so that would be hard to do
@ДаниилЧернышев-л5й2 жыл бұрын
@@allmhuran Well, we can make use of implicit cast operators between string and any of those classes. Not so typesafe, but better than nothing, I guess.
@sebastienvisser87592 жыл бұрын
Thanks, Nick.
@alfonsosuarez93172 жыл бұрын
It will come in handy. Do you know if we could create custom string sintaxes?
@TedOnTheNet2 жыл бұрын
Will be interesting to see custom implementations.
@SmoothSkySailin2 жыл бұрын
Thanks for the great video!
@pdebie19822 жыл бұрын
Is it possible to create custom syntax attributes in which you can create your own list of "options" to fill?
@emmanueladebiyi21092 жыл бұрын
Thanks for putting out all these great content 🙏🏽
@cn-ml2 жыл бұрын
Oh, wow, i cannot even count how many times during development i thought this would be practical. The amount of times i preferred to call the regex constructor with a literal string because it just looks better than a string variable
@AaronShumaker Жыл бұрын
This makes me wonder why we don't have a way to annotate strings as more specific subtypes. There's been many occasions I'd love to have string parameters with specificity so compile time would say "Hey you're trying to pass a HtmlString where a UriString is expected." Or be able to create specialized strong extension methods without polluting every other type of string.
@magicsmoke02 жыл бұрын
What's the most performant way to convert an integer to a string in a hotpath (millions of loops)? My benchmarks show a simple .ToString() on the int is faster than using some Span alternative, like int.TryFormat(buffer.AsSpan(), out var x), but has some memory allocation where as the TryFormat doesn't.
@Denmaverick392 жыл бұрын
Thanks nick.
@ufukata67892 жыл бұрын
It's very cool. Can we customize this, for example json format fix warning etc.
@co2boi2 жыл бұрын
Killer. Thanks!
@saniel27482 жыл бұрын
Can this attribute be applied to fields/consts?
@Anequit2 жыл бұрын
I love this feature
@mabakay2 жыл бұрын
Cool feature. ReSharper has had it for years ;-)
@gammafelikx2 жыл бұрын
Nice feature but, as far as 'IDE dependant' feature goes, Rider already have an ''Mark as injected language or reference" funcionality that is quite the same thing.
@Palladin0072 жыл бұрын
I love it :D I knew about the "lang=regex" feature and I was looking for a long time for a way to do that with attributes. But I don't understand why the constants are in the attribute class. I think it would be better to have "[StringSyntax(StringSyntax.Json)]" and then the StringSyntax class contains the constants.
@jackoberto012 жыл бұрын
StringSyntax is just an identifier for StringSyntaxAttribute when you use it as an Attribute this is how all Attributes work in C# for example SerializableAttribute can be written as Serializable or FlagsAttribute can be written as Flags. So it already exists in the place you're suggesting but you need to write the whole name of the Attribute in the constructor. If you wanted to you could write it "[StringSyntaxAttribute (StringSyntaxAttribute.Json)]"
@metaltyphoon2 жыл бұрын
@@jackoberto01 he is saying that what’s in the parentheses is too long
@jackoberto012 жыл бұрын
@@metaltyphoon Yeah I get that but this is just a quirk of the language. I guess they could allow the identifier to be used in the Constructors of Attributes but that would require changes to the language
@phizc2 жыл бұрын
@@jackoberto01 they could have put the constants on a class named StringSyntaxes. On the other hand, they're just magic strings so you could do it yourself. 🙂
@Dimich19932 жыл бұрын
This is great!
@yatsuk2 жыл бұрын
Is it possible to define own syntax?
@paulpach2 жыл бұрын
Wow, cool feature. Makes stringly typed data just a little safer to use.
@womz82032 жыл бұрын
"No one knows how to write Regex" This is so true 😭
@yzraeu2 жыл бұрын
Video gets nice @ 6:14
@carlitoz4502 жыл бұрын
Wow ! thats nice
@ilShaiHulud2 жыл бұрын
Hello. Thanks for the cool video! I am waiting for this feature. Do you know is it will be possible to extend StringSyntaxAttribute with user defined languages?
@ryanjean2 жыл бұрын
"No one knows how to write Regex" *timidly raises hand*
@TheAzerue2 жыл бұрын
Hi A simple question. Can Net 7 RC be used in production ? and is it drop in replacement for Net 6.
@nickchapsas2 жыл бұрын
I would not run any RC version in production. Wait for the full release. It will mostly be a drop in replacement
@lordmetzgermeister2 жыл бұрын
It's not a question of whether it can be used but rather whether you should use a "release candidate" version in production. The answer is no.
@amrosamy82322 жыл бұрын
Hi Nick, Can you make a video about IAsyncEnumerable plz?
@deusexaethera2 жыл бұрын
I keep telling myself I should learn RegEx, but I keep not needing to. Any string manipulation I could do in RegEx, I can do with other programming structures without having to assume the RegEx parser will do it correctly on my behalf. RegEx is really only useful in the very narrow range of scenarios where you need to modify a string AND pass it to another function in the same line of code.
@Faygris2 жыл бұрын
Are we not going to argue about the way he pronounces regex? No? Alright. Anyway, great feature! I'm looking forward to using it 😊
@nickchapsas2 жыл бұрын
The original plan was to pronounce it both regex and regex but I forgot to switch it up mid-video
@lordmetzgermeister2 жыл бұрын
I was wondering as well. Surprised there's only one comment here... Anyway it's "rejular expressions" now.
@Joe-SoftwareEngineer2 жыл бұрын
Nice! Very nice!
@PetrVejchoda2 жыл бұрын
1:02 deep truth
@slyp052 жыл бұрын
That /*lang=Regex*/ thing is crazy haha. Very nice that new version are trying to make those weird hidden features actually use the clean language features. No more weird "call you method Add, Deconstruct or Dispose and it will actually have a unique behaviour despite nothing telling you about it" in the future ? That would be nice !
@PanMaciek2 жыл бұрын
Nice one
@swordblaster25962 жыл бұрын
Interesting. Using this properly eliminates an entire class of possible mistakes.
@shayvt2 жыл бұрын
What is the state of c# 7? When will it be released?
@samuelschwager2 жыл бұрын
C# 7 was released in 2017. I guess you mean .NET 7? November 2022
@klex39052 жыл бұрын
"No-one knows how to write regex" I haven't laughed that hard since your goPilot video!
@hostar22 жыл бұрын
My question is: will this attribute compile into the binary?
@itssalmanvlogs_2 жыл бұрын
🔥
@iammahie2 жыл бұрын
1:04 absolutely, Lol 😂😆
@metaltyphoon2 жыл бұрын
Attribute length is getting out of hand, C# need to have type alias
@Sergio_Loureiro2 жыл бұрын
1:05 Nick Chapsas: No one knows how to write regex Experienced Perl programmer: *HOLD MY BEER.*
@11clocky2 жыл бұрын
Could they have made those annotations any more verbose? They take up more space than the method signatures themselves.
@Dobrokhvalov2 жыл бұрын
It would be cool to have SQL support
@EduardQualls2 жыл бұрын
Am I the only one who slows Nick down to 0.75 playback speed, just to make sure I don't miss anything in his excitement?
@TimmyBraun2 жыл бұрын
I always go with 2x lol, but sometimes I rewind and play back a bit slower when there's something interesting I didn't get :)
@MHjort92 жыл бұрын
Thanks for the sub-10 minute video. I feel smarter quicker
@klaxxon__2 жыл бұрын
Why is this .Net 7 specific? It doesn't involve the language or the runtime at all, doesn't it? It's all in the IDE. It should be possible to shim this with a custom attribute with the same name and namespace (or a nuget package containing sucha ttribute). A lot of the attributes controlling newer features can be shimmed like this.
@lordmetzgermeister2 жыл бұрын
They'd have to make it so that the nuget package can't be used in a .NET 7+ project. Or use a different namespaces but that'd be confusing. So not enabling it is easier and is an incentive for devs to upgrade to the new version. Win-win.
@klaxxon__2 жыл бұрын
@@lordmetzgermeister They generally do not hold back features just to incentivize upgrading (in many environments, it is not the developers who decide which version of net gets used, there are many other considerations). Also, they have released shims for language features for older frameworks before (see the package System.ValueTuple , and there were multiple other cases as well, where a new language feature could be easily shimmed onto an older runtime by defining a class/struct or an attribute). The colission thing can be easily sorted out with for example #if NET6_0.
@phizc2 жыл бұрын
Cool! You can also put the attribute on fields and properties (and maybe variables?). I knew about the attribute, but only that it supported Regex syntax. I didn't know they also support json, and seem to plan to support XML.
@dariuszkopec2 жыл бұрын
61 years old and just purchased tNice tutorials software. i love making my own soft
@kipchickensout Жыл бұрын
It's not that complicated to learn basic regex and it not only helped me read it a few times but also write as well as search specific strings in my code to narrow down things
@isen12 жыл бұрын
whats up with that double """"?
@nickchapsas2 жыл бұрын
It's a new C# 11 feature called, raw string literals.
@th305192 жыл бұрын
@@nickchapsas I saw a cool video about that feature here kzbin.info/www/bejne/any7iHSdj6prrqs
@Corvin_2 жыл бұрын
Praying dotnet will have a good Uri parser one day.
@tacklemcclean2 жыл бұрын
This is crazy!! You look so much younger than 69!
@nickchapsas2 жыл бұрын
I use sun screen
@liam70732 жыл бұрын
I had no idea the IDE changed behaviour based on comments.
@cedricv-p9z2 жыл бұрын
1:03 lol
@frossen1232 жыл бұрын
Regex is not even a challenge anymore, where were all these tools 20 years ago 😭all the ide features, online "explanation tools" and builders.. oh well, making all our lives easier 😄
@petrucervac87672 жыл бұрын
You look pretty young for a 69 years old
@AvenDonn2 жыл бұрын
When you opened VS... Mood.
@masonwheeler65362 жыл бұрын
There's a good reason why no one knows how to write regex: _they're garbage._ The old joke about "now you have two problems" exists for a good reason. If your use case is simple, it's more readable, and likely to be both more performant and less buggy, to write some manual string-parsing code. If your use case is not simple, it's more readable, and almost certain to be less buggy, to use a parser generator such as ANTLR. Regex was a cool trick back in the 80s and early 90s, but we've had significantly better alternatives for a long time now. Please don't go inflicting regex on people who might need to read and maintain your code in the future. (Especially because you might well be one of them!)
@arjix87382 жыл бұрын
Hey! I know how to write regex!
@nickchapsas2 жыл бұрын
Stop lying
@arjix87382 жыл бұрын
@@nickchapsas I am not lying, I practiced a lot! Honestly, writing regex is easy, reading regex is the hard part. And comprehending regex that was not written by urself is even harder
@davidwhite20112 жыл бұрын
2nd
@lx2222x2 жыл бұрын
This is why C# is way better than JS
@stdprocedure2 жыл бұрын
imagine rust's macros in c#
@ghostaccount98652 жыл бұрын
Microsoft and flipping tables on all the other languages and technologies out there. Bravo! . But when am I going to be a developer for God sake ?
@augustobarreto53012 жыл бұрын
The attribute name is too big for something so basic
@samuelschwager2 жыл бұрын
Real pros use regex to parse html :P
@ssmcs0602 жыл бұрын
Age 69 🎭 🙂🙃
@petermcraa2 жыл бұрын
Wierd, but reminds me of Typescript.
@lordmetzgermeister2 жыл бұрын
Excuse me, "rejex"? Are those "rejular expressions" now? xD
@nickchapsas2 жыл бұрын
The plural of Regex is Regrets
@thebitterbeginning2 жыл бұрын
...because no one knows how to write RegEx... lol!