Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ insert_final_newline = true
[*.{cs,cshtml}]
indent_size = 4
dotnet_diagnostic.SA1101.severity = silent
dotnet_diagnostic.SA1512.severity = silent
dotnet_diagnostic.SA1513.severity = silent
dotnet_diagnostic.SA1515.severity = silent
dotnet_diagnostic.SA1600.severity = silent
dotnet_diagnostic.CS1591.severity = silent
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.x
dotnet-version: 10.x
- name: Restore dependencies
working-directory: user-auth/GraphTutorial/
run: dotnet restore
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build user-auth",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/user-auth/GraphTutorial/bin/Debug/net9.0/GraphTutorial.dll",
"program": "${workspaceFolder}/user-auth/GraphTutorial/bin/Debug/net10.0/GraphTutorial.dll",
"args": [],
"cwd": "${workspaceFolder}/user-auth/GraphTutorial",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
Expand All @@ -26,7 +26,7 @@
"request": "launch",
"preLaunchTask": "build app-auth",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/app-auth/GraphAppOnlyTutorial/bin/Debug/net9.0/GraphAppOnlyTutorial.dll",
"program": "${workspaceFolder}/app-auth/GraphAppOnlyTutorial/bin/Debug/net10.0/GraphAppOnlyTutorial.dll",
"args": [],
"cwd": "${workspaceFolder}/app-auth/GraphAppOnlyTutorial",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
Expand Down
10 changes: 5 additions & 5 deletions app-auth/GraphAppOnlyTutorial/GraphAppOnlyTutorial.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- cSpell:ignore stylecop contentfiles buildtransitive -->
<!-- cSpell:ignore stylecop contentfiles buildtransitive appsettings -->

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>2275df63-2eb2-47b9-a11f-710535686d4b</UserSecretsId>
Expand All @@ -23,9 +23,9 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.17.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0" />
<PackageReference Include="Microsoft.Graph" Version="5.97.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
16 changes: 8 additions & 8 deletions app-auth/GraphAppOnlyTutorial/GraphHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace GraphAppOnlyTutorial;

public class GraphHelper
{
/* <AppOnlyAuthConfigSnippet> */
// <AppOnlyAuthConfigSnippet>
// Settings object
private static Settings? settings;

Expand Down Expand Up @@ -39,9 +39,9 @@ public static void InitializeGraphForAppOnlyAuth(Settings settings)
configured on the app registration */
["https://graph.microsoft.com/.default"]);
}
/* </AppOnlyAuthConfigSnippet> */
// </AppOnlyAuthConfigSnippet>

/* <GetAppOnlyTokenSnippet> */
// <GetAppOnlyTokenSnippet>
public static async Task<string> GetAppOnlyTokenAsync()
{
// Ensure credential isn't null
Expand All @@ -53,9 +53,9 @@ public static async Task<string> GetAppOnlyTokenAsync()
var response = await clientSecretCredential.GetTokenAsync(context);
return response.Token;
}
/* </GetAppOnlyTokenSnippet> */
// </GetAppOnlyTokenSnippet>

/* <GetUsersSnippet> */
// <GetUsersSnippet>
public static Task<UserCollectionResponse?> GetUsersAsync()
{
// Ensure client isn't null
Expand All @@ -72,15 +72,15 @@ public static async Task<string> GetAppOnlyTokenAsync()
config.QueryParameters.Orderby = ["displayName"];
});
}
/* </GetUsersSnippet> */
// </GetUsersSnippet>

#pragma warning disable CS1998
/* <MakeGraphCallSnippet> */
// <MakeGraphCallSnippet>
/* This function serves as a playground for testing Graph snippets
or other code */
public static async Task MakeGraphCallAsync()
{
// INSERT YOUR CODE HERE
}
/* </MakeGraphCallSnippet> */
// </MakeGraphCallSnippet>
}
20 changes: 10 additions & 10 deletions app-auth/GraphAppOnlyTutorial/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/* <ProgramSnippet> */
// <ProgramSnippet>
using GraphAppOnlyTutorial;

