Skip to content

Commit

Permalink
Changed to netstandard2.0 (#114)
Browse files Browse the repository at this point in the history
* Changed to netstandard2.0

* Re-added net462

* Updated readme

* Updated readme 2

* small typo fixes
  • Loading branch information
flytzen authored May 5, 2022
1 parent b90537b commit f7a3413
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
17 changes: 1 addition & 16 deletions Google.Authenticator/Google.Authenticator.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<Product>Google Authenticator Two-Factor</Product>
<Title>Google Authenticator Two-Factor Authentication Library</Title>
<Description>Google Authenticator Two-Factor Authentication Library (Not officially affiliated with Google.)</Description>
Expand All @@ -23,21 +23,6 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45'">
<DefineConstants>NET45;NETFULL</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net5'">
<DefineConstants>NET5_0;NETCOREAPP</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6'">
<DefineConstants>NET6_0;</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>
Expand Down
21 changes: 6 additions & 15 deletions Google.Authenticator/TwoFactorAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,12 @@ private static string GenerateQrCodeUrl(int qrPixelsPerModule, string provisionU
{
using (var qrGenerator = new QRCodeGenerator())
using (var qrCodeData = qrGenerator.CreateQrCode(provisionUrl, QRCodeGenerator.ECCLevel.Q))
#if NET6_0
using (var qrCode = new PngByteQRCode(qrCodeData))
{
var qrCodeImage = qrCode.GetGraphic(qrPixelsPerModule);
qrCodeUrl = $"data:image/png;base64,{Convert.ToBase64String(qrCodeImage)}";
}
#else
using (var qrCode = new QRCode(qrCodeData))
using (var qrCodeImage = qrCode.GetGraphic(qrPixelsPerModule))
using (var ms = new MemoryStream())
{
qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
qrCodeUrl = $"data:image/png;base64,{Convert.ToBase64String(ms.ToArray())}";
}
#endif
using (var qrCode = new PngByteQRCode(qrCodeData))
{
var qrCodeImage = qrCode.GetGraphic(qrPixelsPerModule);
qrCodeUrl = $"data:image/png;base64,{Convert.ToBase64String(qrCodeImage)}";
}

}
catch (TypeInitializationException e)
{
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ bool result = tfa.ValidateTwoFactorPIN(key, txtCode.Text)

## Updates

### 3.0.0-beta1
Removed support for legacy .Net Framework. Lowest supported versions are now netstandard2.0 and .Net 4.6.2.
All use of System.Drawing has been removed. In 2.5, only Net 6.0 avoided System.Drawing.

### 2.5.0
Now runs on .Net 6.0.
Technically the QR Coder library we rely on still does not fully support .Net 6.0 so it is possible there will be other niggling issues, but for now all tests pass for .Net 6.0 on both Windows and Linux.
Expand Down

0 comments on commit f7a3413

Please sign in to comment.