- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最大的烦恼之一是 API 的功能与普通用户的直觉不符。
切入点:.NET 的 DateTime.ToUniversalTime .文档很吓人:
On Windows XP systems, the ToUniversalTime method recognizes only the current adjustment rule when converting from local time to UTC. As a result, conversions for periods before the current adjustment rule came into effect may not accurately reflect the difference between local time and UTC.
然后继续说:
On Windows XP systems, the ToUniversalTime method recognizes only the current adjustment rule for the local time zone, which it applies to all dates, including down-level dates (that is, dates that are earlier than the starting date of the current adjustment rule). Applications running on Windows XP that require historically accurate local date and time calculations must work around this behavior by using the FindSystemTimeZoneById method to retrieve a TimeZoneInfo object that corresponds to the local time zone and calling its TimeZoneInfo.ConvertTimeToUtc(DateTime, TimeZoneInfo) method.
这一定是有史以来最搞笑的文档句子。谁在使用 ToUniversalTime() 时不需要准确的本地日期和时间计算?为什么不使用 ObsoleteAttribute 标记此方法?
无论如何,我正在寻找的是一个可以用程序集级元数据标记程序集的工具,例如 [RequiresHistoricallyAccurateLocalDateAndTimeCalculationsAttribute]。然后,如果它找到任何 ToUniversalTime() 实例,将它们标记为编译器错误,就像 C# 不允许我在没有不安全注释的情况下直接访问非托管代码一样。
最佳答案
这个需求似乎更适合代码分析而不是属性修饰或者编译错误。
参见:http://www.binarycoder.net/fxcop/html/index.html
This has to be the single most hilarious sentence of documentation ever created. Who doesn't require accurate local date and time calculations when using ToUniversalTime()? Why not just mark this method with ObsoleteAttribute?
鉴于日期/时间计算的性质/复杂性,这并不是一个特别可怕/令人震惊的启示。
如果我在 Windows XP 或任何其他操作系统上进行 UTC 处理,我会首先熟悉该平台的特性,就像我了解几乎所有其他复杂操作一样。给出的替代方案 (TimeZoneInfo
) 也不是万无一失的,因为它高度依赖于平台。
关于 TimeZoneInfo
的平台依赖性......我指的是操作系统。
当您开始使用时区转换(许多与日期相关的问题都源于此)时,您会使用类似 FindSystemTimeZoneById 的方法.从好的方面来说,方法名称清楚地表明您正在使用本地系统(因此它可能比 ToUniversalTime()
更明确)。但是,操作系统会查询时区列表,因此操作系统可能会返回一个错误列表(我相信 Windows 中的值存在于注册表中),该列表已过时(可能是一台打补丁的机器)等
我注意到 Windows XP 似乎也有 ambiguity TimeZoneInfo
的问题(请参阅“调用者注意事项”):
On Windows XP systems (...) As a result, the method may not accurately report ambiguous time offsets for periods before the current adjustment rule came into effect. For more information, see the Notes for Callers section in the Local property.
并且(正如您所指出的)底层平台实现可能存在缺陷。
此外,时区由字符串 ID 引用。虽然这些似乎没有太大变化,但仍然有可能在应用程序中存储不再匹配时区的“魔术字符串”。
至少这是我所发现的,尽管我对这个主题的了解远非详尽无遗。我在 Windows Server 上使用 .Net 和世界时的经验是积极的。
我的观点是,BCL(基类库)作者以某种方式实现事物通常有充分的理由,即使它确实导致了意外行为。另一种方法是完全省略该功能。
如果您认为这是一个陷阱,那么我认为值得称赞的是您花时间来缓解它。
关于c# - 有没有C#静态分析工具可以抓取不满足功能需求的API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11959880/
您能否提供有关网站社交网络(例如 Facebook)类型(功能性、非功能性和用户要求)要求的示例? 提前谢谢 最佳答案 以下是 Facebook 应具备的要求的一些示例。然而,值得一提的是:对于每种类
我需要在另一个 Java 项目的 liferay 模块项目中使用一些类。我正在使用 gradle,当我部署应用程序时,即使 gradle 编译了我的 jar 文件,我也会收到 Unresolved 需
我最近发现了类似于button.setText(“Hello World”);的代码行如果您按如下方式分配按钮,则 onCreate() 方法中将抛出 nullPointerException: B
我有一些基于成本的供应链管理代码,其中供应尝试满足需求,但这仅在供应大于需求时才有效。有什么方法可以优化它以两种方式工作(即当 supply > demand 和 supply = model.dem
好吧,我快想多了。有没有一种方法可以组合接口(interface)和属性,使实现类中的特性属性满足接口(interface)契约? 在我的应用程序中,我想显示一个事件列表,它是系统中事件的集合,例如新
我想创建一个模型,在每个步骤中预测每个产品在多周内的 future 需求(预测每个产品明年的每周需求) 我有一些小尺寸(大约 100-200 条记录)的 csv。 这里有关 CSV 列的信息:- 第一
我有一个包含我所有依赖项的 requirements.txt 文件,但它没有被正确处理: pip install -r requirements.txt 后,我得到以下 pip freeze: arg
我对 Java EE 应用程序的性能测量(CPU 和磁盘 I/O 需求)很感兴趣。 对于CPU 我已经想出了如何测量每个方法调用的CPU 需求。通过在每个方法的开始和结束时调用 java.lang.m
如何获取从 yaml 文件创建的管道的需求? yaml 文件包含需求: ... jobs: - job: my_job displayName: My Job pool: name:
我的目标: 构建一个 AngularJS 服务 (MapService),它初始化 (MapService.initMap()) 第 3 方控件 (Esri ArcGIS Map) 并返回对我的 ma
我在我的一个项目中使用了 redis,并且有一个带有 redis = Redis.new 的初始化器并使用了 redis gem。问题是,如果 Redis 没有运行,我将无法执行简单的数据库迁移之类的
如果我们有三个模块名称 A、B 和 C,那么模块 A 需要 B 和 B 需要 C:这个调用会产生什么效果? var A = proxyquire('A', {'C': mockedModule}) 模
我正在为 Liferay 7 开发一些功能。我知道仍处于 beta 版本,但我在 OSGi 包依赖项方面遇到了一些麻烦。当我尝试部署服务项目时,部署时发生错误 Unresolved requireme
我有一个 list 文件 partials.js,其中包含: //= require_tree ./partials 然后 ./partials/ 中的每个咖啡文件都包含以下内容: $ -> #
在 brew 中有没有一种方法或特殊命令可以将安装的包卡住到 requirements.txt 文件中,就像在 python 中使用 pip 一样?然后从该文件快速重新安装它们? 最佳答案 使用Hom
我正在尝试在 g1 GKE 实例(g1 实例有 1 个 vCPU,或 1000 毫核)中运行一个小型应用程序,并且在调度 pod 时遇到 CPU 请求限制问题。有 4 个 pod,每个都是应用程序的不
我们计划为我们的 C++ 代码建立柯南存储库。我们只想向开发人员公开依赖项列表 (lib/version@user/channel),而不是我们放在 conanfile.py 中的逻辑检查。这个包装器
我正在尝试研究 Varnish 。 我的问题是。我确实有一个主要请求/响应,我想使用 Varnish 缓存它。 html结构内部有ESI标签。我想要很多。一个标签具有较长的 ttl,其他标签则具有 t
我有一个在运行时或编译/链接时连接接口(interface)的问题或最佳方法。对于我的嵌入式项目,设备驱动程序和 I/O 具有需要绑定(bind)(即粘合)到其相应接口(interface)依赖项的接
我有一个我创建的协议(protocol)(在 Swift 4.2 中),它的要求之一是一个与协议(protocol)本身类型相同的属性。 例如,我有一个这样定义的协议(protocol): proto
我是一名优秀的程序员,十分优秀!