-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from octokit/fix-dotnet-generation
Updates how we generate .net and simplifies the test app
- Loading branch information
Showing
6 changed files
with
88 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug Go post-processing", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/post-processors/go/main.go", | ||
"args": ["${workspaceFolder}/generated/go"] | ||
}, | ||
{ | ||
"name": "Debug C# post-processing", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/post-processors/csharp/main.go", | ||
"args": ["${workspaceFolder}/generated/csharp"] | ||
}, | ||
] | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Launch (console)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
"program": "${workspaceFolder}/generated/csharp/bin/Debug/net7.0/csharp.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"console": "integratedTerminal", | ||
"stopAtEntry": false | ||
}, | ||
{ | ||
"name": "Debug Go post-processing", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/post-processors/go/main.go", | ||
"args": [ | ||
"${workspaceFolder}/generated/go" | ||
] | ||
}, | ||
{ | ||
"name": "Debug C# post-processing", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/post-processors/csharp/main.go", | ||
"args": [ | ||
"${workspaceFolder}/generated/csharp" | ||
] | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/generated/csharp/csharp.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"${workspaceFolder}/generated/csharp/csharp.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"watch", | ||
"run", | ||
"--project", | ||
"${workspaceFolder}/generated/csharp/csharp.csproj" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,11 @@ | ||
using Azure.Identity; | ||
using Azure.Core; | ||
using Octokit.Client; | ||
using Microsoft.Kiota.Abstractions.Authentication; | ||
using Microsoft.Kiota.Authentication.Azure; | ||
using Microsoft.Kiota.Http.HttpClientLibrary; | ||
using Octokit; | ||
|
||
var token = Environment.GetEnvironmentVariable("GITHUB_TOKEN"); | ||
if (string.IsNullOrEmpty(token)) | ||
{ | ||
Console.WriteLine("GITHUB_TOKEN environment variable is not set"); | ||
// throw new Exception("GITHUB_TOKEN environment variable is not set"); | ||
} | ||
// API requires no authentication, so use the anonymous | ||
var authProvider = new AnonymousAuthenticationProvider(); | ||
var adapter = new HttpClientRequestAdapter(authProvider); | ||
var client = new OctokitClient(adapter); | ||
|
||
var authProvider = new ApiKeyAuthenticationProvider(token, "Authorization", ApiKeyAuthenticationProvider.KeyLocation.Header, new string[] { "https://api.github.com" }); | ||
var requestAdapter = new HttpClientRequestAdapter(authProvider, null, null, new HttpClient | ||
{ | ||
BaseAddress = new Uri("https://api.github.com/") | ||
}); | ||
var pathParameters = new Dictionary<string, object>() { | ||
{"baseurl", "https://api.github.com/"}, | ||
}; | ||
var octocatPathParams = new Octokit.Octocat.OctocatRequestBuilder(pathParameters, requestAdapter); | ||
Action<Octokit.Octocat.OctocatRequestBuilder.OctocatRequestBuilderGetRequestConfiguration> requestConfig = | ||
delegate (Octokit.Octocat.OctocatRequestBuilder.OctocatRequestBuilderGetRequestConfiguration config) | ||
{ | ||
config.QueryParameters.S = "Hey yo!"; | ||
config.Headers.Add("Accept", "application/vnd.github.v3+json"); | ||
}; | ||
|
||
try | ||
{ | ||
Stream requestPathParam = await octocatPathParams.GetAsync(requestConfig); | ||
StreamReader rPathParams = new StreamReader(requestPathParam); | ||
string responsePathParams = rPathParams.ReadToEnd(); | ||
Console.WriteLine(responsePathParams); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.Message); | ||
throw; | ||
} | ||
|
||
|
||
// Passing path parms | ||
|
||
// Basic request | ||
|
||
// var client = new Octokit.ApiClient(requestAdapter); | ||
// var request = await client.Octocat.GetAsync(); | ||
|
||
// StreamReader reader = new StreamReader(request); | ||
// string response = reader.ReadToEnd(); | ||
// Console.WriteLine(response); | ||
|
||
// Basic request | ||
var user = await client.Users["nickfloyd"].GetAsync(); | ||
user?.AdditionalData.ToList().ForEach(x => Console.WriteLine(x.Key + ": " + x.Value)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters