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
7 changes: 7 additions & 0 deletions SourceLink.sln
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SourceLink.Gitea"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SourceLink.Gitea.UnitTests", "src\SourceLink.Gitea.UnitTests\Microsoft.SourceLink.Gitea.UnitTests.csproj", "{04C95AC8-E3A4-4A2B-94E6-4C62E910FD8A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-sourcelink", "src\dotnet-sourcelink\dotnet-sourcelink.csproj", "{4376B613-CD5B-4274-9071-30989769B0B2}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\SourceLink.Tools\Microsoft.SourceLink.Tools.projitems*{4376b613-cd5b-4274-9071-30989769b0b2}*SharedItemsImports = 5
src\SourceLink.Tools\Microsoft.SourceLink.Tools.projitems*{5df76cc2-5f0e-45a6-ad56-6bbbccbc1a78}*SharedItemsImports = 13
src\SourceLink.Tools\Microsoft.SourceLink.Tools.projitems*{99d113a9-24ec-471d-9f74-d2ac2f16220b}*SharedItemsImports = 5
EndGlobalSection
Expand Down Expand Up @@ -178,6 +181,10 @@ Global
{04C95AC8-E3A4-4A2B-94E6-4C62E910FD8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04C95AC8-E3A4-4A2B-94E6-4C62E910FD8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04C95AC8-E3A4-4A2B-94E6-4C62E910FD8A}.Release|Any CPU.Build.0 = Release|Any CPU
{4376B613-CD5B-4274-9071-30989769B0B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4376B613-CD5B-4274-9071-30989769B0B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4376B613-CD5B-4274-9071-30989769B0B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4376B613-CD5B-4274-9071-30989769B0B2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 3 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<MicrosoftDotNetPlatformAbstractionsVersion>3.1.6</MicrosoftDotNetPlatformAbstractionsVersion>
<NuGetVersioningVersion>5.7.0</NuGetVersioningVersion>
<NuGetPackagingVersion>5.7.0</NuGetPackagingVersion>
<SystemCommandLineVersion>2.0.0-beta1.20371.2</SystemCommandLineVersion>
<SystemCommandLineRenderingVersion>0.3.0-alpha.20371.2</SystemCommandLineRenderingVersion>
<SystemReflectionMetadataVersion>1.8.1</SystemReflectionMetadataVersion>
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<SystemTextJsonVersion>4.7.2</SystemTextJsonVersion>
<!-- libgit2 used for integration tests -->
Expand Down
30 changes: 30 additions & 0 deletions src/dotnet-sourcelink/AuthenticationHeaderProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Net.Http.Headers;
using System.Text;

namespace Microsoft.SourceLink.Tools
{
internal interface IAuthenticationHeaderValueProvider
{
AuthenticationHeaderValue GetValue();
}

internal sealed class BasicAuthenticationHeaderValueProvider : IAuthenticationHeaderValueProvider
{
private readonly string _username;
private readonly string _password;
private readonly Encoding _encoding;

public BasicAuthenticationHeaderValueProvider(string username, string password, Encoding encoding)
{
_username = username;
_password = password;
_encoding = encoding;
}

public AuthenticationHeaderValue GetValue()
=> new("Basic", Convert.ToBase64String(_encoding.GetBytes($"{_username}:{_password}")));
}
}
25 changes: 25 additions & 0 deletions src/dotnet-sourcelink/HashAlgorithmGuids.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Security.Cryptography;

namespace Microsoft.SourceLink.Tools
{
internal static class HashAlgorithmGuids
{
public static readonly Guid MD5 = new Guid("406ea660-64cf-4c82-b6f0-42d48172a799");
public static readonly Guid Sha1 = new("ff1816ec-aa5e-4d10-87f7-6f4963833460");
public static readonly Guid Sha256 = new("8829d00f-11b8-4213-878b-770e8597ac16");

public static HashAlgorithmName? TryGetName(Guid guid)
{
if (guid == MD5) return new HashAlgorithmName("MD5");
if (guid == Sha1) return new HashAlgorithmName("SHA1");
if (guid == Sha256) return new HashAlgorithmName("SHA256");
return null;
}

public static HashAlgorithmName GetName(Guid guid)
=> TryGetName(guid) ?? throw new CryptographicException("unknown HashAlgorithm " + guid);
}
}
21 changes: 21 additions & 0 deletions src/dotnet-sourcelink/LanguageGuids.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace Microsoft.SourceLink.Tools
{
internal static class LanguageGuids
{
public static readonly Guid CSharp = new("3f5162f8-07c6-11d3-9053-00c04fa302a1");
public static readonly Guid FSharp = new("ab4f38c9-b6e6-43ba-be3b-58080b2ccce3");
public static readonly Guid VisualBasic = new("3a12d0b8-c26c-11d0-b442-00a0244a1dd2");

public static string GetName(Guid guid)
{
if (guid == CSharp) return "C#";
if (guid == FSharp) return "F#";
if (guid == VisualBasic) return "VB";
return guid.ToString();
}
}
}
Loading