Skip to content

Commit

Permalink
Only publish artifacts on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Nov 19, 2024
1 parent ab3847c commit 5b3aa51
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
- name: 'Publish: artifacts'
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: artifacts
path: artifacts
Expand All @@ -70,6 +71,7 @@ jobs:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
- name: 'Publish: artifacts'
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: artifacts
path: artifacts
1 change: 1 addition & 0 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
OnPushIncludePaths = ["**/*.*"],
OnPushExcludePaths = ["**/*.md"],
PublishArtifacts = true,
PublishCondition = "runner.os == 'Windows'",
InvokedTargets = [nameof(Compile), nameof(Test), nameof(Pack), nameof(Publish)],
ImportSecrets = ["NUGET_API_KEY", "MYGET_API_KEY"],
CacheKeyFiles = ["global.json", "src/**/*.csproj", "src/**/package.json"])
Expand Down
1 change: 1 addition & 0 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="8.1.4" />
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
</ItemGroup>

</Project>
18 changes: 8 additions & 10 deletions src/NJsonSchema/JsonReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public JsonReferenceResolver(JsonSchemaAppender schemaAppender)
/// <returns>The factory.</returns>
public static Func<JsonSchema, JsonReferenceResolver> CreateJsonReferenceResolverFactory(ITypeNameGenerator typeNameGenerator)
{
JsonReferenceResolver ReferenceResolverFactory(JsonSchema schema) =>
new JsonReferenceResolver(new JsonSchemaAppender(schema, typeNameGenerator));
JsonReferenceResolver ReferenceResolverFactory(JsonSchema schema)
{
return new JsonReferenceResolver(new JsonSchemaAppender(schema, typeNameGenerator));
}

return ReferenceResolverFactory;
}
Expand Down Expand Up @@ -99,16 +101,13 @@ private static string UnescapeReferenceSegment(string segment)
public virtual IJsonReference ResolveDocumentReference(object rootObject, string jsonPath, Type targetType, IContractResolver contractResolver)
{
var allSegments = jsonPath.Split('/').Skip(1).ToList();
for (int i = 0; i < allSegments.Count; i++)
for (var i = 0; i < allSegments.Count; i++)
{
allSegments[i] = UnescapeReferenceSegment(allSegments[i]);
}

var schema = ResolveDocumentReference(rootObject, allSegments, targetType, contractResolver, new HashSet<object>());
if (schema == null)
{
throw new InvalidOperationException("Could not resolve the path '" + jsonPath + "'.");
}
var schema = ResolveDocumentReference(rootObject, allSegments, targetType, contractResolver, new HashSet<object>())
?? throw new InvalidOperationException($"Could not resolve the path '{jsonPath}'.");

return schema;
}
Expand Down Expand Up @@ -299,8 +298,7 @@ private async Task<IJsonReference> ResolveUrlReferenceWithAlreadyResolvedCheckAs
}
else if (obj is IEnumerable)
{
int index;
if (int.TryParse(firstSegment, out index))
if (int.TryParse(firstSegment, out var index))
{
var enumerable = ((IEnumerable)obj).Cast<object>().ToArray();
if (enumerable.Length > index)
Expand Down

0 comments on commit 5b3aa51

Please sign in to comment.