我什么时候应该在 .NET 应用程序中实现全球化和本地化?
我正在清理我编写的 C# 应用程序中的一些代码,并真正尝试专注于最佳实践和编码风格。因此,我通过 FXCop 运行我的程序集,并尝试研究它给我的每条消息,以决定哪些内容应该更改,哪些内容不应该更改。我目前关注的是区域设置。例如,我当前遇到的两个错误是我应该为 Convert.ToString(int) 指定 IFormatProvider 参数,并设置数据集和数据表区域设置。这是我从来没有做过的事情,也从来没有考虑过。我总是把超负荷的事情排除在外。
我当前正在开发的应用程序是一家小公司的内部应用程序,很可能永远不需要在另一个国家/地区运行。因此,我认为我根本不需要设置这些。另一方面,这样做也没什么大不了的,但似乎没有必要,并且可能会在一定程度上妨碍可读性。
据我所知,微软的主张是如果有的话就使用它,就这样。好吧,从技术上讲,我应该在每个实现 IDisposable 的对象上调用 Dispose(),但我懒得对数据集和数据表这样做。我想知道小型内部应用程序的全球化和本地化实践是“疯狂的”。
I am cleaning up some code in a C# app that I wrote and really trying to focus on best practices and coding style. As such, I am running my assembly through FXCop and trying to research each message it gives me to decide what should and shouldn't be changed. What I am currently focusing on are locale settings. For instance, the two errors that I have currently are that I should be specifying the IFormatProvider parameter for Convert.ToString(int), and setting the Dataset and Datatable locale. This is something that I've never done, and never put much thought into. I've always just left that overload out.
The current app that I am working on is an internal app for a small company that will very likely never need to run in another country. As such, it is my opinion that I do not need to set these at all. On the other hand, doing so would not be such a big deal, but it seems like it is unneccessary and could hinder readability to a degree.
I understand that Microsoft's contention is to use it if it's there, period. Well, I'm technically supposed to call Dispose() on every object that implements IDisposable, but I don't bother doing that with Datasets and Datatables. I wonder what the practice in regards to globalization and localization on small-scale internal apps is "in the wild."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通常会忽略小型内部应用程序的此类警告。请记住,FXCop 的目的是确保您的代码适合框架,并非所有代码都与您相关,我总是在构建应用程序时禁用各种我认为不适合应用程序的规则。
尽管我会在实现它们的任何类上调用 Disponse,但如果它们现在不执行任何操作也没关系,该类的升级版本可能会开始泄漏一些重要的内容,这是一个值得养成的好习惯。
I usually ignore those kinds of warnings for small internal apps. Remember that FXCop is meant to make sure that your code is good for a framework, not all of them might be relevant to you, I always disable various rules that I don't think fits with the applications as I build them.
Though I would call Disponse on any classes that implements them, doesn't matter if they don't do anything now, an upgraded version of the class might start leaking something essential, and it's a good habit to get into.