Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromdotnet/corert

Commitb503742

Browse files
committed
Feedback comments
1 parentf79f7c8 commitb503742

14 files changed

+114
-164
lines changed

‎src/Common/src/Interop/Windows/kernel32/Interop.FileTimeToSystemTime.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal partial class Interop
99
{
1010
internalpartialclassKernel32
1111
{
12-
[DllImport(Libraries.Kernel32,SetLastError=true)]
13-
internalstaticunsafeexternboolFileTimeToSystemTime(reflonglpFileTime,refFullSystemTimelpSystemTime);
12+
[DllImport(Libraries.Kernel32)]
13+
internalstaticunsafeexternboolFileTimeToSystemTime(inlonglpFileTime,outInterop.Kernel32.SYSTEMTIMElpSystemTime);
1414
}
1515
}

‎src/Common/src/Interop/Windows/kernel32/Interop.FullSystemTime.cs‎

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ internal partial class Interop
99
{
1010
internalpartialclassKernel32
1111
{
12-
// FullSystemTime struct matches Windows SYSTEMTIME struct, except we added the extrananoSeconds field to store
12+
// FullSystemTime struct matches Windows SYSTEMTIME struct, except we added the extrahundredNanoSecond field to store
1313
// more precise time.
1414
[StructLayout(LayoutKind.Sequential)]
1515
internalstructFullSystemTime
1616
{
17+
internalInterop.Kernel32.SYSTEMTIMEsystemTime;
18+
internallonghundredNanoSecond;
19+
1720
internalFullSystemTime(intyear,intmonth,DayOfWeekdayOfWeek,intday,inthour,intminute,intsecond)
1821
{
19-
wYear=(ushort)year;
20-
wMonth=(ushort)month;
21-
wDayOfWeek=(ushort)dayOfWeek;
22-
wDay=(ushort)day;
23-
wHour=(ushort)hour;
24-
wMinute=(ushort)minute;
25-
wSecond=(ushort)second;
26-
wMillisecond=0;
22+
systemTime.Year=(ushort)year;
23+
systemTime.Month=(ushort)month;
24+
systemTime.DayOfWeek=(ushort)dayOfWeek;
25+
systemTime.Day=(ushort)day;
26+
systemTime.Hour=(ushort)hour;
27+
systemTime.Minute=(ushort)minute;
28+
systemTime.Second=(ushort)second;
29+
systemTime.Milliseconds=0;
2730
hundredNanoSecond=0;
2831
}
2932

@@ -34,26 +37,17 @@ internal FullSystemTime(long ticks)
3437
intyear,month,day;
3538
dt.GetDatePart(outyear,outmonth,outday);
3639

37-
wYear=(ushort)year;
38-
wMonth=(ushort)month;
39-
wDayOfWeek=(ushort)dt.DayOfWeek;
40-
wDay=(ushort)day;
41-
wHour=(ushort)dt.Hour;
42-
wMinute=(ushort)dt.Minute;
43-
wSecond=(ushort)dt.Second;
44-
wMillisecond=(ushort)dt.Millisecond;
40+
systemTime.Year=(ushort)year;
41+
systemTime.Month=(ushort)month;
42+
systemTime.DayOfWeek=(ushort)dt.DayOfWeek;
43+
systemTime.Day=(ushort)day;
44+
systemTime.Hour=(ushort)dt.Hour;
45+
systemTime.Minute=(ushort)dt.Minute;
46+
systemTime.Second=(ushort)dt.Second;
47+
systemTime.Milliseconds=(ushort)dt.Millisecond;
4548
hundredNanoSecond=0;
4649
}
4750

48-
internalushortwYear;
49-
internalushortwMonth;
50-
internalushortwDayOfWeek;
51-
internalushortwDay;
52-
internalushortwHour;
53-
internalushortwMinute;
54-
internalushortwSecond;
55-
internalushortwMillisecond;
56-
internallonghundredNanoSecond;
5751
};
5852
}
5953
}

