Skip to content

Commit f852baa

Browse files
committed
Misc cleanup
1 parent f490971 commit f852baa

File tree

7 files changed

+26
-28
lines changed

7 files changed

+26
-28
lines changed

QRCoder/PayloadGenerator/SlovenianUpnQr.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public SlovenianUpnQr(string payerName, string payerAddress, string payerPlace,
114114
private string FormatAmount(double amount)
115115
{
116116
int _amt = (int)Math.Round(amount * 100.0);
117-
return String.Format("{0:00000000000}", _amt);
117+
return string.Format("{0:00000000000}", _amt);
118118
}
119119

120120
/// <summary>

QRCoder/QRCodeGenerator/Polynom.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ public void Sort(Func<PolynomItem, PolynomItem, int> comparer)
111111
if (comparer == null)
112112
throw new ArgumentNullException(nameof(comparer));
113113

114-
var items = _polyItems;
115-
if (items == null)
116-
throw new ObjectDisposedException(nameof(Polynom));
114+
var items = _polyItems ?? throw new ObjectDisposedException(nameof(Polynom));
117115

118116
if (Count <= 1)
119117
{

QRCoderConsole/Program.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ namespace QRCoderConsole;
1111

1212
#if NET6_0_WINDOWS
1313
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
14+
internal
1415
#endif
15-
class MainClass
16+
internal class MainClass
1617
{
1718
public static void Main(string[] args)
1819
{
1920
var friendlyName = AppDomain.CurrentDomain.FriendlyName;
2021
var newLine = Environment.NewLine;
2122
var setter = new OptionSetter();
2223

23-
String fileName = null, outputFileName = null, payload = null;
24+
string fileName = null, outputFileName = null, payload = null;
2425

2526
var eccLevel = QRCodeGenerator.ECCLevel.L;
2627
var imageFormat = SupportedImageFormat.Png;
@@ -39,7 +40,7 @@ public static void Main(string[] args)
3940
},
4041
{ "f|output-format=",
4142
$"Image format for outputfile. Possible values: {string.Join(", ", Enum.GetNames(typeof(SupportedImageFormat)))} (default: png)",
42-
value => { Enum.TryParse(value, true, out imageFormat); }
43+
value => Enum.TryParse(value, true, out imageFormat)
4344
},
4445
{
4546
"i|in=",
@@ -229,9 +230,8 @@ public class OptionSetter
229230
{
230231
public QRCodeGenerator.ECCLevel GetECCLevel(string value)
231232
{
232-
QRCodeGenerator.ECCLevel level;
233233

234-
Enum.TryParse(value, out level);
234+
Enum.TryParse(value, out QRCodeGenerator.ECCLevel level);
235235

236236
return level;
237237
}

QRCoderDemo/Form1.cs

+11-12
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ private Bitmap GetIconBitmap()
5959

6060
private void selectIconBtn_Click(object sender, EventArgs e)
6161
{
62-
var openFileDlg = new OpenFileDialog();
63-
openFileDlg.Title = "Select icon";
64-
openFileDlg.Multiselect = false;
65-
openFileDlg.CheckFileExists = true;
62+
var openFileDlg = new OpenFileDialog
63+
{
64+
Title = "Select icon",
65+
Multiselect = false,
66+
CheckFileExists = true
67+
};
6668
if (openFileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
6769
{
6870
iconPath.Text = openFileDlg.FileName;
@@ -82,9 +84,11 @@ private void btn_save_Click(object sender, EventArgs e)
8284
{
8385

8486
// Displays a SaveFileDialog so the user can save the Image
85-
var saveFileDialog1 = new SaveFileDialog();
86-
saveFileDialog1.Filter = "Bitmap Image|*.bmp|PNG Image|*.png|JPeg Image|*.jpg|Gif Image|*.gif";
87-
saveFileDialog1.Title = "Save an Image File";
87+
var saveFileDialog1 = new SaveFileDialog
88+
{
89+
Filter = "Bitmap Image|*.bmp|PNG Image|*.png|JPeg Image|*.jpg|Gif Image|*.gif",
90+
Title = "Save an Image File"
91+
};
8892
saveFileDialog1.ShowDialog();
8993

9094
// If the file name is not an empty string open it for saving.
@@ -109,11 +113,6 @@ private void btn_save_Click(object sender, EventArgs e)
109113
}
110114
}
111115

112-
public void ExportToBmp(string path)
113-
{
114-
115-
}
116-
117116
private void textBoxQRCode_TextChanged(object sender, EventArgs e)
118117
{
119118
RenderQrCode();

QRCoderDemo/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace QRCoderDemo;
77

8-
static class Program
8+
internal static class Program
99
{
1010
/// <summary>
1111
/// Der Haupteinstiegspunkt für die Anwendung.
1212
/// </summary>
1313
[STAThread]
14-
static void Main()
14+
private static void Main()
1515
{
1616
Application.EnableVisualStyles();
1717
Application.SetCompatibleTextRenderingDefault(false);

QRCoderDemoUWP/App.xaml.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -20,7 +20,7 @@ namespace QRCoderDemoUWP
2020
/// <summary>
2121
/// Provides application-specific behavior to supplement the default Application class.
2222
/// </summary>
23-
sealed partial class App : Application
23+
internal sealed partial class App : Application
2424
{
2525
/// <summary>
2626
/// Initializes the singleton application object. This is the first line of authored code
@@ -45,11 +45,10 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
4545
DebugSettings.EnableFrameRateCounter = true;
4646
}
4747
#endif
48-
var rootFrame = Window.Current.Content as Frame;
4948

5049
// Do not repeat app initialization when the Window already has content,
5150
// just ensure that the window is active
52-
if (rootFrame == null)
51+
if (!(Window.Current.Content is Frame rootFrame))
5352
{
5453
// Create a Frame to act as the navigation context and navigate to the first page
5554
rootFrame = new Frame();
@@ -84,7 +83,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
8483
/// </summary>
8584
/// <param name="sender">The Frame which failed navigation</param>
8685
/// <param name="e">Details about the navigation failure</param>
87-
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
86+
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
8887
{
8988
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
9089
}

QRCoderTests/Helpers/CategoryDiscoverer.cs

+2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ namespace QRCoderTests.Helpers.XUnitExtenstions;
1212
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
1313
public class CategoryAttribute : Attribute
1414
{
15+
#pragma warning disable IDE0060 // Remove unused parameter
1516
public CategoryAttribute(string category) { }
17+
#pragma warning restore IDE0060 // Remove unused parameter
1618
}
1719
#else
1820
public class CategoryDiscoverer : ITraitDiscoverer

0 commit comments

Comments
 (0)