question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider 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:closed
  • Created 7 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
richardwerkmancommented, Feb 22, 2023

@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.

0reactions
dupdobcommented, Feb 22, 2023

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found