-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Because these are shipped as two separate packages and particularly because the analyzers are only a development dependency, it's easy for one to use the annotations without also running the analyzers which can lead to analysis holes. If we consolidated the packages, then the analyzers would flow transitively to all consumers of the annotations, making the default case the safe case. This wouldn't prevent someone going out of their way to actively disable the diagnostics, but it removes a pretty easy to set off footgun.
Example
Library A
This library references both Annotations and Analyzers.
[Immutable]
public class Foo { }Library B
This library references Library A, so transitively references Annotations but not Analyzers.
public class Bar : Foo {
public int Mutable { get; set; }
}Application
This application references Library A and B, as well as both Annotations and Analyzers.
[Immutable]
public class Baz {
// No problems here!
public Foo Foo { get; init; }
}
Bar bar = new Bar {
Mutable = 1
};
Baz baz = new Baz {
Foo = bar
};
bar.Mutable += 1; // oh no!Open Questions
- How should TestAnalyzers factor into this?
- How do we transition without breaking existing dependency graphs? e.g. if we move Annotations types to a new lib, how do we avoid name conflicts?