Skip to content

Commit

Permalink
Merge branch 'master' of github.com:NuGetPackageExplorer/NuGetPackage…
Browse files Browse the repository at this point in the history
…Explorer
  • Loading branch information
wangfu91 committed Dec 11, 2018
2 parents 70309e6 + 825eb55 commit 52c362d
Show file tree
Hide file tree
Showing 40 changed files with 431 additions and 410 deletions.
38 changes: 26 additions & 12 deletions Core/AssemblyMetadata/AssemblyDebugParser.cs
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
using Microsoft.DiaSymReader.Tools;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -83,19 +84,32 @@ private IReadOnlyList<SourceLinkMap> GetSourceLinkInformation()
select Encoding.UTF8.GetString(bl))
.FirstOrDefault();

var jobj = JObject.Parse(sl);
var docs = (JObject)jobj["documents"];


var slis = (from prop in docs.Properties()
select new SourceLinkMap
{
Base = prop.Name,
Location = prop.Value.Value<string>()
})
.ToList();
if(sl != null)
{
try
{
var jobj = JObject.Parse(sl);
var docs = (JObject)jobj["documents"];


var slis = (from prop in docs.Properties()
select new SourceLinkMap
{
Base = prop.Name,
Location = prop.Value.Value<string>()
})
.ToList();

return slis;
}
catch(JsonReaderException jse)
{
throw new InvalidDataException("SourceLink data could not be parsed", jse);
}

}

return slis;
return Array.Empty<SourceLinkMap>();
}


Expand Down
2 changes: 2 additions & 0 deletions Core/AssemblyMetadata/AssemblyDebugSourceDocument.cs
Expand Up @@ -12,6 +12,7 @@ public class AssemblyDebugSourceDocument
private static readonly Guid VisualBasic = new Guid("3a12d0b8-c26c-11d0-b442-00a0244a1dd2");
private static readonly Guid FSharp = new Guid("ab4f38c9-b6e6-43ba-be3b-58080b2ccce3");

private static readonly Guid Md5 = new Guid("406ea660-64cf-4c82-b6f0-42d48172a799");
private static readonly Guid Sha1 = new Guid("ff1816ec-aa5e-4d10-87f7-6f4963833460");
private static readonly Guid Sha256 = new Guid("8829d00f-11b8-4213-878b-770e8597ac16");

Expand Down Expand Up @@ -40,6 +41,7 @@ private SymbolLanguage LanguageFromGuid(Guid guid)

public HashAlgorithmName HashAlgorithmNameFromGuid(Guid guid)
{
if (guid == Md5) return HashAlgorithmName.MD5;
if (guid == Sha1) return HashAlgorithmName.SHA1;
if (guid == Sha256) return HashAlgorithmName.SHA256;

Expand Down
6 changes: 3 additions & 3 deletions Core/AssemblyMetadata/AssemblyMetadataParser.cs
Expand Up @@ -129,7 +129,7 @@ public class AttributeInfo

private class AttributeTypeProvider : ICustomAttributeTypeProvider<string>
{
private static Dictionary<PrimitiveTypeCode, Type> PrimitiveTypeMappings =
private static readonly Dictionary<PrimitiveTypeCode, Type> _primitiveTypeMappings =
new Dictionary<PrimitiveTypeCode, Type>
{
{ PrimitiveTypeCode.Void, typeof(void) },
Expand All @@ -154,7 +154,7 @@ private class AttributeTypeProvider : ICustomAttributeTypeProvider<string>

public string GetPrimitiveType(PrimitiveTypeCode typeCode)
{
if (PrimitiveTypeMappings.TryGetValue(typeCode, out var type))
if (_primitiveTypeMappings.TryGetValue(typeCode, out var type))
{
return type.FullName;
}
Expand Down Expand Up @@ -236,7 +236,7 @@ public PrimitiveTypeCode GetUnderlyingEnumType(string type)
{
var underlyingType = runtimeType.GetEnumUnderlyingType();

foreach (var primitiveTypeMapping in PrimitiveTypeMappings)
foreach (var primitiveTypeMapping in _primitiveTypeMappings)
{
if (primitiveTypeMapping.Value == underlyingType)
{
Expand Down
4 changes: 0 additions & 4 deletions Core/Configuration/UserSettings.cs
Expand Up @@ -23,8 +23,6 @@ public UserSettings(IFileSystem fileSystem)
_config = XmlUtility.GetOrCreateDocument("configuration", _fileSystem, _configLocation);
}

#region ISettings Members

public string GetValue(string section, string key)
{
if (string.IsNullOrEmpty(section))
Expand Down Expand Up @@ -159,8 +157,6 @@ public void DeleteValue(string section, string key)
Save(_config);
}

#endregion

private void Save(XDocument document)
{
_fileSystem.AddFile(_configLocation, document.Save);
Expand Down
12 changes: 2 additions & 10 deletions Core/Packages/PackageFileBase.cs
Expand Up @@ -9,14 +9,12 @@ namespace NuGetPe
{
public abstract class PackageFileBase : IPackageFile
{
private readonly FrameworkName _targetFramework;

protected PackageFileBase(string path)
{
Path = path;

FrameworkNameUtility.ParseFrameworkNameFromFilePath(path, out var effectivePath);
_targetFramework = new FrameworkName(NuGetFramework.Parse(effectivePath).DotNetFrameworkName);
TargetFramework = new FrameworkName(NuGetFramework.Parse(effectivePath).DotNetFrameworkName);
EffectivePath = effectivePath;
}

Expand All @@ -42,13 +40,7 @@ public string EffectivePath
private set;
}

public FrameworkName TargetFramework
{
get
{
return _targetFramework;
}
}
public FrameworkName TargetFramework { get; }

public IEnumerable<FrameworkName> SupportedFrameworks
{
Expand Down

0 comments on commit 52c362d

Please sign in to comment.