Static Guid
See original GitHub issueConsider the following code;
public static class StaticKeys
{
public static Guid StaticPersonKey = new("C8901F9D-4227-4BAC-903F-46E899D863F4");
}
Using Stryker would result in:
public static class StaticKeys
{
public static Guid StaticPersonKey = new("");
}
This will always throw because an empty string can not be parsed as a Guid. It would be great if Stryker in this case mutated to Guid.Empty or some random Guid. Maybe configurable?
Issue Analytics
- State:
- Created 7 months ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to declare a constant Guid in C#? - Stack Overflow
I understand that I can declare a static readonly Guid , but is there a syntax that allows me to write const Guid...
Read more >Guid.NewGuid Method (System)
This is a convenient static method that you can call to get a new Guid. The method creates a Version 4 Universally Unique...
Read more >GUIDs In C# And .NET
A GUID (Global Unique IDentifier) is a 128-bit integer used as a unique identifier. ... static int Main(string[] args) {; Guid obj =...
Read more >5 things you didn't know about Guid in C# | Code4IT
For sure, the typical way of creating a Guid is using the static method Guid.NewGuid() . There are other ways to generate them....
Read more >How to work with GUIDs in C# 8
Here is a simple extension method that determines if a GUID is Guid.Empty. public static bool IsNullOrEmpty(this ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Liam-Rougoor well yes and no. We already do this for regex as well. If we find a string in a constructor called “Regex” we assume the string is a regex and we mutate regex specifically.
We could do the same with Guid. It’s not foolproof as with the above anonymous constructor we can’t find the name. Or someone could have their own class called Guid (but why would they…).
So basically, yes we can do this. But only if the syntax
new Guid("C8901F9D-4227-4BAC-903F-46E899D863F4")
is used.@Iceeman76 : bear in mind that this behavior is considered as normal for Stryker: there is no strong guarantee that generated mutations are relevant (while ensuring of them are, of course). So this is definitely a low priority request, until proven otherwise.
That being said, it looks like something that can be addressed simply by configuration: you just need to add
*.Guid.ctor
as to be ignored. See the configuration doc for details.