‎src/Common/src/Interop/Windows/kernel32/Interop.GetProcessInformation.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal partial class Kernel32
1111
{
1212
internalconstintProcessLeapSecondInfo=8;
1313

14-
[DllImport(Libraries.Kernel32,SetLastError=true,CharSet=CharSet.Unicode,ExactSpelling=true)]
14+
[DllImport(Libraries.Kernel32)]
1515
internalstaticexternboolGetProcessInformation(IntPtrhProcess,intProcessInformationClass,reflongprocessInformation,intProcessInformationSize);
1616
}
1717
}

‎src/Common/src/Interop/Windows/kernel32/Interop.SystemTimeToFileTime.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ internal partial class Interop
88
{
99
internalpartialclassKernel32
1010
{
11-
// api-ms-win-core-timezone-l1-1-0.dll
12-
[DllImport(Libraries.Kernel32,SetLastError=true)]
13-
internalstaticexternboolSystemTimeToFileTime(refFullSystemTimelpSystemTime,outlonglpFileTime);
11+
[DllImport(Libraries.Kernel32)]
12+
internalstaticexternboolSystemTimeToFileTime(inInterop.Kernel32.SYSTEMTIMElpSystemTime,outlonglpFileTime);
1413
}
1514
}

‎src/Common/src/Interop/Windows/kernel32/Interop.TzSpecificLocalTimeToSystemTime.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ internal partial class Interop
99
{
1010
internalpartialclassKernel32
1111
{
12-
[DllImport(Libraries.Kernel32,SetLastError=true)]
13-
internalstaticexternboolTzSpecificLocalTimeToSystemTime(IntPtrlpTimeZoneInformation,refFullSystemTimelpLocalTime,refFullSystemTimelpUniversalTime);
12+
[DllImport(Libraries.Kernel32)]
13+
internalstaticexternboolTzSpecificLocalTimeToSystemTime(
14+
IntPtrlpTimeZoneInformation,
15+
inInterop.Kernel32.SYSTEMTIMElpLocalTime,
16+
outInterop.Kernel32.SYSTEMTIMElpUniversalTime);
1417
}
1518
}

‎src/Common/src/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs‎renamed to ‎src/System.Private.CoreLib/shared/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ internal partial class Interop
99
{
1010
internalpartialclassNtDll
1111
{
12-
[DllImport(Libraries.NtDll,SetLastError=true)]
13-
internalstaticunsafeexternintNtQuerySystemInformation(intSystemInformationClass,void*SystemInformation,intSystemInformationLength,IntPtrReturnLength);
12+
[DllImport(Libraries.NtDll)]
13+
internalstaticunsafeexternintNtQuerySystemInformation(intSystemInformationClass,void*SystemInformation,intSystemInformationLength,uint*ReturnLength);
1414

1515
[StructLayout(LayoutKind.Sequential)]
1616
internalstructSYSTEM_LEAP_SECOND_INFORMATION

‎src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@
859859
<CompileInclude="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs" />
860860
<CompileInclude="$(MSBuildThisFileDirectory)Interop\Windows\Normaliz\Interop.Idna.cs"Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" />
861861
<CompileInclude="$(MSBuildThisFileDirectory)Interop\Windows\Normaliz\Interop.Normalization.cs"Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" />
862+
<CompileInclude="$(MSBuildThisFileDirectory)Interop\Windows\NtDll\Interop.NtQuerySystemInformation.cs"Condition="'$(EnableWinRT)' != 'true'" />
862863
<CompileInclude="$(MSBuildThisFileDirectory)Interop\Windows\Ole32\Interop.CoCreateGuid.cs" />
863864
<CompileInclude="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysAllocStringLen.cs" />
864865
<CompileInclude="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysFreeString.cs" />

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

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public DateTime(int year, int month, int day, Calendar calendar)
196196
//
197197
publicDateTime(intyear,intmonth,intday,inthour,intminute,intsecond)
198198
{
199-
if(second==60&&s_isLeapSecondsSupportedSystem&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,DateTimeKind.Unspecified))
199+
if(second==60&&s_systemSupportsLeapSeconds&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,DateTimeKind.Unspecified))
200200
{
201201
// if we have leap second (second = 60) then we'll need to check if it is valid time.
202202
// if it is valid, then we adjust the second to 59 so DateTime will consider this second is last second
@@ -214,7 +214,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second,
214214
thrownewArgumentException(SR.Argument_InvalidDateTimeKind,nameof(kind));
215215
}
216216

217-
if(second==60&&s_isLeapSecondsSupportedSystem&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,kind))
217+
if(second==60&&s_systemSupportsLeapSeconds&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,kind))
218218
{
219219
// if we have leap second (second = 60) then we'll need to check if it is valid time.
220220
// if it is valid, then we adjust the second to 59 so DateTime will consider this second is last second
@@ -236,7 +236,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second,
236236
thrownewArgumentNullException(nameof(calendar));
237237

238238
intoriginalSecond=second;
239-
if(second==60&&s_isLeapSecondsSupportedSystem)
239+
if(second==60&&s_systemSupportsLeapSeconds)
240240
{
241241
// Reset the second value now and then we'll validate it later when we get the final Gregorian date.
242242
second=59;
@@ -264,7 +264,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second,
264264
thrownewArgumentOutOfRangeException(nameof(millisecond),SR.Format(SR.ArgumentOutOfRange_Range,0,MillisPerSecond-1));
265265
}
266266

267-
if(second==60&&s_isLeapSecondsSupportedSystem&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,DateTimeKind.Unspecified))
267+
if(second==60&&s_systemSupportsLeapSeconds&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,DateTimeKind.Unspecified))
268268
{
269269
// if we have leap second (second = 60) then we'll need to check if it is valid time.
270270
// if it is valid, then we adjust the second to 59 so DateTime will consider this second is last second
@@ -291,7 +291,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second,
291291
thrownewArgumentException(SR.Argument_InvalidDateTimeKind,nameof(kind));
292292
}
293293

