Browse Source

AllowTrailingCommas while parse jsons for telemetry

pull/24305/head
berkansasmaz 2 months ago
parent
commit
4506f06fc6
  1. 5
      framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs
  2. 10
      framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/EnvironmentInspection/Detectors/AbpStudioDetector.cs
  3. 10
      framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/EnvironmentInspection/Detectors/VisualStudioCodeDetector.cs
  4. 6
      framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Helpers/AbpPackageMetadataReader.cs

5
framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs

@ -114,7 +114,10 @@ internal sealed class TelemetrySolutionInfoEnricher : TelemetryActivityEventEnri
}
var moduleJsonFileContent = File.ReadAllText(modulePath);
using var moduleDoc = JsonDocument.Parse(moduleJsonFileContent);
using var moduleDoc = JsonDocument.Parse(moduleJsonFileContent, new JsonDocumentOptions
{
AllowTrailingCommas = true
});
if (!moduleDoc.RootElement.TryGetProperty("imports", out var imports))
{

10
framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/EnvironmentInspection/Detectors/AbpStudioDetector.cs

@ -40,7 +40,10 @@ internal sealed class AbpStudioDetector : SoftwareDetector
return null;
}
using var fs = new FileStream(ideStateJsonPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using var doc = JsonDocument.Parse(fs);
using var doc = JsonDocument.Parse(fs, new JsonDocumentOptions
{
AllowTrailingCommas = true
});
return doc.RootElement.TryGetProperty("theme", out var themeElement) ? themeElement.GetString() : null;
}
@ -55,7 +58,10 @@ internal sealed class AbpStudioDetector : SoftwareDetector
}
using var fs = new FileStream(extensionsFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using var doc = JsonDocument.Parse(fs);
using var doc = JsonDocument.Parse(fs, new JsonDocumentOptions
{
AllowTrailingCommas = true
});
if (doc.RootElement.TryGetProperty("Extensions", out var extensionsElement) &&
extensionsElement.ValueKind == JsonValueKind.Array)

10
framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/EnvironmentInspection/Detectors/VisualStudioCodeDetector.cs

@ -77,7 +77,10 @@ internal sealed class VisualStudioCodeDetector : SoftwareDetector
{
try
{
using var jsonDoc = JsonDocument.Parse(File.ReadAllText(productJson));
using var jsonDoc = JsonDocument.Parse(File.ReadAllText(productJson), new JsonDocumentOptions
{
AllowTrailingCommas = true
});
var root = jsonDoc.RootElement;
if (root.TryGetProperty("version", out var versionProp))
{
@ -105,7 +108,10 @@ internal sealed class VisualStudioCodeDetector : SoftwareDetector
{
try
{
using var json = JsonDocument.Parse( File.ReadAllText(settingsPath));
using var json = JsonDocument.Parse( File.ReadAllText(settingsPath), new JsonDocumentOptions
{
AllowTrailingCommas = true
});
var root = json.RootElement;
if (root.TryGetProperty("theme", out var themeProp))
{

6
framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Helpers/AbpPackageMetadataReader.cs

@ -49,11 +49,13 @@ static internal class AbpProjectMetadataReader
private static AbpProjectMetaData ReadOrCreateMetadata(string packagePath)
{
var fileContent = File.ReadAllText(packagePath);
var metadata = new AbpProjectMetaData();
using var document = JsonDocument.Parse(fileContent);
using var document = JsonDocument.Parse(fileContent, new JsonDocumentOptions
{
AllowTrailingCommas = true
});
var root = document.RootElement;
if (TryGetProjectId(root,out var projectId))

Loading…
Cancel
Save