Visual studio Blazor.net核心引用枚举?param不更改其值

Visual studio Blazor.net核心引用枚举?param不更改其值,visual-studio,asp.net-core,blazor,Visual Studio,Asp.net Core,Blazor,我对下面发生的事情有点困惑: 谁能解释一下为什么dataType总是说StatisticData而不是SibsMonthly 数据类型是枚举?此方法的passad as ref param,并在方法调用之前将其初始化为null 代码如下: string errorMessage = null; Enums.Uploads.DataType? dataType = null; if (ValidadeFile(file, ref errorMessage, ref dataType)) {

我对下面发生的事情有点困惑:

谁能解释一下为什么dataType总是说StatisticData而不是SibsMonthly

数据类型是枚举?此方法的passad as ref param,并在方法调用之前将其初始化为null

代码如下:

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;
        }
    }
    ...
}
string errorMessage=null;
Enums.Uploads.DataType?dataType=null;
if(有效数据文件(文件,参考错误消息,参考数据类型))
{
...
}
私有bool ValidadeFile(IBrowserFile文件,ref string errorMessage,ref Enums.Uploads.DataType?DataType)
{
List acceptedFileTypes=新列表
{
“application/vnd.openxmlformats of iceDocument.spreadsheetml.sheet”
};
var valid=true;
if(AcceptedFileNames!=null&&AcceptedFileNames.Length>0)
{
var tmp=AcceptedFileNames.Where(x=>newregex(x.Regex).IsMatch(file.Name))
.OrderByDescending(x=>x.DataType)
.选择(x=>x.DataType)
.FirstOrDefault();
数据类型=tmp;
if(数据类型==null)
{
有效=错误;
errorMessage=Constants.Uploads.Error.InvalidFileName;
}
}
...
}

WASM调试器似乎不喜欢
ref
变量,它似乎在查看它们的地址,而不是它们的值:


在调用站点或调试窗口中检查它们的行为符合预期;这是一个调试器ISSUE。

您正在调试正在运行的代码吗?或者有其他线程修改该成员吗?我正在调试代码,没有其他线程正在运行。。顺便说一句,我使用ref表示数据类型,它可以为null,所以在方法调用之前初始化为null@BrianParker我知道正则表达式,正如您在代码中看到的,它在x.regex的内部…@Brian整个要点是
dataType=tmp
似乎不会更新变量
dataType
。Linq在这里不相关,OP调用
var tmp=…FirstOrDefault()
,因此获取
tmp
的查询不会再次计算或类似的内容。伙计们,我相信这是代码Blazor部分的VS调试器错误,因为当它到达api时,值会更新。。我应该删除这个问题吗?或者让它出现在这里,以防有人最终遇到同样的问题?感谢CodeCaster,他意识到了这一点,我们都可以向微软报告,我们报告的越多,我们就越有可能让他们修复它。