M
M
mrCraick2018-02-03 14:57:07
.NET
mrCraick, 2018-02-03 14:57:07

dotnet.exe crashes when accessing a variable, wut?

Good day! Most likely I just missed something simple, but I am tormented by doubts.
And so what's the problem. There is a property It seems there is no catch, but if you perform any manipulations with the property during unit testing, for example: then dotnet says: "I dump: 0xc00000fd" and also writes in the console "Process is terminating due to StackOverflowException.". getters and seters:
short BaseGene<short>.Code { get; set; }
Assert.IsNotNull(gene.Code);

public T Code { get => Code; set => Code = value; }

I absolutely do not understand where the overflow occurs, I understand there would be an infinite loop, but no ...
Even if:
GeneInt16 gene = new GeneInt16();
Assert.IsNotNull(gene);

And in the constructor
public GeneInt16(int? seed = null, short min = short.MinValue, short max = short.MaxValue)
{
    _random = (seed == null) ? new Random() : new Random((int)seed);
    Code = (short)_random.Next(min, max);
}

The same thing happens.
If you ignore the existence of Code at all, then all tests pass normally.
An important note, if you just compile the project and use it, everything is fine.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Griboks, 2018-02-03
@mrCraick

I understand it would be an endless loop

Code {get{return Code;}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question