294-
if(second==60&&s_isLeapSecondsSupportedSystem&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,kind))
294+
if(second==60&&s_systemSupportsLeapSeconds&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,kind))
295295
{
296296
// if we have leap second (second = 60) then we'll need to check if it is valid time.
297297
// if it is valid, then we adjust the second to 59 so DateTime will consider this second is last second
@@ -320,7 +320,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second,
320320
}
321321

322322
intoriginalSecond=second;
323-
if(second==60&&s_isLeapSecondsSupportedSystem)
323+
if(second==60&&s_systemSupportsLeapSeconds)
324324
{
325325
// Reset the second value now and then we'll validate it later when we get the final Gregorian date.
326326
second=59;
@@ -356,7 +356,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second,
356356
}
357357

358358
intoriginalSecond=second;
359-
if(second==60&&s_isLeapSecondsSupportedSystem)
359+
if(second==60&&s_systemSupportsLeapSeconds)
360360
{
361361
// Reset the second value now and then we'll validate it later when we get the final Gregorian date.
362362
second=59;
@@ -427,8 +427,6 @@ private DateTime(SerializationInfo info, StreamingContext context)
427427
}
428428
}
429429

430-
431-
432430
internallongInternalTicks
433431
{
434432
get
@@ -804,6 +802,23 @@ public static DateTime FromFileTime(long fileTime)
804802
returnFromFileTimeUtc(fileTime).ToLocalTime();
805803
}
806804

805+
publicstaticDateTimeFromFileTimeUtc(longfileTime)
806+
{
807+
if(fileTime<0||fileTime>MaxTicks-FileTimeOffset)
808+
{
809+
thrownewArgumentOutOfRangeException(nameof(fileTime),SR.ArgumentOutOfRange_FileTimeInvalid);
810+
}
811+
812+
if(s_systemSupportsLeapSeconds)
813+
{
814+
returnFromFileTimeLeapSecondsAware(fileTime);
815+
}
816+
817+
// This is the ticks in Universal time for this fileTime.
818+
longuniversalTicks=fileTime+FileTimeOffset;
819+
returnnewDateTime(universalTicks,DateTimeKind.Utc);
820+
}
821+
807822
// Creates a DateTime from an OLE Automation Date.
808823
//
809824
publicstaticDateTimeFromOADate(doubled)
@@ -1296,6 +1311,25 @@ public long ToFileTime()
12961311
returnToUniversalTime().ToFileTimeUtc();
12971312
}
12981313

