Skip to content

Commit

Permalink
Merge pull request #121 from BrandonPotter/feature/RemoveFrameworkDep…
Browse files Browse the repository at this point in the history
…endentCodeFromTestProject

Removed framework dependent code from the test project
  • Loading branch information
ahwm authored May 26, 2022
2 parents b7fd6fa + 7ee8f12 commit 9973bec
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
4 changes: 1 addition & 3 deletions Google.Authenticator.Tests/Google.Authenticator.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ZXing.Net" Version="0.16.8" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net452'">
<PackageReference Include="ZXing.Net.Bindings.Magick" Version="0.16.9" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Google.Authenticator\Google.Authenticator.csproj" />
</ItemGroup>
Expand Down
17 changes: 0 additions & 17 deletions Google.Authenticator.Tests/QRCodeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,13 @@ private static string ExtractUrlFromQRImage(string qrCodeSetupImageUrl)
var rawImageData = qrCodeSetupImageUrl.Substring(headerLength, qrCodeSetupImageUrl.Length - headerLength);
var imageData = Convert.FromBase64String(rawImageData);

//var reader = new BarcodeReaderGeneric();
//reader.Options.PossibleFormats = new List<BarcodeFormat> {
// BarcodeFormat.QR_CODE
//};

#if NETFRAMEWORK
var reader = new BarcodeReader();
reader.Options.PossibleFormats = new List<BarcodeFormat> {
BarcodeFormat.QR_CODE
};
using (var ms = new MemoryStream(imageData))
{
var image = new System.Drawing.Bitmap(ms);
return reader.Decode(image).Text;
}
#else
var reader = new BarcodeReaderGeneric();
reader.Options.PossibleFormats = new List<BarcodeFormat> {
BarcodeFormat.QR_CODE
};
var image = new ImageMagick.MagickImage(imageData);
var wrappedImage = new ZXing.Magick.MagickImageLuminanceSource(image);
return reader.Decode(wrappedImage).Text;
#endif
}
}
}

0 comments on commit 9973bec

Please sign in to comment.