MarchalPT
MarchalPT

Reputation: 1566

Blazor .net core ref enum? param not changing its value

Im a bit confused with whats happening bellow:

enter image description here

enter image description here

Can anyone explain me why is dataType keep saying StatisticData instead of SibsMonthly??

dataType is a enum? passad as ref param to this method and its initialized as null before the method call..

Here is the code:

string errorMessage = null;
Enums.Uploads.DataType? dataType = null;

if (ValidadeFile(file, ref errorMessage, ref dataType))
{
    ...
}
 
private bool ValidadeFile(IBrowserFile file, ref string errorMessage, ref Enums.Uploads.DataType? dataType)
{
    List<string> acceptedFileTypes = new List<string>
    {
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    };
    var valid = true;

    if (AcceptedFileNames != null && AcceptedFileNames.Length > 0)
    {
        var tmp = AcceptedFileNames.Where(x => new Regex(x.Regex).IsMatch(file.Name))
            .OrderByDescending(x => x.DataType)
            .Select(x => x.DataType)
            .FirstOrDefault();

        dataType = tmp;

        if (dataType == null)
        {
            valid = false;
            errorMessage = Constants.Uploads.Error.InvalidFileName;
        }
    }
    ...
}

Upvotes: 0

Views: 123

Answers (1)

CodeCaster
CodeCaster

Reputation: 151594

The WASM debugger doesn't seem to like ref variables, it seems to look at their address, not their value:

Enum

String

Inspecting them at their call site or in the Debug window behaves as expected; this is a debugger isssue.

Upvotes: 1

Related Questions