1314+
publiclongToFileTimeUtc()
1315+
{
1316+
// Treats the input as universal if it is not specified
1317+
longticks=((InternalKind&LocalMask)!=0)?ToUniversalTime().InternalTicks:this.InternalTicks;
1318+
1319+
if(s_systemSupportsLeapSeconds)
1320+
{
1321+
returnToFileTimeLeapSecondsAware(ticks);
1322+
}
1323+
1324+
ticks-=FileTimeOffset;
1325+
if(ticks<0)
1326+
{
1327+
thrownewArgumentOutOfRangeException(null,SR.ArgumentOutOfRange_FileTimeInvalid);
1328+
}
1329+
1330+
returnticks;
1331+
}
1332+
12991333
publicDateTimeToLocalTime()
13001334
{
13011335
returnToLocalTime(false);
@@ -1650,7 +1684,7 @@ internal static bool TryCreate(int year, int month, int day, int hour, int minut
16501684

16511685
if(second==60)
16521686
{
1653-
if(s_isLeapSecondsSupportedSystem&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,DateTimeKind.Unspecified))
1687+
if(s_systemSupportsLeapSeconds&&IsValidTimeWithLeapSeconds(year,month,day,hour,minute,second,DateTimeKind.Unspecified))
16541688
{
16551689
// if we have leap second (second = 60) then we'll need to check if it is valid time.
16561690
// if it is valid, then we adjust the second to 59 so DateTime will consider this second is last second

‎src/System.Private.CoreLib/shared/System/DateTimeOffset.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public DateTimeOffset(int year, int month, int day, int hour, int minute, int se
111111
_offsetMinutes=ValidateOffset(offset);
112112

113113
intoriginalSecond=second;
114-
if(second==60&&DateTime.s_isLeapSecondsSupportedSystem)
114+
if(second==60&&DateTime.s_systemSupportsLeapSeconds)
115115
{
116116
// Reset the leap second to 59 for now and then we'll validate it after getting the final UTC time.
117117
second=59;
@@ -133,7 +133,7 @@ public DateTimeOffset(int year, int month, int day, int hour, int minute, int se
133133
_offsetMinutes=ValidateOffset(offset);
134134

135135
intoriginalSecond=second;
136-
if(second==60&&DateTime.s_isLeapSecondsSupportedSystem)
136+
if(second==60&&DateTime.s_systemSupportsLeapSeconds)
137137
{
138138
// Reset the leap second to 59 for now and then we'll validate it after getting the final UTC time.
139139
second=59;
@@ -155,7 +155,7 @@ public DateTimeOffset(int year, int month, int day, int hour, int minute, int se
155155
_offsetMinutes=ValidateOffset(offset);
156156

157157
intoriginalSecond=second;
158-
if(second==60&&DateTime.s_isLeapSecondsSupportedSystem)
158+
if(second==60&&DateTime.s_systemSupportsLeapSeconds)
159159
{
160160
// Reset the leap second to 59 for now and then we'll validate it after getting the final UTC time.
161161
second=59;

‎src/System.Private.CoreLib/src/System.Private.CoreLib.csproj‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@
370370
<CompileInclude="..\..\Common\src\Interop\Windows\kernel32\Interop.TzSpecificLocalTimeToSystemTime.cs">
371371
<Link>Interop\Windows\kernel32\Interop.TzSpecificLocalTimeToSystemTime.cs</Link>
372372
</Compile>
373-
<CompileInclude="..\..\Common\src\Interop\Windows\NtDll\Interop.NtQuerySystemInformation.cs"Condition="'$(EnableWinRT)'!='true'">
374-
<Link>Interop\Windows\NtDll\Interop.NtQuerySystemInformation.cs</Link>
375-
</Compile>
376373
<CompileInclude="..\..\Common\src\Interop\Windows\kernel32\Interop.GetProcessInformation.cs"Condition="'$(EnableWinRT)'=='true'">
377374
<Link>Interop\Windows\kernel32\Interop.GetProcessInformation.cs</Link>
378375
</Compile>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp