1

I am trying to see the actual implementation detail of System.Management.ManagementDateTimeConverter.ToDateTime(string) using ILspy? It didn't show anything. Then I thought it's probably a bug in ILSpy and tried to see the decompiled code using Reflector - but it also doesn't show details (please see below code snippet) either.

Basically I am trying to see how the cim datetime will be parsed - for details, you may refer to: (What format is this time value in? , Parse CIM_DateTime to .Net DateTime )

Questions

  1. Why am I not able to see the decompiled code of this specific function/assembly?

  2. any details on how managementdatetimeconverter parses the stringof type CIM DateTime?


// System.Management.ManagementDateTimeConverter
/// <summary>Converts a given DMTF datetime to <see cref="T:System.DateTime" />. The returned <see cref="T:System.DateTime" /> will be in the current time zone of the system.          </summary>
/// <returns>A <see cref="T:System.DateTime" /> that represents the given DMTF datetime.</returns>
/// <param name="dmtfDate">A string representing the datetime in DMTF format.</param>
public static DateTime ToDateTime(string dmtfDate)
{
}
Community
  • 1
  • 1
Dreamer
  • 3,371
  • 2
  • 34
  • 50
  • 5
    You'll need a better decompiler. Just use the [published source code](http://referencesource.microsoft.com/#System.Management/ManagementDatetime.cs#18028db43b6fa364) instead. Comments are always nice. – Hans Passant Jun 06 '14 at 20:49
  • I can't answer your question but I can verify that it works on my machine. I see the decompiled source in ILSpy for System.Management.ManagementDateTimeConvert.ToDateTime(string) – Grax32 Jun 06 '14 at 20:50
  • Works on my machine with Reflector... Are you using an old version? – Thomas Levesque Jun 06 '14 at 21:08
  • thanks for the quick response - they helped me to find details. please see below answer for details. – Dreamer Jun 06 '14 at 23:32

2 Answers2

2

Thanks for all the comments - it helped me to find a way to see the implementation of ToDateTim(..) am looking for.

Visual Studio properties windows showing the system.management assembly location as 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Management.dll'. So, I have used this to reflect over to see the implementation.

Once I saw the above comments, which confirms its working for others, I tried to see which assembly has been loaded during runtime - Debug + Modules window showed that the assembly has been loaded from "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll" - so reflecting over it showed that actual code.

halfer
  • 19,824
  • 17
  • 99
  • 186
Dreamer
  • 3,371
  • 2
  • 34
  • 50
  • 1
    The .NET 4.x reference assemblies are special, they just contain the declarations, no code. – Hans Passant Jun 07 '14 at 00:15
  • 1
    ohh, for 4.5 Microsoft intentionally hiding implementation details? can I change the behavior? I thought managed code by default can be decompiled - or, its probably one of the configuration to hide these details? do you mind giving more details? thank you. – Dreamer Jun 07 '14 at 03:15
0

With ILSpy, you can also load the assembly from the GAC.

Menu "File > Open from GAC..."

Dude Pascalou
  • 2,989
  • 4
  • 29
  • 34