燮preSS"资源名称是不是有效的标识符"标识符、名称、有效、资源

2023-09-04 23:52:32 作者:夏の樱

我有它5000+资源字符串的项目。几乎所有的人都在他们的标识符时期。

I have a project with 5000+ resource strings in it. Almost all of them have periods in their identifier.

我们正在切换到自动生成,当然强类型类,以及周期的,因为我们看到几千警告

We're switching over to automatically generating strongly-typed classes, and of course, because of the periods, we see a few thousand warnings

资源名称'嗒嗒'不是一个有效的标识符。

The resource name 'blah' is not a valid identifier.

我知道这是不是,发电机的变化周期为下划线,并且一切都很好。

I know it isn't, the generator changes periods to underscores, and everything is fine.

我可以晚饭preSS的警告?它似乎并不具有关联的数#PRAGMA了。

Can I suppress the warning? It doesn't seem to have an associated number to #pragma away.

推荐答案

我想我可以摄制,虽然它不是晶体中的问题。项目+属性,资源和输入字符串资源的名称,如foo.bar​​触发此警告。

I think I can repro, although it isn't crystal in the question. Project + Properties, Resources and type a string resource name like "foo.bar" triggers this warning.

是的,你不能燮preSS此警告,它是由在IDE中的资源设计器生成。当自动生成的属性\ Resources.resx文件属性\ Resources.Designer.cs文件中的code。看.resx文件,并检查了&LT的name属性;数据> 元素。一个时期的属性值会触发警报。

Yes, you cannot suppress this warning, it is generated by the resource designer in the IDE. When it auto-generates the code from the Properties\Resources.resx file to the Properties\Resources.Designer.cs file. Look at the .resx file and check the "name" attribute on the <data> elements. A period in the attribute value is going to trigger the warning.

一个精心打造的搜索和替换正则表达式可以解决,通过转周期为下划线。这给了我个人的两个问题,我只是编写使用的XDocument一个小程序。另外,请检查您是否还需要这个自动生成的code,听起来像您要更换它。

A carefully crafted search-and-replace with regexp could fix that by turning the periods into underscores. That gives me personally two problems, I'd just write a little program that uses XDocument. Also check if you still need this auto-generated code, sounds like you are replacing it.