Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1a5246d

Browse files
committedFeb 28, 2024
Adding suppressions for cs/leap-year/unsafe-date-construction-from-two-elements
1 parent 17fa327 commit 1a5246d

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed
 

‎src/libraries/System.Management/src/System/Management/ManagementDateTime.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public static DateTime ToDateTime(string dmtfDate)
193193
throw new ArgumentOutOfRangeException(nameof(dmtfDate));
194194
}
195195

196-
196+
// codeql[cs/leap-year/unsafe-date-construction-from-two-elements] - DateTime not constructed from multiple elements - it's parsed from a string.
197197
var datetime = new DateTime(year, month, day, hour, minute, second, 0, DateTimeKind.Local);
198198
// Then add the ticks calculated from the microseconds
199199
datetime = datetime.AddTicks(ticks);

‎src/libraries/System.Private.CoreLib/src/System/DateTime.cs

+1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second)
332332
else
333333
{
334334
// if we have a leap second, then we adjust it to 59 so that DateTime will consider it the last in the specified minute.
335+
// codeql[cs/leap-year/unsafe-date-construction-from-two-elements] - DateTime is constructed using the user specifed values, not a combination of different sources.
335336
this = new DateTime(year, month, day, hour, minute, 59);
336337
ValidateLeapSecond();
337338
}

‎src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ internal EraInfo(int era, int startYear, int startMonth, int startDay, int yearO
3535
this.yearOffset = yearOffset;
3636
this.minEraYear = minEraYear;
3737
this.maxEraYear = maxEraYear;
38+
// codeql[cs/leap-year/unsafe-date-construction-from-two-elements] - DateTime is constructed using the user specifed values, not a combination of different sources.
3839
this.ticks = new DateTime(startYear, startMonth, startDay).Ticks;
3940
this.eraName = eraName;
4041
this.abbrevEraName = abbrevEraName;

‎src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdDateTime.cs

+1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ public static implicit operator DateTime(XsdDateTime xdt)
396396
{
397397
case DateTimeTypeCode.GMonth:
398398
case DateTimeTypeCode.GDay:
399+
// codeql[cs/leap-year/unsafe-date-construction-from-two-elements] - DateTime not constructed from multiple elements - it's converted from an XsdDateTime.
399400
result = new DateTime(DateTime.Now.Year, xdt.Month, xdt.Day);
400401
break;
401402
case DateTimeTypeCode.Time:

0 commit comments

Comments
 (0)
Please sign in to comment.