Skip to content

Commit

Permalink
dotnet format
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
  • Loading branch information
berezovskyi committed Sep 5, 2024
1 parent c3dd38f commit e0dfd17
Show file tree
Hide file tree
Showing 194 changed files with 4,428 additions and 4,031 deletions.
994 changes: 493 additions & 501 deletions OSLC4Net_SDK/JsonProvider/JsonHelper.cs

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions OSLC4Net_SDK/JsonProvider/JsonMediaTypeFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Json;
using System.Linq;
Expand Down Expand Up @@ -144,7 +143,7 @@ public override bool CanWriteType(Type type)
/// <param name="content"></param>
/// <param name="transportContext"></param>
/// <returns></returns>
public override Task WriteToStreamAsync(
public override Task WriteToStreamAsync(
Type type,
object value,
Stream writeStream,
Expand Down Expand Up @@ -265,7 +264,10 @@ IFormatterLogger formatterLogger
{
var tcs = new TaskCompletionSource<object>();

if (content != null && content.Headers != null && content.Headers.ContentLength == 0) return null;
if (content != null && content.Headers != null && content.Headers.ContentLength == 0)
{
return null;
}

try
{
Expand All @@ -274,7 +276,6 @@ IFormatterLogger formatterLogger
// readStream.Position = 0;
// Debug.WriteLine("HTTP response body" + httpResponseBody);


var jsonObject = (JsonObject)JsonObject.Load(readStream);
// Debug.WriteLine("JsonMediaTypeFormatter.ReadFromStreamAsync(): Loaded JSON: " + jsonObject?.ToString());

Expand All @@ -285,7 +286,7 @@ IFormatterLogger formatterLogger
{
var haveOne = (int)output.GetType().GetProperty("Count").GetValue(output, null) > 0;

tcs.SetResult(haveOne ? output.GetType().GetProperty("Item").GetValue(output, new object[] { 0 }): null);
tcs.SetResult(haveOne ? output.GetType().GetProperty("Item").GetValue(output, new object[] { 0 }) : null);
}
else if (type.IsArray)
{
Expand All @@ -298,7 +299,10 @@ IFormatterLogger formatterLogger
}
catch (Exception e)
{
if (formatterLogger == null) throw;
if (formatterLogger == null)
{
throw;
}

formatterLogger.LogError(string.Empty, e.Message);

Expand Down
2 changes: 1 addition & 1 deletion OSLC4Net_SDK/JsonProvider/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
18 changes: 9 additions & 9 deletions OSLC4Net_SDK/JsonProviderTests/JsonMediaTypeFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task TestJsonSerialization()
OslcJsonMediaTypeFormatter formatter = new();

Assert.NotNull(changeRequest1);
var json = Serialize<ChangeRequest>(formatter, changeRequest1, OslcMediaType.APPLICATION_JSON_TYPE);
var json = Serialize(formatter, changeRequest1, OslcMediaType.APPLICATION_JSON_TYPE);

Assert.NotNull(json);
Debug.WriteLine(json);
Expand Down Expand Up @@ -85,7 +85,7 @@ public void TestJsonCollectionSerialization()
null);
OSLC4Net.Core.JsonProvider.OslcJsonMediaTypeFormatter formatter = new(json, false);

var jsonString = SerializeCollection<ChangeRequest>(formatter, crListOut, OslcMediaType.APPLICATION_JSON_TYPE);
var jsonString = SerializeCollection(formatter, crListOut, OslcMediaType.APPLICATION_JSON_TYPE);

var crListIn = DeserializeCollection<ChangeRequest>(formatter, jsonString, OslcMediaType.APPLICATION_JSON_TYPE).ToList();
Assert.Equal(crListOut.Count, crListIn.Count);
Expand Down Expand Up @@ -115,7 +115,7 @@ public void TestJsonCollectionSerialization()

}

private string Serialize<T>(MediaTypeFormatter formatter, T value, MediaTypeHeaderValue mediaType) where T : IResource
private static string Serialize<T>(MediaTypeFormatter formatter, T value, MediaTypeHeaderValue mediaType) where T : IResource
{
Stream stream = new MemoryStream();
HttpContent content = new StreamContent(stream);
Expand All @@ -128,7 +128,7 @@ private string Serialize<T>(MediaTypeFormatter formatter, T value, MediaTypeHead
return content.ReadAsStringAsync().Result;
}

private string SerializeCollection<T>(MediaTypeFormatter formatter, IEnumerable<T> value, MediaTypeHeaderValue mediaType) where T : IResource
private static string SerializeCollection<T>(MediaTypeFormatter formatter, IEnumerable<T> value, MediaTypeHeaderValue mediaType) where T : IResource
{
Stream stream = new MemoryStream();
HttpContent content = new StreamContent(stream);
Expand All @@ -141,7 +141,7 @@ private string SerializeCollection<T>(MediaTypeFormatter formatter, IEnumerable<
return content.ReadAsStringAsync().Result;
}

private async Task<T> Deserialize<T>(MediaTypeFormatter formatter, string str, MediaTypeHeaderValue mediaType) where T : class, IResource
private static async Task<T> Deserialize<T>(MediaTypeFormatter formatter, string str, MediaTypeHeaderValue mediaType) where T : class, IResource
{
Stream stream = new MemoryStream();
StreamWriter writer = new(stream);
Expand All @@ -161,7 +161,7 @@ private async Task<T> Deserialize<T>(MediaTypeFormatter formatter, string str, M
return result as T;
}

private IEnumerable<T> DeserializeCollection<T>(MediaTypeFormatter formatter, string str, MediaTypeHeaderValue mediaType) where T : class, IResource
private static IEnumerable<T> DeserializeCollection<T>(MediaTypeFormatter formatter, string str, MediaTypeHeaderValue mediaType) where T : class, IResource
{
Stream stream = new MemoryStream();
StreamWriter writer = new(stream);
Expand All @@ -177,7 +177,7 @@ private IEnumerable<T> DeserializeCollection<T>(MediaTypeFormatter formatter, st
return formatter.ReadFromStreamAsync(typeof(List<T>), stream, content, logFormatter).Result as IEnumerable<T>;
}

private class LogFormatter : IFormatterLogger
private sealed class LogFormatter : IFormatterLogger
{
public LogFormatter(ILog logger)
{
Expand All @@ -194,8 +194,8 @@ public void LogError(string errorPath, string errorMessage)
logger.Error(errorPath + ": " + errorMessage);
}

private ILog logger;
private readonly ILog logger;
}

private static LogFormatter logFormatter = new(LogManager.GetLogger(typeof(JsonMediaTypeFormatterTests)));
private static readonly LogFormatter logFormatter = new(LogManager.GetLogger(typeof(JsonMediaTypeFormatterTests)));
}
2 changes: 1 addition & 1 deletion OSLC4Net_SDK/JsonProviderTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
84 changes: 42 additions & 42 deletions OSLC4Net_SDK/OSLC4Net.ChangeManagement/ChangeRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
Expand Down Expand Up @@ -29,45 +29,45 @@ namespace OSLC4Net.ChangeManagement;
[OslcResourceShape(title = "Change Request Resource Shape", describes = new string[] { Constants.TYPE_CHANGE_REQUEST })]
public class ChangeRequest : AbstractResource
{
private readonly ISet<Link> affectedByDefects = new HashSet<Link>();
private readonly ISet<Link> affectsPlanItems = new HashSet<Link>();
private readonly ISet<Link> affectsRequirements = new HashSet<Link>();
private readonly ISet<Link> affectsTestResults = new HashSet<Link>();
private readonly ISet<Link> blocksTestExecutionRecords = new HashSet<Link>();
private readonly ISet<Uri> contributors = new HashSet<Uri>(); // XXX - TreeSet<> in Java
private readonly ISet<Uri> creators = new HashSet<Uri>(); // XXX - TreeSet<> in Java
private readonly ISet<Type> dctermsTypes = new HashSet<Type>(); // XXX - TreeSet<> in Java
private readonly ISet<Link> implementsRequirements = new HashSet<Link>();
private readonly ISet<Link> relatedChangeRequests = new HashSet<Link>();
private readonly ISet<Link> relatedResources = new HashSet<Link>(); // TODO - Extension to point to any other OSLC resource(s).
private readonly ISet<Link> relatedTestCases = new HashSet<Link>();
private readonly ISet<Link> relatedTestExecutionRecords = new HashSet<Link>();
private readonly ISet<Link> relatedTestPlans = new HashSet<Link>();
private readonly ISet<Link> relatedTestScripts = new HashSet<Link>();
private readonly ISet<string> subjects = new HashSet<string>(); // XXX - TreeSet<> in Java
private readonly ISet<Link> testedByTestCases = new HashSet<Link>();
private readonly ISet<Link> tracksChangeSets = new HashSet<Link>();
private readonly ISet<Link> tracksRequirements = new HashSet<Link>();
private readonly ISet<Uri> rdfTypes = new HashSet<Uri>(); // XXX - TreeSet<> in Java

private bool? approved;
private bool? closed;
private DateTime? closeDate;
private DateTime? created;
private string description;
private Uri discussedBy;
private bool? isFixed;
private string identifier;
private bool? inProgress;
private Uri instanceShape;
private DateTime? modified;
private bool? reviewed;
private Uri serviceProvider;
private Severity severity = Severity.Unclassified; // TODO - Added severity for demo
private string shortTitle;
private string status;
private string title;
private bool? verified;
private readonly ISet<Link> affectedByDefects = new HashSet<Link>();
private readonly ISet<Link> affectsPlanItems = new HashSet<Link>();
private readonly ISet<Link> affectsRequirements = new HashSet<Link>();
private readonly ISet<Link> affectsTestResults = new HashSet<Link>();
private readonly ISet<Link> blocksTestExecutionRecords = new HashSet<Link>();
private readonly ISet<Uri> contributors = new HashSet<Uri>(); // XXX - TreeSet<> in Java
private readonly ISet<Uri> creators = new HashSet<Uri>(); // XXX - TreeSet<> in Java
private readonly ISet<Type> dctermsTypes = new HashSet<Type>(); // XXX - TreeSet<> in Java
private readonly ISet<Link> implementsRequirements = new HashSet<Link>();
private readonly ISet<Link> relatedChangeRequests = new HashSet<Link>();
private readonly ISet<Link> relatedResources = new HashSet<Link>(); // TODO - Extension to point to any other OSLC resource(s).
private readonly ISet<Link> relatedTestCases = new HashSet<Link>();
private readonly ISet<Link> relatedTestExecutionRecords = new HashSet<Link>();
private readonly ISet<Link> relatedTestPlans = new HashSet<Link>();
private readonly ISet<Link> relatedTestScripts = new HashSet<Link>();
private readonly ISet<string> subjects = new HashSet<string>(); // XXX - TreeSet<> in Java
private readonly ISet<Link> testedByTestCases = new HashSet<Link>();
private readonly ISet<Link> tracksChangeSets = new HashSet<Link>();
private readonly ISet<Link> tracksRequirements = new HashSet<Link>();
private readonly ISet<Uri> rdfTypes = new HashSet<Uri>(); // XXX - TreeSet<> in Java

private bool? approved;
private bool? closed;
private DateTime? closeDate;
private DateTime? created;
private string description;
private Uri discussedBy;
private bool? isFixed;
private string identifier;
private bool? inProgress;
private Uri instanceShape;
private DateTime? modified;
private bool? reviewed;
private Uri serviceProvider;
private Severity severity = Severity.Unclassified; // TODO - Added severity for demo
private string shortTitle;
private string status;
private string title;
private bool? verified;

public ChangeRequest() : base()
{
Expand Down Expand Up @@ -272,7 +272,7 @@ public Uri[] GetCreators()
return creators.ToArray();
}

[OslcAllowedValue(new string[] {"Defect", "Task", "Story", "Bug Report", "Feature Request"})]
[OslcAllowedValue(new string[] { "Defect", "Task", "Story", "Bug Report", "Feature Request" })]
[OslcDescription("A short string representation for the type, example 'Defect'.")]
[OslcName("type")]
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "type")]
Expand Down Expand Up @@ -430,7 +430,7 @@ public Uri GetServiceProvider()
return serviceProvider;
}

[OslcAllowedValue(new string[] {"Unclassified", "Minor", "Normal", "Major", "Critical", "Blocker"})]
[OslcAllowedValue(new string[] { "Unclassified", "Minor", "Normal", "Major", "Critical", "Blocker" })]
[OslcDescription("Severity of change request.")]
[OslcOccurs(Occurs.ExactlyOne)]
[OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "severity")]
Expand Down
41 changes: 20 additions & 21 deletions OSLC4Net_SDK/OSLC4Net.ChangeManagement/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
Expand All @@ -22,29 +22,28 @@ namespace OSLC4Net.ChangeManagement;
/// </summary>
public static class Constants
{
public const string CHANGE_MANAGEMENT_DOMAIN = "http://open-services.net/ns/cm#";
public const string CHANGE_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/cm#";
public const string CHANGE_MANAGEMENT_NAMESPACE_PREFIX = "oslc_cm";
public const string FOAF_NAMESPACE = "http://xmlns.com/foaf/0.1/";
public const string FOAF_NAMESPACE_PREFIX = "foaf";
public const string QUALITY_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/qm#";
public const string QUALITY_MANAGEMENT_PREFIX = "oslc_qm";
public const string REQUIREMENTS_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/rm#";
public const string REQUIREMENTS_MANAGEMENT_PREFIX = "oslc_rm";
public const string CHANGE_MANAGEMENT_DOMAIN = "http://open-services.net/ns/cm#";
public const string CHANGE_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/cm#";
public const string CHANGE_MANAGEMENT_NAMESPACE_PREFIX = "oslc_cm";
public const string FOAF_NAMESPACE = "http://xmlns.com/foaf/0.1/";
public const string FOAF_NAMESPACE_PREFIX = "foaf";
public const string QUALITY_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/qm#";
public const string QUALITY_MANAGEMENT_PREFIX = "oslc_qm";
public const string REQUIREMENTS_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/rm#";
public const string REQUIREMENTS_MANAGEMENT_PREFIX = "oslc_rm";
public const string SOFTWARE_CONFIGURATION_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/scm#";
public const string SOFTWARE_CONFIGURATION_MANAGEMENT_PREFIX = "oslc_scm";
public const string SOFTWARE_CONFIGURATION_MANAGEMENT_PREFIX = "oslc_scm";


public const string TYPE_CHANGE_REQUEST = CHANGE_MANAGEMENT_NAMESPACE + "ChangeRequest";
public const string TYPE_CHANGE_SET = SOFTWARE_CONFIGURATION_MANAGEMENT_NAMESPACE + "ChangeSet";
public const string TYPE_DISCUSSION = OslcConstants.OSLC_CORE_NAMESPACE + "Discussion";
public const string TYPE_PERSON = FOAF_NAMESPACE + "Person";
public const string TYPE_REQUIREMENT = REQUIREMENTS_MANAGEMENT_NAMESPACE + "Requirement";
public const string TYPE_TEST_CASE = QUALITY_MANAGEMENT_NAMESPACE + "TestCase";
public const string TYPE_CHANGE_REQUEST = CHANGE_MANAGEMENT_NAMESPACE + "ChangeRequest";
public const string TYPE_CHANGE_SET = SOFTWARE_CONFIGURATION_MANAGEMENT_NAMESPACE + "ChangeSet";
public const string TYPE_DISCUSSION = OslcConstants.OSLC_CORE_NAMESPACE + "Discussion";
public const string TYPE_PERSON = FOAF_NAMESPACE + "Person";
public const string TYPE_REQUIREMENT = REQUIREMENTS_MANAGEMENT_NAMESPACE + "Requirement";
public const string TYPE_TEST_CASE = QUALITY_MANAGEMENT_NAMESPACE + "TestCase";
public const string TYPE_TEST_EXECUTION_RECORD = QUALITY_MANAGEMENT_NAMESPACE + "TestExecutionRecord";
public const string TYPE_TEST_PLAN = QUALITY_MANAGEMENT_NAMESPACE + "TestPlan";
public const string TYPE_TEST_RESULT = QUALITY_MANAGEMENT_NAMESPACE + "TestResult";
public const string TYPE_TEST_SCRIPT = QUALITY_MANAGEMENT_NAMESPACE + "TestScript";
public const string TYPE_TEST_PLAN = QUALITY_MANAGEMENT_NAMESPACE + "TestPlan";
public const string TYPE_TEST_RESULT = QUALITY_MANAGEMENT_NAMESPACE + "TestResult";
public const string TYPE_TEST_SCRIPT = QUALITY_MANAGEMENT_NAMESPACE + "TestScript";

public const string PATH_CHANGE_REQUEST = "changeRequest";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;

using OSLC4Net.Core.Attribute;
using OSLC4Net.ChangeManagement;
using OSLC4Net.Core.Attribute;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
2 changes: 1 addition & 1 deletion OSLC4Net_SDK/OSLC4Net.ChangeManagement/Severity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
Expand Down
2 changes: 1 addition & 1 deletion OSLC4Net_SDK/OSLC4Net.ChangeManagement/Type.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
Expand Down
2 changes: 1 addition & 1 deletion OSLC4Net_SDK/OSLC4Net.ChangeManagement/XmlNamespace.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
Expand Down
15 changes: 8 additions & 7 deletions OSLC4Net_SDK/OSLC4Net.ChangeManagementTest/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public abstract class TestBase
protected TestBase()
{
_config = new ConfigurationBuilder()
.AddJsonFile("appsettings.Development.json")
// .AddEnvironmentVariables()
.AddJsonFile("appsettings.Development.json")
// .AddEnvironmentVariables()
.Build();
_serviceProviderCatalogURI = _config["serviceProviderCatalog:uri"]!;
}
Expand Down Expand Up @@ -157,8 +157,8 @@ protected async void VerifyChangeRequest(string mediaType,

var aboutURI = changeRequest.GetAbout();
var createdDate = changeRequest.GetCreated();
var identifierString = changeRequest.GetIdentifier();
var modifiedDate = changeRequest.GetModified();
var identifierString = changeRequest.GetIdentifier();
_ = changeRequest.GetModified();
Uri[] rdfTypesURIs = changeRequest.GetRdfTypes();
var serviceProviderURI = changeRequest.GetServiceProvider();

Expand Down Expand Up @@ -186,7 +186,8 @@ protected async void VerifyChangeRequest(string mediaType,
VerifyChangeRequest(mediaType,
await aboutOSLCRestClient.GetOslcResourceAsync<ChangeRequest>(),
recurse: false);
if(serviceProviderURI != null) {
if (serviceProviderURI != null)
{
OslcRestClient serviceProviderOSLCRestClient = new(Formatters,
serviceProviderURI,
mediaType);
Expand All @@ -203,8 +204,8 @@ protected async void VerifyCompact(string mediaType,
{
Assert.IsNotNull(compact);

var aboutURI = compact.GetAbout();
var shortTitleString = compact.GetShortTitle();
var aboutURI = compact.GetAbout();
_ = compact.GetShortTitle();
var titleString = compact.GetTitle();

Assert.IsNotNull(aboutURI);
Expand Down
Loading

0 comments on commit e0dfd17

Please sign in to comment.