1

I'm looking at the System.Web.Http assembly in dotPeek and I can't see a reference to Newtonsoft.Json

enter image description here

even though I know that System.Web.Http.Results.JsonResult uses Newtonsoft.Json as it's serializer unlike it's System.Web.Mvc cousin.

using Newtonsoft.Json;
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;

namespace System.Web.Http.Results
{
  /// <summary>
  /// Represents an action result that returns an <see cref="F:System.Net.HttpStatusCode.OK"/> response with JSON data.
  /// </summary>
  /// <typeparam name="T">The type of content in the entity body.</typeparam>
  public class JsonResult<T> : IHttpActionResult

Now I understand that Newtonsoft.Json will come down from Nuget in most instances if not already installed as per the WebGrease dependency but I don't understand why it doesn't show up in references.

It does show up as a comment in the AssemblyInfo file:

using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

// Assembly System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: F99F496C-B0D2-49C1-A945-C1FCABCE1695
// References: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// References: System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// References: System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// References: System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// References: System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// References: System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// References: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
// References: System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// References: System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

[assembly: AssemblyTrademark("")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyConfiguration("")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
[assembly: AssemblyCompany("Microsoft Corporation.")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyProduct("Microsoft ASP.NET MVC")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Extension]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]
[assembly: SatelliteContractVersion("5.2.3.0")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyFileVersion("5.2.30128.0")]
[assembly: AssemblyInformationalVersion("5.2.3-30128 (0e974218e12a67d4b1f25422119e40cfe6953e46)")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("System.Web.Http")]
[assembly: Guid("70cecdcd-46f5-492b-9e1f-1d9a947f1fd1")]
[assembly: InternalsVisibleTo("System.Web.Http.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("System.Web.Http.Integration.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: AssemblyVersion("5.2.3.0")]

So is this a setting, or a dotPeek quirk, or something about the way that assembly is built, or something else?

rism
  • 11,932
  • 16
  • 76
  • 116

2 Answers2

1

I know this is an old question, but while researching this I saw this unanswered post, so I thought I would answer it. The reason it doesn't show in dotPeek is because dotPeek does not show references for assemblies that it cannot load.

You can reproduce this fairly simply by creating a simple project with two assemblies where one references the other. If you copy the DLLs into a folder, and view the referencing assembly in dotPeek it will show the referenced assembly. Remove it from dotPeek, remove the referenced assembly from the folder and view the referencing assembly again - and you will see that reference has disappeared from dotPeek (apart from in the AssemblyInfo.cs as you mention above).

FWIW, Because of this issue I have moved to using ILSpy because that doesn't suffer from the same issue.

Matt Whitfield
  • 6,436
  • 3
  • 29
  • 44
1

As the answer to this question mentions the reason why DotPeek did not display all references was because it could not find the referenced assemblies.

This is no longer the case in DotPeek 2016.2. References for which assemblies are not present will be displayed using a question mark on a yellow circle

Screenshot with referenced assembly not present in the same folder as the examined assembly

Screenshot with referenced assembly present in the same folder as the examined assembly

inwenis
  • 368
  • 7
  • 24