Skip to content

Commit

Permalink
Up Bump .NET SDK from 5.0.100 to 5.0.102 (RehanSaeed#238)
Browse files Browse the repository at this point in the history
* Up Bump .NET SDK from 5.0.100 to 5.0.102

* Update .NET SDK install directory for AppVeyor MacOS
  • Loading branch information
RehanSaeed authored and ran-resonaixr committed Jan 24, 2021
1 parent cdcaaad commit 58aead6
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 82 deletions.
1 change: 0 additions & 1 deletion Benchmarks/Schema.NET.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Schema.NET.Benchmarks
{
using System;
using BenchmarkDotNet.Running;

internal class Program
Expand Down
22 changes: 21 additions & 1 deletion Source/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
##########################################
# StyleCop
# .NET Formatting Conventions
##########################################

[*.cs]
# CA1711: Identifiers should not have incorrect suffix
# Justification: Some code is auto-generated.
dotnet_diagnostic.CA1711.severity = none

# CA1716: Identifiers should not match keywords
# Justification: Some code is auto-generated.
dotnet_diagnostic.CA1716.severity = none

# CA1720: Identifier contains type name
# Justification: Some code is auto-generated.
dotnet_diagnostic.CA1720.severity = none

# IDE0005: Using directive is unnecessary.
# Justification: Some code is auto-generated.
dotnet_diagnostic.IDE0005.severity = none

##########################################
# StyleCop
##########################################

# SA1623: Property summary documentation should match accessors
# Justification: Summary documentation is generated from schema.org.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md
Expand Down
4 changes: 1 addition & 3 deletions Source/Schema.NET/FastActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ namespace Schema.NET
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;

/// <summary>
/// A faster version of <see cref="Activator.CreateInstance(System.Type, object[])"/> by providing constructor delegates.
/// A faster version of <see cref="Activator.CreateInstance(Type, object[])"/> by providing constructor delegates.
/// </summary>
internal static class FastActivator
{
Expand Down
20 changes: 0 additions & 20 deletions Source/Schema.NET/GlobalSuppressions.cs

This file was deleted.

1 change: 0 additions & 1 deletion Source/Schema.NET/OneOrMany{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace Schema.NET
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;

/// <summary>
/// A single or list of values.
Expand Down
26 changes: 16 additions & 10 deletions Source/Schema.NET/ValuesJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ namespace Schema.NET
/// <seealso cref="JsonConverter" />
public class ValuesJsonConverter : JsonConverter
{
private const string HttpSchemaOrgUrl = "http://schema.org/";
private const int HttpSchemaOrgLength = 18; // equivalent to "http://schema.org/".Length
private const string HttpsSchemaOrgUrl = "https://schema.org/";
private const int HttpsSchemaOrgLength = 19; // equivalent to "https://schema.org/".Length

private static readonly TypeInfo ThingInterfaceTypeInfo = typeof(IThing).GetTypeInfo();
private static readonly Dictionary<string, Type> BuiltInThingTypeLookup = new Dictionary<string, Type>(StringComparer.Ordinal);

Expand Down Expand Up @@ -201,7 +206,9 @@ private static object ProcessToken(JsonReader reader, Type[] targetTypes, JsonSe
// If the target is an interface, attempt to identify concrete target
var localTargetType = underlyingTargetType;
var typeInfo = localTargetType.GetTypeInfo();
#pragma warning disable IDE0057 // Use range operator. Need to multi-target.
if (typeInfo.IsInterface && TryGetConcreteType(typeInfo.Name.Substring(1), out var concreteType))
#pragma warning restore IDE0057 // Use range operator. Need to multi-target.
{
localTargetType = concreteType;
}
Expand Down Expand Up @@ -282,19 +289,18 @@ private static bool TryProcessTokenAsType(JsonReader reader, Type targetType, ou
}
else if (targetType.GetTypeInfo().IsEnum)
{
const string SCHEMA_ORG = "http://schema.org/";
const int SCHEMA_ORG_LENGTH = 18; // equivalent to "http://schema.org/".Length
const string SCHEMA_ORG_HTTPS = "https://schema.org/";
const int SCHEMA_ORG_HTTPS_LENGTH = 19; // equivalent to "https://schema.org/".Length

string enumString;
if (valueString.StartsWith(SCHEMA_ORG, StringComparison.OrdinalIgnoreCase))
if (valueString.StartsWith(HttpSchemaOrgUrl, StringComparison.OrdinalIgnoreCase))
{
enumString = valueString.Substring(SCHEMA_ORG_LENGTH);
#pragma warning disable IDE0057 // Use range operator. Need to multi-target.
enumString = valueString.Substring(HttpSchemaOrgLength);
#pragma warning restore IDE0057 // Use range operator. Need to multi-target.
}
else if (valueString.StartsWith(SCHEMA_ORG_HTTPS, StringComparison.OrdinalIgnoreCase))
else if (valueString.StartsWith(HttpsSchemaOrgUrl, StringComparison.OrdinalIgnoreCase))
{
enumString = valueString.Substring(SCHEMA_ORG_HTTPS_LENGTH);
#pragma warning disable IDE0057 // Use range operator. Need to multi-target.
enumString = valueString.Substring(HttpsSchemaOrgLength);
#pragma warning restore IDE0057 // Use range operator. Need to multi-target.
}
else
{
Expand Down Expand Up @@ -373,7 +379,7 @@ private static bool TryProcessTokenAsType(JsonReader reader, Type targetType, ou
result = localResult;
}
}
else if (tokenType == JsonToken.Integer || tokenType == JsonToken.Float)
else if (tokenType is JsonToken.Integer or JsonToken.Float)
{
if (targetType.GetTypeInfo().IsPrimitive || targetType == typeof(decimal))
{
Expand Down
3 changes: 0 additions & 3 deletions Tests/Schema.NET.Test/core/TestDefaults.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
namespace Schema.NET.Test
{
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ namespace Schema.NET.Tool.CustomOverrides
// https://github.com/schemaorg/schemaorg/issues/1668
public class AddNumberTypeToMediaObjectHeightAndWidth : IClassOverride
{
public bool CanOverride(Class @class)
public bool CanOverride(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

return string.Equals(@class.Name, "MediaObject", StringComparison.OrdinalIgnoreCase);
return string.Equals(c.Name, "MediaObject", StringComparison.OrdinalIgnoreCase);
}

public void Override(Class @class)
public void Override(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

@class
c
.Properties
.First(x => string.Equals(x.Name, "Height", StringComparison.OrdinalIgnoreCase))
.Types
.Add(new PropertyType("Integer", "int"));
@class
c
.Properties
.First(x => string.Equals(x.Name, "Width", StringComparison.OrdinalIgnoreCase))
.Types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ namespace Schema.NET.Tool.CustomOverrides

public class AddQueryInputPropertyToSearchAction : IClassOverride
{
public bool CanOverride(Class @class)
public bool CanOverride(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

return string.Equals(@class.Name, "SearchAction", StringComparison.Ordinal);
return string.Equals(c.Name, "SearchAction", StringComparison.Ordinal);
}

public void Override(Class @class)
public void Override(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

var property = new Property()
{
Class = @class,
Class = c,
Description = "Gets or sets the query input search parameter.",
JsonName = "query-input",
Name = "QueryInput",
Expand All @@ -36,7 +36,7 @@ public void Override(Class @class)
new PropertyType("Text", "string"),
new PropertyType("PropertyValueSpecification", "PropertyValueSpecification"),
});
@class.Properties.Add(property);
c.Properties.Add(property);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ namespace Schema.NET.Tool.CustomOverrides
// See https://schema.org/docs/actions.html#part-3
public class AddTextTypeToActionTarget : IClassOverride
{
public bool CanOverride(Class @class)
public bool CanOverride(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

return string.Equals(@class.Name, "Action", StringComparison.OrdinalIgnoreCase);
return string.Equals(c.Name, "Action", StringComparison.OrdinalIgnoreCase);
}

public void Override(Class @class)
public void Override(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

var property = @class.Properties.First(x => string.Equals(x.Name, "target", StringComparison.OrdinalIgnoreCase));
var property = c.Properties.First(x => string.Equals(x.Name, "target", StringComparison.OrdinalIgnoreCase));
property.Types.Add(new PropertyType("URL", "Uri"));
}
}
Expand Down
16 changes: 8 additions & 8 deletions Tools/Schema.NET.Tool/CustomOverrides/RenameEventProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ namespace Schema.NET.Tool.CustomOverrides

public class RenameEventProperty : IClassOverride
{
public bool CanOverride(Class @class)
public bool CanOverride(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

return @class.Properties.Any(x => string.Equals(x.Name, "Event", StringComparison.OrdinalIgnoreCase));
return c.Properties.Any(x => string.Equals(x.Name, "Event", StringComparison.OrdinalIgnoreCase));
}

public void Override(Class @class)
public void Override(Class c)
{
if (@class is null)
if (c is null)
{
throw new ArgumentNullException(nameof(@class));
throw new ArgumentNullException(nameof(c));
}

var eventProperty = @class
var eventProperty = c
.Properties
.First(x => string.Equals(x.Name, "Event", StringComparison.OrdinalIgnoreCase));
eventProperty.Name = "Events";
Expand Down
2 changes: 2 additions & 0 deletions Tools/Schema.NET.Tool/Services/SchemaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ private static void SetParentAndChildren(List<Class> classes)
var parentClass = classes.FirstOrDefault(x => x.Id == parentClassId);
if (parentClass is null)
{
#pragma warning disable CA2201 // Do not raise reserved exception types
throw new Exception(Resources.CheckThatNewPrimitiveTypeNotAdded);
#pragma warning restore CA2201 // Do not raise reserved exception types
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions Tools/Schema.NET.Tool/ViewModels/Class.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public override string ToString()
}
else
{
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
#pragma warning disable CA2201 // Do not raise reserved exception types
throw new Exception(Resources.InterfaceShouldOnlyHaveOneParent);
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
#pragma warning restore CA2201 // Do not raise reserved exception types
}

stringBuilder.AppendIndentLine(4, "{");
Expand Down Expand Up @@ -143,9 +143,9 @@ public override string ToString()
}
else
{
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
#pragma warning disable CA2201 // Do not raise reserved exception types
throw new Exception(Resources.ClassShouldOnlyHaveOneParent);
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
#pragma warning restore CA2201 // Do not raise reserved exception types
}

stringBuilder.AppendIndentLine(4, "{");
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
version: '{build}'

image:
- macOS
#- macOS
- Ubuntu
- Visual Studio 2019

Expand All @@ -28,12 +28,12 @@ build_script:
Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile "./dotnet-install.sh"
sudo chmod u+x dotnet-install.sh
if ($isMacOS) {
sudo ./dotnet-install.sh --jsonfile global.json --install-dir '/Users/appveyor/.dotnet'
sudo ./dotnet-install.sh --jsonfile global.json --install-dir '/usr/local/share/dotnet'
} else {
sudo ./dotnet-install.sh --jsonfile global.json --install-dir '/usr/share/dotnet'
}
}
- pwsh: dotnet tool restore
- pwsh: dotnet tool restore --verbosity diagnostic
- pwsh: dotnet cake --target=Build
- pwsh: dotnet cake --target=Test
- pwsh: dotnet cake --target=Pack
Expand Down
2 changes: 1 addition & 1 deletion dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "1.0.0-rc0001",
"version": "1.0.0-rc0002",
"commands": [
"dotnet-cake"
]
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"rollForward": "latestMajor",
"version": "5.0.100"
"version": "5.0.102"
}
}

0 comments on commit 58aead6

Please sign in to comment.