Skip to content

Add Roslyn analyser to block DateTime Now properties - #5904

Open
rbev wants to merge 3 commits into
masterfrom
time-analyser
Open

rbev wants to merge 3 commits into
masterfrom
time-analyser

Conversation

@rbev

@rbev rbev commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Follow up from #5843

Adds new entries to the BannedSymbols.txt file to discourage direct usage of certain date and time properties. Instead, it recommends using TimeProvider as a replacement.

@warwickschroeder warwickschroeder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the BannedSymbols file even used/referenced? There should be warnings but there arnt.

ExpirationDate = DateTime.UtcNow.Date.AddDays(-2), //HasLicenseDateExpired uses a grace period of 1 day

Also, once wired up would throw errors in CI as it treats warnings as errors.

Should "DateTime.Today" be banned as well?

@rbev

rbev commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Is the BannedSymbols file even used/referenced? There should be warnings but there arnt.

ExpirationDate = DateTime.UtcNow.Date.AddDays(-2), //HasLicenseDateExpired uses a grace period of 1 day

Also, once wired up would throw errors in CI as it treats warnings as errors.

Should "DateTime.Today" be banned as well?

That's so strange, I was surprised I got no errors so I added a reference, it wasn't a warning it completely failed the build locally without a #pragma. I didn't go searching, I just assumed you did an amazing job removing them all.

I'll look into why those ones don't create errors.

@rbev rbev changed the title Add roslyn analyser to block DateTime Now properties Add Roslyn analyser to block DateTime Now properties Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants