4 ms·
I'm more curious about how things like shitlists are implemented in different languages. Most of my experience is C#, where calling deprecated code triggers a
by gwbas1c 6y ago
I'm more curious about how things like shitlists are implemented in different languages.
Most of my experience is C#, where calling deprecated code triggers a warning.
Considering that C# warnings will fail in CI, how would someone do a C# shitlist? Would it require some kind of #pragma, that would stick out like a sore thumb in a code review
- tantalor 6y agoMy preference is when violating the shitlist is a compile/build/lint error.
- ben509 6y agoI think if warnings can't do the job, you'd have to go the route of writing a test that greps the codebase for usages. Maybe a custom linter could also do the trick. The ability to grandfather in existing violations, though, is something most build tools are likely to have trouble with. Maybe another way to do it is to have warnings fail CI, but grep out the known offenders from stderr. None of that sounds elegant to me, but it _is_ a shitlist.
- ivraatiems 6y agoConsider using the [Obsolete] attribute on methods or other entities you don't want people to keep using: https://docs.microsoft.com/en-us/dotnet/api/system.obsoleteattribute?view=net-5.0 https://docs.microsoft.com/en-us/dotnet/api/system.obsoletea... This results in syntax highlighting in Visual Studio and warnings on compilation when somebody tries to use the method.
- jonathanlydall 6y agoThat is pretty much what we do on our C# code base. We treat warnings as errors and use #pragmas in cases where obsolete members are used. When marking members as obsolete we require it be commented with a Jira issue number to make sure removing it is not forgotten. I also strongly encourage that an XML Document Comment is added with a <see cref=""/> to the replacement member which is navigable to by the IDE. Finally, reviewers of the PRs just need to make sure these rules are applied, but it’s easy to spot #pragmas.