.editorconfig 5.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. [*.cs]
  2. # Suppress spurious 'unnecessary suppression' reports.
  3. #
  4. # A load of these come from CA1704. We currently can't use this, but want to reinstate it at some
  5. # point, so we don't want to delete all of the suppression attributes that used to suppress the
  6. # spurious reports the old StyleCop-era CA1704 analyzer produced. We expect to need most of those
  7. # attributes if we manage to re-instate CA1704. But since CA1704 is currently not enabled, these
  8. # suppression attributes would produce an IDE0079 (Remove unnecessary suppression) message. We
  9. # disable IDE0079 for CA1704 so that we can leave these suppressions in place, ready for when
  10. # CA1704 might be restored.
  11. # So why aren't we using CA1704? The CA1704 current analyzer is essentially broken. Microsoft
  12. # never ported this analyzer into the new world of Roslyn-based code analyzers. This is not
  13. # obvious because the source for a new CA1704 analyzer does in fact exist, and it's in the same
  14. # repo as all the supported ones. However, it's deemed to be an unsupported community effort,
  15. # it lives in its own NuGet package (with the surprisingly generic name of Text.Analyzers).
  16. # It has two serious flaws:
  17. # https://github.com/dotnet/roslyn-analyzers/issues/6024 - it can't be configured to ignore
  18. # private symbols
  19. # https://github.com/dotnet/roslyn-analyzers/issues/5183 - its definition of 'unmeaningful' is
  20. # too broad, and can't be disabled
  21. # The first issue could perhaps be circumvented by adding a few entries to a custom dictionary, but
  22. # the second is impossible to work around. The analyzer describes type arguments of the form `T1`,
  23. # `T2` etc as 'meaningless' # and there's no way to stop that. This is a significant problem for Rx,
  24. # because we have quite a lot of methods with large numbers of generic type arguments in which the
  25. # meaning of those type arguments is entirely up to application code, so there's simply no way for
  26. # us to give them meaningful names. As with .NET runtime library types like Action<T1, T2, T3> we
  27. # just use names like T1, T2, T3. The names are deliberately meaningless, because they represent
  28. # placeholders for application types that will signify whatever the application wants to signify.
  29. # So there are no better names, and in any case it would technically be a breaking change to
  30. # rename them. We might be able to deal with this by adding enormous numbers of suppressions, but
  31. # it would be better for the CA1704 analyzer to be fixed - we aren't the only users for which this
  32. # is a major issue.
  33. # We also disable suppression warnings for CA1711. It's currently a mystery why that's being
  34. # reported as unnecessary on ObservableEx, but it is, so we've squelched it.
  35. # IL2060 is considered unnecessary on targets that don't support trimming, but we don't want to wrap every
  36. # single one in a conditional, so we also suppress warnings about unnecessary suppressions on those.
  37. #
  38. # dotnet_remove_unnecessary_suppression_exclusions = CA1704,CA1711,IL2060
  39. #
  40. # Since moving to .NET SDK 9.0, we now get a lot more of these inexplicable IDE0079 warnings, where
  41. # if we remove the suppression that it complains about, we immediately get the warning that the suppression
  42. # is there to prevent. As far as I can tell, every suppression now causes a spurious IDE0079, so we
  43. # just have to disable IDE0079. Presumably there's something odd about this codebase that is confusing
  44. # the IDE0079 diagnostic - it can't be completely broken for everyone, because someone would have
  45. # noticed. I guess this may be related to the curse placed on this codebase by The Great Unification,
  46. # and in particular the corresponding requirement for putting a uap10.0.xxxx TFM on packages that
  47. # really shouldn't have them.
  48. dotnet_diagnostic.IDE0079.severity = silent
  49. # Prevent IDE1006 (Naming rule violation) errors for non-public fields.
  50. #
  51. # Unfortunately, the codebase has not historically been entirely consistent with internal naming
  52. # conventions. Apparently this wasn't noticed by older analyzer tooling, but as of the .NET 7
  53. # era, the naming rules analyzers are a bit more particular, and cannot be configured in a way
  54. # that makes them happy with the code as it stands. We could rename all the relevant symbols,
  55. # but that doesn't seem like an especially good use of time, so for now, we're suppressing
  56. # diagnostics in certain cases.
  57. #
  58. # Static readonly fields
  59. dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = none
  60. # Internal fields
  61. dotnet_naming_symbols.internal_field_symbols.applicable_kinds = field
  62. dotnet_naming_symbols.internal_field_symbols.applicable_accessibilities = internal
  63. dotnet_naming_rule.internal_instance_fields_must_be_camel_cased_underscore_prefix.symbols = internal_field_symbols
  64. dotnet_naming_rule.internal_instance_fields_must_be_camel_cased_underscore_prefix.style = camel_case_and_prefix_with_underscore_style
  65. dotnet_naming_rule.internal_instance_fields_must_be_camel_cased_underscore_prefix.severity = none
  66. # Protected fields
  67. # Annoyingly, a protected field in an internal class cannot be distinguished from a protected field in a public
  68. # class. That's unfortunate, because the latter are publicly visible, but the former are not, so we don't really
  69. # want to enforce public naming conventions on them. We generally avoid publicly visible fields, so the majority
  70. # of protected fields are in fact in internal types, so we use naming conventions appropriate to those.
  71. dotnet_naming_symbols.protected_field_symbols.applicable_kinds = field
  72. dotnet_naming_symbols.protected_field_symbols.applicable_accessibilities = protected
  73. dotnet_naming_rule.protected_instance_fields_must_be_camel_cased_underscore_prefix.symbols = protected_field_symbols
  74. dotnet_naming_rule.protected_instance_fields_must_be_camel_cased_underscore_prefix.style = camel_case_and_prefix_with_underscore_style
  75. dotnet_naming_rule.protected_instance_fields_must_be_camel_cased_underscore_prefix.severity = none
  76. dotnet_style_require_accessibility_modifiers = for_non_interface_members