Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public void Sets_Top_If_Value_Is_Not_Set()

[Theory]
[InlineData(0)]
#pragma warning disable xUnit1012
[InlineData(null)]
#pragma warning restore xUnit1012
[InlineData("test")]
public void Sets_Top_If_Value_Is_Invalid(object topValue)
{
Expand Down
20 changes: 1 addition & 19 deletions src/Microsoft.Graph.Cli.Core/IO/GraphCliClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Graph.Cli.Core.IO;
/// <summary>
/// HTTP client factory for the graph CLI.
/// </summary>
public class GraphCliClientFactory
public static class GraphCliClientFactory
{
/// <summary>
/// Gets default middlewares.
Expand Down Expand Up @@ -49,24 +49,6 @@ public static HttpClient GetDefaultClient(GraphClientOptions? options = null, st
m.Add(lh);
}

// Set compression handler to be last (Allows logging handler to log request body)
m.Sort((a, b) =>
{
var aMatch = a is Kiota.Http.HttpClientLibrary.Middleware.CompressionHandler;
var bMatch = b is Kiota.Http.HttpClientLibrary.Middleware.CompressionHandler;
if (aMatch && !bMatch)
{
return 1;
}

if (bMatch && !aMatch)
{
return -1;
}

return 0;
});

return GraphClientFactory.Create(version: version, nationalCloud: environment.GraphClientCloud(), finalHandler: finalHandler, handlers: m);
}
}
4 changes: 2 additions & 2 deletions src/sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

namespace Microsoft.Graph.Cli
{
class Program

Check warning on line 39 in src/sample/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)

Check warning on line 39 in src/sample/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)
{
private static bool debugEnabled = false;
private static AzureEventSourceListener? listener = null;
Expand Down Expand Up @@ -146,7 +146,7 @@
rootCommand.Add(new LoginCommand(builder));
rootCommand.AddGlobalOption(debugOption);

if (rootCommand.Subcommands.FirstOrDefault(static c => c.Name == "users") is {} usersCmd)
if (rootCommand.Subcommands.FirstOrDefault(static c => c.Name == "users") is { } usersCmd)
{
usersCmd.AddAlias("me");
}
Expand Down Expand Up @@ -179,7 +179,7 @@
var authSettings = p.GetRequiredService<IOptions<AuthenticationOptions>>().Value;
var headersHandler = new NativeHttpHeadersHandler(() => InMemoryHeadersStore.Instance, p.GetService<ILogger<NativeHttpHeadersHandler>>());

return GraphCliClientFactory.GetDefaultClient(options, environment: authSettings.Environment, loggingHandler: p.GetRequiredService<LoggingHandler>(), middlewares: new[] { headersHandler });

Check warning on line 182 in src/sample/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check warning on line 182 in src/sample/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)
});
services.AddSingleton<IAuthenticationProvider>(p =>
{
Expand All @@ -188,7 +188,7 @@
AuthenticationStrategy authStrategy = authSettings?.Strategy ?? AuthenticationStrategy.DeviceCode;
var credential = serviceFactory.GetTokenCredentialAsync(authStrategy, authSettings?.TenantId, authSettings?.ClientId, authSettings?.ClientCertificateName, authSettings?.ClientCertificateThumbPrint, authSettings?.Environment ?? CloudEnvironment.Global);
credential.Wait();
return new AzureIdentityAuthenticationProvider(credential.Result);
return new AzureIdentityAuthenticationProvider(credential.Result, isCaeEnabled: true); // disambiguates the call to the constructor
});
services.AddSingleton<IRequestAdapter>(p =>
{
Expand Down Expand Up @@ -223,7 +223,7 @@
logBuilder.AddFilter("Microsoft.Graph.Cli", level => level >= (debugEnabled ? LogLevel.Debug : LogLevel.Warning));
});

static void ConfigureAppConfiguration(IConfigurationBuilder builder, string[] args)

Check warning on line 226 in src/sample/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this unused method parameter 'args'. (https://rules.sonarsource.com/csharp/RSPEC-1172)

Check warning on line 226 in src/sample/Program.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this unused method parameter 'args'. (https://rules.sonarsource.com/csharp/RSPEC-1172)
{
builder.Sources.Clear();
builder.AddJsonFile(Path.Combine(System.AppContext.BaseDirectory, "app-settings.json"), optional: true);
Expand Down
26 changes: 18 additions & 8 deletions src/sample/generated/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// <auto-generated/>
#pragma warning disable CS0618
using ApiSdk.Users;
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions;
Expand All @@ -15,15 +16,20 @@
using System.Text;
using System.Threading.Tasks;
using System;
namespace ApiSdk {
namespace ApiSdk
{
/// <summary>
/// The main entry point of the SDK, exposes the configuration and the fluent API.
/// </summary>
public class ApiClient : BaseCliRequestBuilder {
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
public partial class ApiClient : BaseCliRequestBuilder
{
/// <summary>
/// Instantiates a new ApiClient and sets the default values.
/// Instantiates a new <see cref="global::ApiSdk.ApiClient"/> and sets the default values.
/// </summary>
public Command BuildRootCommand() {
/// <returns>A <see cref="Command"/></returns>
public Command BuildRootCommand()
{
var command = new RootCommand();
command.Description = "Instantiates a new ApiClient and sets the default values.";
command.AddCommand(BuildUsersNavCommand());
Expand All @@ -32,10 +38,12 @@ public Command BuildRootCommand() {
/// <summary>
/// The users property
/// </summary>
public Command BuildUsersNavCommand() {
/// <returns>A <see cref="Command"/></returns>
public Command BuildUsersNavCommand()
{
var command = new Command("users");
command.Description = "The users property";
var builder = new UsersRequestBuilder(PathParameters);
var builder = new global::ApiSdk.Users.UsersRequestBuilder(PathParameters);
var execCommands = new List<Command>();
var nonExecCommands = new List<Command>();
nonExecCommands.Add(builder.BuildCountNavCommand());
Expand All @@ -55,9 +63,11 @@ public Command BuildUsersNavCommand() {
return command;
}
/// <summary>
/// Instantiates a new ApiClient and sets the default values.
/// Instantiates a new <see cref="global::ApiSdk.ApiClient"/> and sets the default values.
/// </summary>
public ApiClient() : base("{+baseurl}", new Dictionary<string, object>()) {
public ApiClient() : base("{+baseurl}", new Dictionary<string, object>())
{
}
}
}
#pragma warning restore CS0618
34 changes: 24 additions & 10 deletions src/sample/generated/Models/AccessAction.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
// <auto-generated/>
#pragma warning disable CS0618
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
namespace ApiSdk.Models {
public class AccessAction : IAdditionalDataHolder, IParsable {
namespace ApiSdk.Models
{
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
#pragma warning disable CS1591
public partial class AccessAction : IAdditionalDataHolder, IParsable
#pragma warning restore CS1591
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData { get; set; }
/// <summary>
/// Instantiates a new accessAction and sets the default values.
/// Instantiates a new <see cref="global::ApiSdk.Models.AccessAction"/> and sets the default values.
/// </summary>
public AccessAction() {
public AccessAction()
{
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::ApiSdk.Models.AccessAction"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static AccessAction CreateFromDiscriminatorValue(IParseNode parseNode) {
public static global::ApiSdk.Models.AccessAction CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new AccessAction();
return new global::ApiSdk.Models.AccessAction();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
return new Dictionary<string, Action<IParseNode>> {
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public void Serialize(ISerializationWriter writer) {
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteAdditionalData(AdditionalData);
}
}
}
#pragma warning restore CS0618
7 changes: 5 additions & 2 deletions src/sample/generated/Models/ActionState.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// <auto-generated/>
using System.Runtime.Serialization;
using System;
namespace ApiSdk.Models {
namespace ApiSdk.Models
{
/// <summary>State of the action on the device</summary>
public enum ActionState {
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
public enum ActionState
{
/// <summary>Not a valid action state</summary>
[EnumMember(Value = "none")]
None,
Expand Down
63 changes: 38 additions & 25 deletions src/sample/generated/Models/ActivityHistoryItem.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
// <auto-generated/>
#pragma warning disable CS0618
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
namespace ApiSdk.Models {
public class ActivityHistoryItem : Entity, IParsable {
namespace ApiSdk.Models
{
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
#pragma warning disable CS1591
public partial class ActivityHistoryItem : global::ApiSdk.Models.Entity, IParsable
#pragma warning restore CS1591
{
/// <summary>Optional. The duration of active user engagement. if not supplied, this is calculated from the startedDateTime and lastActiveDateTime.</summary>
public int? ActiveDurationSeconds { get; set; }
/// <summary>The activity property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public UserActivity? Activity { get; set; }
public global::ApiSdk.Models.UserActivity? Activity { get; set; }
#nullable restore
#else
public UserActivity Activity { get; set; }
public global::ApiSdk.Models.UserActivity Activity { get; set; }
#endif
/// <summary>Set by the server. DateTime in UTC when the object was created on the server.</summary>
public DateTimeOffset? CreatedDateTime { get; set; }
/// <summary>Optional. UTC DateTime when the historyItem will undergo hard-delete. Can be set by the client.</summary>
/// <summary>Optional. UTC DateTime when the activityHistoryItem will undergo hard-delete. Can be set by the client.</summary>
public DateTimeOffset? ExpirationDateTime { get; set; }
/// <summary>Optional. UTC DateTime when the historyItem (activity session) was last understood as active or finished - if null, historyItem status should be Ongoing.</summary>
/// <summary>Optional. UTC DateTime when the activityHistoryItem (activity session) was last understood as active or finished - if null, activityHistoryItem status should be Ongoing.</summary>
public DateTimeOffset? LastActiveDateTime { get; set; }
/// <summary>Set by the server. DateTime in UTC when the object was modified on the server.</summary>
public DateTimeOffset? LastModifiedDateTime { get; set; }
/// <summary>Required. UTC DateTime when the historyItem (activity session) was started. Required for timeline history.</summary>
/// <summary>Required. UTC DateTime when the activityHistoryItem (activity session) was started. Required for timeline history.</summary>
public DateTimeOffset? StartedDateTime { get; set; }
/// <summary>The status property</summary>
public ApiSdk.Models.Status? Status { get; set; }
public global::ApiSdk.Models.Status? Status { get; set; }
/// <summary>Optional. The timezone in which the user&apos;s device used to generate the activity was located at activity creation time. Values supplied as Olson IDs in order to support cross-platform representation.</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand All @@ -39,43 +45,50 @@ public class ActivityHistoryItem : Entity, IParsable {
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::ApiSdk.Models.ActivityHistoryItem"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static new ActivityHistoryItem CreateFromDiscriminatorValue(IParseNode parseNode) {
public static new global::ApiSdk.Models.ActivityHistoryItem CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new ActivityHistoryItem();
return new global::ApiSdk.Models.ActivityHistoryItem();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
public new IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
return new Dictionary<string, Action<IParseNode>>(base.GetFieldDeserializers()) {
{"activeDurationSeconds", n => { ActiveDurationSeconds = n.GetIntValue(); } },
{"activity", n => { Activity = n.GetObjectValue<UserActivity>(UserActivity.CreateFromDiscriminatorValue); } },
{"createdDateTime", n => { CreatedDateTime = n.GetDateTimeOffsetValue(); } },
{"expirationDateTime", n => { ExpirationDateTime = n.GetDateTimeOffsetValue(); } },
{"lastActiveDateTime", n => { LastActiveDateTime = n.GetDateTimeOffsetValue(); } },
{"lastModifiedDateTime", n => { LastModifiedDateTime = n.GetDateTimeOffsetValue(); } },
{"startedDateTime", n => { StartedDateTime = n.GetDateTimeOffsetValue(); } },
{"status", n => { Status = n.GetEnumValue<Status>(); } },
{"userTimezone", n => { UserTimezone = n.GetStringValue(); } },
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public override IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>(base.GetFieldDeserializers())
{
{ "activeDurationSeconds", n => { ActiveDurationSeconds = n.GetIntValue(); } },
{ "activity", n => { Activity = n.GetObjectValue<global::ApiSdk.Models.UserActivity>(global::ApiSdk.Models.UserActivity.CreateFromDiscriminatorValue); } },
{ "createdDateTime", n => { CreatedDateTime = n.GetDateTimeOffsetValue(); } },
{ "expirationDateTime", n => { ExpirationDateTime = n.GetDateTimeOffsetValue(); } },
{ "lastActiveDateTime", n => { LastActiveDateTime = n.GetDateTimeOffsetValue(); } },
{ "lastModifiedDateTime", n => { LastModifiedDateTime = n.GetDateTimeOffsetValue(); } },
{ "startedDateTime", n => { StartedDateTime = n.GetDateTimeOffsetValue(); } },
{ "status", n => { Status = n.GetEnumValue<global::ApiSdk.Models.Status>(); } },
{ "userTimezone", n => { UserTimezone = n.GetStringValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public new void Serialize(ISerializationWriter writer) {
public override void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
base.Serialize(writer);
writer.WriteIntValue("activeDurationSeconds", ActiveDurationSeconds);
writer.WriteObjectValue<UserActivity>("activity", Activity);
writer.WriteObjectValue<global::ApiSdk.Models.UserActivity>("activity", Activity);
writer.WriteDateTimeOffsetValue("createdDateTime", CreatedDateTime);
writer.WriteDateTimeOffsetValue("expirationDateTime", ExpirationDateTime);
writer.WriteDateTimeOffsetValue("lastActiveDateTime", LastActiveDateTime);
writer.WriteDateTimeOffsetValue("lastModifiedDateTime", LastModifiedDateTime);
writer.WriteDateTimeOffsetValue("startedDateTime", StartedDateTime);
writer.WriteEnumValue<Status>("status", Status);
writer.WriteEnumValue<global::ApiSdk.Models.Status>("status", Status);
writer.WriteStringValue("userTimezone", UserTimezone);
}
}
}
#pragma warning restore CS0618
Loading