Console.WriteLine(".NET Graph App-only Tutorial\n");
Expand Down Expand Up @@ -54,16 +54,16 @@
break;
}
}
/* </ProgramSnippet> */
// </ProgramSnippet>

/* <InitializeGraphSnippet> */
// <InitializeGraphSnippet>
void InitializeGraph(Settings settings)
{
GraphHelper.InitializeGraphForAppOnlyAuth(settings);
}
/* </InitializeGraphSnippet> */
// </InitializeGraphSnippet>

/* <DisplayAccessTokenSnippet> */
// <DisplayAccessTokenSnippet>
async Task DisplayAccessTokenAsync()
{
try
Expand All @@ -76,9 +76,9 @@ async Task DisplayAccessTokenAsync()
Console.WriteLine($"Error getting app-only access token: {ex.Message}");
}
}
/* </DisplayAccessTokenSnippet> */
// </DisplayAccessTokenSnippet>

/* <ListUsersSnippet> */
// <ListUsersSnippet>
async Task ListUsersAsync()
{
try
Expand Down Expand Up @@ -113,11 +113,11 @@ async Task ListUsersAsync()
Console.WriteLine($"Error getting users: {ex.Message}");
}
}
/* </ListUsersSnippet> */
// </ListUsersSnippet>

/* <MakeGraphCallSnippet> */
// <MakeGraphCallSnippet>
async Task MakeGraphCallAsync()
{
await GraphHelper.MakeGraphCallAsync();
}
/* </MakeGraphCallSnippet> */
// </MakeGraphCallSnippet>
4 changes: 3 additions & 1 deletion app-auth/GraphAppOnlyTutorial/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

// cSpell:ignore appsettings

/* <SettingsSnippet> */
using Microsoft.Extensions.Configuration;

Expand Down Expand Up @@ -30,4 +32,4 @@ public static Settings LoadSettings()
throw new Exception("Could not load app settings. See README for configuration instructions.");
}
}
/* </SettingsSnippet> */
// </SettingsSnippet>
24 changes: 12 additions & 12 deletions user-auth/GraphTutorial/GraphHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace GraphTutorial;

public class GraphHelper
{
/* <UserAuthConfigSnippet> */
// <UserAuthConfigSnippet>
// Settings object
private static Settings? settings;

Expand All @@ -38,9 +38,9 @@ public static void InitializeGraphForUserAuth(

userClient = new GraphServiceClient(deviceCodeCredential, settings.GraphUserScopes);
}
/* </UserAuthConfigSnippet> */
// </UserAuthConfigSnippet>

/* <GetUserTokenSnippet> */
// <GetUserTokenSnippet>
public static async Task<string> GetUserTokenAsync()
{
// Ensure credential isn't null
Expand All @@ -55,9 +55,9 @@ public static async Task<string> GetUserTokenAsync()
var response = await deviceCodeCredential.GetTokenAsync(context);
return response.Token;
}
/* </GetUserTokenSnippet> */
// </GetUserTokenSnippet>

/* <GetUserSnippet> */
// <GetUserSnippet>
public static Task<User?> GetUserAsync()
{
// Ensure client isn't null
Expand All @@ -70,9 +70,9 @@ public static async Task<string> GetUserTokenAsync()
config.QueryParameters.Select = ["displayName", "mail", "userPrincipalName"];
});
}
/* </GetUserSnippet> */
// </GetUserSnippet>

/* <GetInboxSnippet> */
// <GetInboxSnippet>
public static Task<MessageCollectionResponse?> GetInboxAsync()
{
// Ensure client isn't null
Expand All @@ -92,9 +92,9 @@ public static async Task<string> GetUserTokenAsync()
config.QueryParameters.Orderby = ["receivedDateTime DESC"];
});
}
/* </GetInboxSnippet> */
// </GetInboxSnippet>

/* <SendMailSnippet> */
// <SendMailSnippet>
public static async Task SendMailAsync(string subject, string body, string recipient)
{
// Ensure client isn't null
Expand Down Expand Up @@ -130,15 +130,15 @@ await userClient.Me
Message = message,
});
}
/* </SendMailSnippet> */
// </SendMailSnippet>

#pragma warning disable CS1998
/* <MakeGraphCallSnippet> */
// <MakeGraphCallSnippet>
/* This function serves as a playground for testing Graph snippets */
/* or other code */
public static async Task MakeGraphCallAsync()
{
// INSERT YOUR CODE HERE
}
/* </MakeGraphCallSnippet> */
// </MakeGraphCallSnippet>
}
10 changes: 5 additions & 5 deletions user-auth/GraphTutorial/GraphTutorial.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- cSpell:ignore stylecop contentfiles buildtransitive -->
<!-- cSpell:ignore stylecop contentfiles buildtransitive appsettings -->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>2275df63-2eb2-47b9-a11f-710535686d4b</UserSecretsId>
Expand All @@ -22,9 +22,9 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.17.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0" />
<PackageReference Include="Microsoft.Graph" Version="5.97.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
28 changes: 14 additions & 14 deletions user-auth/GraphTutorial/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/* <ProgramSnippet> */
// <ProgramSnippet>
using GraphTutorial;

Console.WriteLine(".NET Graph Tutorial\n");
Expand Down Expand Up @@ -62,9 +62,9 @@
break;
}
}
/* </ProgramSnippet> */
// </ProgramSnippet>

/* <InitializeGraphSnippet> */
// <InitializeGraphSnippet>
void InitializeGraph(Settings settings)
{
GraphHelper.InitializeGraphForUserAuth(
Expand All @@ -79,9 +79,9 @@ void InitializeGraph(Settings settings)
return Task.FromResult(0);
});
}
/* </InitializeGraphSnippet> */
// </InitializeGraphSnippet>

/* <GreetUserSnippet> */
// <GreetUserSnippet>
async Task GreetUserAsync()
{
try
Expand All @@ -98,9 +98,9 @@ async Task GreetUserAsync()
Console.WriteLine($"Error getting user: {ex.Message}");
}
}
/* </GreetUserSnippet> */
// </GreetUserSnippet>

/* <DisplayAccessTokenSnippet> */
// <DisplayAccessTokenSnippet>
async Task DisplayAccessTokenAsync()
{
try
Expand All @@ -113,9 +113,9 @@ async Task DisplayAccessTokenAsync()
Console.WriteLine($"Error getting user access token: {ex.Message}");
}
}
/* </DisplayAccessTokenSnippet> */
// </DisplayAccessTokenSnippet>

/* <ListInboxSnippet> */
// <ListInboxSnippet>
async Task ListInboxAsync()
{
try
Expand Down Expand Up @@ -151,9 +151,9 @@ async Task ListInboxAsync()
Console.WriteLine($"Error getting user's inbox: {ex.Message}");
}
}
/* </ListInboxSnippet> */
// </ListInboxSnippet>

/* <SendMailSnippet> */
// <SendMailSnippet>
async Task SendMailAsync()
{
try
Expand Down Expand Up @@ -182,11 +182,11 @@ await GraphHelper.SendMailAsync(
Console.WriteLine($"Error sending mail: {ex.Message}");
}
}
/* </SendMailSnippet> */
// </SendMailSnippet>

/* <MakeGraphCallSnippet> */
// <MakeGraphCallSnippet>
async Task MakeGraphCallAsync()
{
await GraphHelper.MakeGraphCallAsync();
}
/* </MakeGraphCallSnippet> */
// </MakeGraphCallSnippet>
6 changes: 4 additions & 2 deletions user-auth/GraphTutorial/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/* <SettingsSnippet> */
// cSpell:ignore appsettings

// <SettingsSnippet>
using Microsoft.Extensions.Configuration;

namespace GraphTutorial;
Expand Down Expand Up @@ -30,4 +32,4 @@ public static Settings LoadSettings()
throw new Exception("Could not load app settings. See README for configuration instructions.");
}
}
/* </SettingsSnippet> */
// </SettingsSnippet>