Support for ICU API Status #80
Replies: 3 comments 11 replies
-
Thanks Shad for pulling this all together and laying out the lay of the land. My first thought is that I would want to be able to call the experimental APIs unless there was a chance it's core underlying functionality might be going away. If the API changes form in the future, that's fine, as long as there is some way for me to migrate my code to the changed API. I personally like the attribute approach to marking the experimental APIs. I'd also like the XML summary of the method to indicate it's "Experimental:" or something like that. If I had that, then I don't personally care if there is a Roslyn code analyzer to warn me. In fact, I might even prefer there wasn't. It's probably worth noting that this approach is a bit like how LuceneNET starts the XML summary of a method with Expert: for many of it's advanced methods. I found this approach very helpful when I was first learning LuceneNET. For an example see the NumericTokenStream class. |
Beta Was this translation helpful? Give feedback.
-
I think based on the feedback that the explanation of API Status was not broad or deep enough. Part of that was due to my lack of knowledge of the subject, so I dug a bit deeper. ICU4J Doesn't Provide Conditional Compilation Like ICU4JI suspect the reason for this is because the main distribution channel is through Maven. While it is possible for front-end developers to work with custom builds of libraries in some cases, it presents problems when the consumer also has a library distributed through a package manager such as Maven. So, the APIs are either released publicly or not. In the case of It seems we are in the same boat when deploying through NuGet. API Status is a Subset of Javadoc TagsICU4J uses javadoc to create various reports about tags including API Status. None of these tools seem to do any updates. Apparently they are done manually. The tools are in this directory: https://github.com/unicode-org/icu/tree/36061ccee26bd54b2e72e11e0c662034e8f4511c/icu4j/tools/build/src/main/java/com/ibm/icu/dev/tool/docs There is a README here: https://github.com/unicode-org/icu/blob/36061ccee26bd54b2e72e11e0c662034e8f4511c/icu4j/tools/build/README.txt The valid tags are:
The valid API Statuses are:
There are basically 3 things that need addressing, and they have different priorities.
API Status is a policy that applies to the entire public API surface (with a few exceptions). Every public API must have a status. It is important that users are aware of the status of each API and so they are aware of the implications if they don't use a stable part of it. Once an API is marked stable, it will always exist and will always function (as far as I can tell), even if it is later deprecated. Enforcing API StatusAs far as I can tell, there are only 2 options for this:
Frankly, given how important this is, I think the code analyzer is the only way to go here. It will help to ensure the policy is always adhered to. It will provide quick links to the exact spots in the code that need to be cleaned up and one or more code fixes can insert the snippet to fix the issue. Generating the text report in the build may also be useful, especially if the release procedure is setup to commit these reports to be compared across versions. However, it is much more work to use reports to enforce policies than analyzers and code fixes. The analyzer should take priority, IMO. Determining the Visibility and/or Accessibility for Each StatusThese are my opinion:
|
Beta Was this translation helpful? Give feedback.
-
Later you say @internal is Public. Not Visible. Can you elaborate about what Not Visible means? And the idea that something that is internal is Public seems very odd to me coming from the .NET world. I think I don't understand.
I agree with this statement.
That's fine, and certainly a conservative approach, but the first thing I'm going to do if I'm using that library is turn those warnings off. When I code against a method in the library, I'll look at intelligence for it and I expect it to tell me its status. If that's crystal clear in intellisense then I'm good to go, and I wouldn't be surprised if many other devs feel the same way. All of these alerts in tooling are like training wheels, and sometimes they are great, but often they just get in the way of being productive (my perspective). The one exception is depreciated given that it's typically added AFTER it was ok to use the method. So getting alerted to the change is helpful in my opinion.
Absolutely. To me, this is far more important than build warnings.
Totally agree.
I'm ok with this approach, but I see it as an extra bell and whistle. It's nice. But it's the kind of thing I personally wouldn't delay a production release to implement. That said, I have no issue if you want to go this route.
I guess I don't really understand the references to using @internal, @draft, or @stable tag. This is from the java world, right, so in .NET it would need to be internal, DraftAttribute, or StableAttribute. Correct? |
Beta Was this translation helpful? Give feedback.
-
I have been mulling over how to support the ICU API statuses for quite some time and think it is time to have a discussion about it. This is a very important thing to get done right before the production release. The documentation for API and Docs as well as the API Compatibility docs are pretty detailed and it looks like they have some automation built around this to investigate.
Internal Status
One thing that is really annoying is that if we port
@internal
in Java to[Obsolete]
in .NET, we end up with a bunch of suppression code to get rid of the warnings everywhere. So, this is definitely not the answer. Marking them internal also doesn't really seem to be the best answer as some APIs cannot be marked internal (for example, when a subclass needs to be public).This really depends on how much extensibility a user needs. I am leaning toward making them internal and relying on the new UnsafeAccessorAttribute for any users that dare to call the functionality.
If it is made public (even if hidden), we would ideally have a custom Roslyn code analyzer warning if a user accesses such an API. This would allow us to globally suppress the warning internally without also suppressing valid warnings for obsolete APIs that we may be calling.
Draft Status
These APIs are released in "preview" called draft status. This means that the API is unstable even though it is in a stable library release. My thought here is to make them both visible and public, but provide a custom Roslyn code analyzer warning.
Deprecated and Obsolete Status
These both sound like valid things that
[ObsoleteAttribute]
should cover, although I don't know offhand why there are 2 different statuses.Impl Namespace
One thing I found interesting is that when I looked through the javadocs for ICU4J, they don't list any of the classes in the
impl
package. This kind of makes me think that the right choice for these is to hide them from the IDE at least and perhaps mark them internal. Marking them internal would significantly cut down on the number of public APIs that we need to prepare for release, though.Conditional Compilation
Microsoft contributed some compilation constants upstream from their copy of ICU4C. They set it up so all of these unstable APIs would be compiled out of the release to prevent their team from accidentally calling them.
This solves the problem quickly, but to me it seems like the draft APIs should at least be made available so users can start exploring the experimental functionality.
Technically, much of what we are doing is experimental, so if we went that route on our first release, the API would be so barren it would probably be hard to use.
Custom/Built-in Attributes
IMO, this feels like the right choice in .NET rather than burying API statuses in the API docs. Attributes can be made to drive both the Roslyn code analyzer warnings and control how the API docs are generated. But it would probably be worth digging into the automation that ICU built to see if there is more to this that we should be aware of.
Beta Was this translation helpful? Give feedback.
All reactions