Closed johanvergeer closed 5 years ago
Hey @johanvergeer, thanks for your kind words. Sure, let's add this assertion to Light.GuardClauses. Some thinks we should consider:
You're welcome to implement this assertion and send me a pull request.
BTW: as a workaround, there is already a string.MustMatch
assertion that you can use while this feature isn't released.
@feO2x Thanks for your fast response. I do have an issue though.
It seems the project supports a lot of frameworks and I have resolved most of them by now. The only one left is .NETFramework,Version=v3.5,Profile=CompactFramework
. The plain .NETFramework,Version=v3.5
is already resolved.
Do you know how I can resolve that last one?
@johanvergeer I suggest you create a TargetFrameworks.props
file as described in the building and contributing page in the wiki. Thus you do not have to resolve the dependencies that are not installed on your dev machine.
Please take a look at the rest of the wiki, too. If you have any further questions, please feel free to contact me.
Implemented in 38d506d63b9f8c8807833e9af6b31d8264bd4d2e
Hey @johanvergeer, before I'll publish your new to NuGet, I wanted to take a closer look to the email regular expression that you wrote:
new Regex(
@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*@((((\w+\-?)+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$",
RegexOptions.CultureInvariant | RegexOptions.ECMAScript)
I have several questions:
IsEmailAddress
we already are in the range of microseconds. I know email validation is not easy, but if we could at least arrive in the range of several hundred nanoseconds, that would be great.Hi @feO2x,
To answer your questions:
I did use an existing regex pattern to start with, but not from https://emailregex.com/, since that one gave a lot of false positives. The one I used to start of was from https://www.rhyous.com/2010/06/15/csharp-email-regular-expression/. This one also didn't pass all tests so I made some changes.
The only ones that won't pass at this moment are:
"hello"@test.com
hello@[123.123.123.123]
For the test cases I used this list from MSDN.
It might be that I missed some that I'm not aware of.
Regarding performance. This would require some more research. I do know some regex, but I'm not a master in it.
I also have one more question for you. I tried to use TargetFrameworks.props
as you described in the Wiki, but VS is still showing errers because of the missing dependencies. Is there something else I might be missing?
Also a suggestion. Would you like to add a .gitignore
to the project?
Hey @johanvergeer,
Sorry that it took so long, but version 6.2 is out now. You can fetch your contribution on NuGet or in the source file.
Thanks again for your contribution!
Hi @feO2x,
Just out of curiosity. Were you able to improve the performance of the regex?
Unfortunately not. I think the key here is to replace the regular expression with plain code, but this would take some time.
I just started using your library, and so far it is looking great. And at this point I'm missing something that can be used in a couple of my projects.
Has anyone thought of adding a clause like
string.MustBeValidEmail();
. This seems to be something that can be very generic and useful for this library. If you would like this to be added I'm willing to make a contribution.