Skip to content

Commit e0c5741

Browse files
committed
Project: warning as errors
1 parent 9a1d5a1 commit e0c5741

34 files changed

+204
-110
lines changed

.github/workflows/publish.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
dotnet-version: '9.0.x'
2020

2121
- name: Build and Publish AvaloniaVisualBasic.Desktop (Windows)
22-
run: dotnet publish AvaloniaVisualBasic.Desktop -f net9.0 -o bin/windows/ -p:PublishAot=true -p:PublishTrimmed=true
22+
run: dotnet publish AvaloniaVisualBasic.Desktop -f net9.0 -o bin/windows/ -p:PublishAot=true -p:PublishTrimmed=true -p:WarningAsErrors=false
2323

2424
- name: Build and Publish AvaloniaVisualBasic.Standalone (Windows)
25-
run: dotnet publish AvaloniaVisualBasic.Standalone -f net9.0 -o bin/windows/standalone/ -p:PublishAot=true -p:PublishTrimmed=true
25+
run: dotnet publish AvaloniaVisualBasic.Standalone -f net9.0 -o bin/windows/standalone/ -p:PublishAot=true -p:PublishTrimmed=true -p:WarningAsErrors=false
2626

2727
- name: Remove Debug Symbols (Windows)
2828
run: |
@@ -66,10 +66,10 @@ jobs:
6666
java-version: '21'
6767

6868
- name: Build and Publish AvaloniaVisualBasic.Desktop (Linux)
69-
run: dotnet publish AvaloniaVisualBasic.Desktop -f net9.0 -o bin/linux/ -p:PublishAot=true -p:PublishTrimmed=true
69+
run: dotnet publish AvaloniaVisualBasic.Desktop -f net9.0 -o bin/linux/ -p:PublishAot=true -p:PublishTrimmed=true -p:WarningAsErrors=false
7070

7171
- name: Build and Publish AvaloniaVisualBasic.Standalone (Linux)
72-
run: dotnet publish AvaloniaVisualBasic.Standalone -f net9.0 -o bin/linux/standalone/ -p:PublishAot=true -p:PublishTrimmed=true
72+
run: dotnet publish AvaloniaVisualBasic.Standalone -f net9.0 -o bin/linux/standalone/ -p:PublishAot=true -p:PublishTrimmed=true -p:WarningAsErrors=false
7373

7474
- name: Remove Debug Symbols (Linux)
7575
run: |
@@ -112,10 +112,10 @@ jobs:
112112
dotnet-version: '9.0.x'
113113

114114
- name: Build and Publish AvaloniaVisualBasic.Desktop (macOS)
115-
run: dotnet publish AvaloniaVisualBasic.Desktop -f net9.0 -o bin/macos/ -p:PublishAot=true -p:PublishTrimmed=true
115+
run: dotnet publish AvaloniaVisualBasic.Desktop -f net9.0 -o bin/macos/ -p:PublishAot=true -p:PublishTrimmed=true -p:WarningAsErrors=false
116116

117117
- name: Build and Publish AvaloniaVisualBasic.Standalone (macOS)
118-
run: dotnet publish AvaloniaVisualBasic.Standalone -f net9.0 -o bin/macos/standalone/ -p:PublishAot=true -p:PublishTrimmed=true
118+
run: dotnet publish AvaloniaVisualBasic.Standalone -f net9.0 -o bin/macos/standalone/ -p:PublishAot=true -p:PublishTrimmed=true -p:WarningAsErrors=false
119119

120120
- name: Remove Debug Symbols (macOS)
121121
run: |
@@ -138,7 +138,7 @@ jobs:
138138
uses: actions/upload-artifact@v4
139139
with:
140140
name: macos-bin
141-
path: ./bin/macos/vb6-macos-arm64.tar
141+
path: ./bin/macos/vb6-macos-arm64.tar.gz
142142

143143
- name: Release
144144
uses: softprops/action-gh-release@v2

AvaloniaVisualBasic.Browser/AvaloniaVisualBasic.Browser.csproj

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,4 @@
2828
<ItemGroup>
2929
<ProjectReference Include="..\AvaloniaVisualBasic\AvaloniaVisualBasic.csproj" />
3030
</ItemGroup>
31-
32-
<!-- https://github.com/dotnet/runtime/issues/109289#issuecomment-2448960065 -->
33-
<Target Name="Issue109289_Workaround" AfterTargets="_BrowserWasmWriteRspForLinking" Condition=" $(NETCoreSdkVersion.Contains('rc.2')) ">
34-
<ItemGroup>
35-
<_WasmLinkStepArgs Remove="@(_EmccLinkStepArgs)" />
36-
<_EmccLinkStepArgs Remove="&quot;%(_WasmNativeFileForLinking.Identity)&quot;" />
37-
<_WasmLinkDependencies Remove="@(_WasmNativeFileForLinking)" />
38-
39-
<_SkiaSharpToReorder Include="@(_WasmNativeFileForLinking)" Condition="$([System.String]::Copy('%(FullPath)').Contains('SkiaSharp'))" />
40-
<_WasmNativeFileForLinking Remove="@(_SkiaSharpToReorder)" />
41-
<_WasmNativeFileForLinking Include="@(_SkiaSharpToReorder)" />
42-
43-
<_EmccLinkStepArgs Include="&quot;%(_WasmNativeFileForLinking.Identity)&quot;" />
44-
<_WasmLinkDependencies Include="@(_WasmNativeFileForLinking)" />
45-
<_WasmLinkStepArgs Include="@(_EmccLinkStepArgs)" />
46-
</ItemGroup>
47-
</Target>
4831
</Project>

AvaloniaVisualBasic.Desktop/AvaloniaVisualBasic.Desktop.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<Nullable>enable</Nullable>
88
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
99
<ApplicationIcon>vb6icon.ico</ApplicationIcon>
10+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
11+
<NoWarn>$(NoWarn);CS1998</NoWarn>
12+
<WarningsNotAsErrors>IL2026;IL3053;IL2104;</WarningsNotAsErrors>
1013
</PropertyGroup>
1114

1215
<PropertyGroup>
@@ -15,6 +18,7 @@
1518

1619
<ItemGroup>
1720
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
21+
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
1822
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
1923
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
2024
</ItemGroup>

AvaloniaVisualBasic.Runtime/AvaloniaInterop/AvaloniaMethodsInteroperability.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ public static Vb6Value Call(this Control c, string method, IReadOnlyList<Vb6Valu
2424
}
2525

2626
throw new Exception($"Unknown method {method} on {c}");
27-
return Vb6Value.Nothing;
2827
}
2928
}

AvaloniaVisualBasic.Runtime/AvaloniaVisualBasic.Runtime.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<WarningsAsErrors>nullable</WarningsAsErrors>
77
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
88
<TrimMode>full</TrimMode>
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
<NoWarn>$(NoWarn);CS1998</NoWarn>
911
</PropertyGroup>
1012

1113
<ItemGroup>

AvaloniaVisualBasic.Runtime/BuiltinControls/VBLabel.axaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ public bool RecognizesAccessKey
8080
}
8181

8282
private ClassicBorderDecorator? decorator;
83-
private TextBlock? textblock;
84-
private AccessText? accessText;
8583

8684
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
8785
{

AvaloniaVisualBasic.Runtime/Interpreter/ExpressionExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public async Task<string> ExtractIdentifier(VB6Parser.ICS_S_VariableOrProcedureC
285285
{
286286
return array.GetValue(AsType<int>(args));
287287
}
288-
catch (IndexOutOfRangeException _)
288+
catch (IndexOutOfRangeException)
289289
{
290290
throw new VBRunTimeException(procOrArrayCall, VBStandardError.SubscriptOutOfRange);
291291
}

AvaloniaVisualBasic.Runtime/Interpreter/StatementExecutor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ public override async Task<ControlFlow> VisitLetStmt(VB6Parser.LetStmtContext co
450450
{
451451
throw new NotImplementedException($"{context.implicitCallStmt_InStmt()} is not supported");
452452
}
453-
454-
return default;
455453
}
456454

457455
public override async Task<ControlFlow> VisitLineInputStmt(VB6Parser.LineInputStmtContext context)

AvaloniaVisualBasic.Runtime/Interpreter/VB6Visitor.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,76 @@ namespace AvaloniaVisualBasic.Runtime.Interpreter;
66

77
public abstract class VB6Visitor<T> : VB6BaseVisitor<T>
88
{
9-
public T AsType<T>(Vb6Value value)
9+
public TT AsType<TT>(Vb6Value value)
1010
{
11-
if (!TryUnpack(value, out T val))
11+
if (!TryUnpack(value, out TT val))
1212
throw new VBCompileErrorException("Type mismatch");
1313
return val;
1414
}
1515

16-
public List<T> AsType<T>(IReadOnlyList<Vb6Value> indexes)
16+
public List<TT> AsType<TT>(IReadOnlyList<Vb6Value> indexes)
1717
{
18-
return indexes.Select(AsType<T>).ToList();
18+
return indexes.Select(AsType<TT>).ToList();
1919
}
2020

21-
public bool TryUnpack<T>(Vb6Value val, out T tout)
21+
public bool TryUnpack<TT>(Vb6Value val, out TT tout)
2222
{
2323
tout = default!;
24-
if (typeof(T) == typeof(int))
24+
if (typeof(TT) == typeof(int))
2525
{
2626
if (val.Type == Vb6Value.ValueType.Integer)
2727
{
28-
tout = (T)(object)(int)val.Value!;
28+
tout = (TT)(object)(int)val.Value!;
2929
return true;
3030
}
3131
if (val.Type == Vb6Value.ValueType.String)
3232
{
3333
if (int.TryParse((string?)val.Value ?? "", out var asInt))
3434
{
35-
tout = (T)(object)asInt;
35+
tout = (TT)(object)asInt;
3636
return true;
3737
}
3838
}
3939
return false;
4040
}
41-
if (typeof(T) == typeof(bool))
41+
if (typeof(TT) == typeof(bool))
4242
{
4343
if (val.Type == Vb6Value.ValueType.Boolean)
4444
{
45-
tout = (T)(object)(bool)val.Value!;
45+
tout = (TT)(object)(bool)val.Value!;
4646
return true;
4747
}
4848
return false;
4949
}
50-
if (typeof(T) == typeof(float))
50+
if (typeof(TT) == typeof(float))
5151
{
5252
if (val.Type == Vb6Value.ValueType.Integer)
5353
{
54-
tout = (T)(object)(float)(int)val.Value!;
54+
tout = (TT)(object)(float)(int)val.Value!;
5555
return true;
5656
}
5757
if (val.Type == Vb6Value.ValueType.Single)
5858
{
59-
tout = (T)(object)(float)val.Value!;
59+
tout = (TT)(object)(float)val.Value!;
6060
return true;
6161
}
6262
return false;
6363
}
64-
if (typeof(T) == typeof(double))
64+
if (typeof(TT) == typeof(double))
6565
{
6666
if (val.Type == Vb6Value.ValueType.Integer)
6767
{
68-
tout = (T)(object)(double)(int)val.Value!;
68+
tout = (TT)(object)(double)(int)val.Value!;
6969
return true;
7070
}
7171
if (val.Type == Vb6Value.ValueType.Single)
7272
{
73-
tout = (T)(object)(float)val.Value!;
73+
tout = (TT)(object)(float)val.Value!;
7474
return true;
7575
}
7676
if (val.Type == Vb6Value.ValueType.Double)
7777
{
78-
tout = (T)(object)(double)val.Value!;
78+
tout = (TT)(object)(double)val.Value!;
7979
return true;
8080
}
8181
return false;
@@ -84,7 +84,7 @@ public bool TryUnpack<T>(Vb6Value val, out T tout)
8484
return false;
8585
}
8686

87-
public bool TryUnpack<T>(Vb6Value left, Vb6Value right, out T tleft, out T tright)
87+
public bool TryUnpack<TT>(Vb6Value left, Vb6Value right, out TT tleft, out TT tright)
8888
{
8989
tright = default!;
9090
return TryUnpack(left, out tleft) && TryUnpack(right, out tright);

AvaloniaVisualBasic.Standalone/AvaloniaVisualBasic.Standalone.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<DebugSymbols>False</DebugSymbols>
1212
<DebugType>None</DebugType>
1313
<ApplicationIcon>form.ico</ApplicationIcon>
14+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
15+
<NoWarn>$(NoWarn);CS1998</NoWarn>
16+
<WarningsNotAsErrors>IL2026;IL3053;IL2104;</WarningsNotAsErrors>
1417
</PropertyGroup>
1518

1619
<PropertyGroup>
@@ -26,6 +29,7 @@
2629
<PrivateAssets>all</PrivateAssets>
2730
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2831
</PackageReference>
32+
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
2933
</ItemGroup>
3034

3135
<ItemGroup>

AvaloniaVisualBasic/App.axaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public override void Initialize()
2828
public override void OnFrameworkInitializationCompleted()
2929
{
3030
var rootViewModel = new DISetup().Root;
31+
Static.RootViewModel = rootViewModel;
3132

3233
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
3334
{

AvaloniaVisualBasic/ApplicationCommands.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ private class BaseDisabledCommand : ICommand
9595
{
9696
public bool CanExecute(object? parameter) => false;
9797
public void Execute(object? parameter) { }
98+
#pragma warning disable CS0067
9899
public event EventHandler? CanExecuteChanged;
100+
#pragma warning restore CS0067
99101
}
100102

101103
private static KeyModifiers GetPlatformCommandKey()

AvaloniaVisualBasic/AvaloniaVisualBasic.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<LangVersion>latest</LangVersion>
66
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
77
<TrimMode>full</TrimMode>
8+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9+
<NoWarn>$(NoWarn);CS1998</NoWarn>
10+
<WarningsNotAsErrors>IL2026;IL3053;IL2104;</WarningsNotAsErrors>
811
</PropertyGroup>
912

1013
<ItemGroup>
@@ -32,6 +35,7 @@
3235
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3336
</PackageReference>
3437
<PackageReference Include="R3" Version="1.2.9" />
38+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
3539
</ItemGroup>
3640

3741
<ItemGroup>

AvaloniaVisualBasic/Controls/MDI/MDICaptionButtons.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private void Attach(MDIWindow hostWindow)
3333
}
3434
}
3535

36-
private void Detach()
36+
private new void Detach()
3737
{
3838
if (disposables != null)
3939
{

AvaloniaVisualBasic/Controls/MDI/MDIHost.axaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public void Tile(Orientation orientation)
5454
for (int i = 0; i < windowCount; ++i)
5555
{
5656
var container = ContainerFromIndex(i);
57+
if (container == null)
58+
continue;
5759
MDIHostPanel.SetWindowState(container, WindowState.Normal);
5860
MDIHostPanel.SetWindowLocation(container, orientation == Orientation.Horizontal ? new Point(x, 0) : new Point(0, y));
5961
MDIHostPanel.SetWindowSize(container, windowSize);
@@ -77,6 +79,8 @@ public void Cascade()
7779
x += 20;
7880
y += 20;
7981
var container = ContainerFromIndex(i);
82+
if (container == null)
83+
continue;
8084
MDIHostPanel.SetWindowState(container, WindowState.Normal);
8185
MDIHostPanel.SetWindowLocation(container, new Point(x, y));
8286
MDIHostPanel.SetWindowSize(container, windowSize);

AvaloniaVisualBasic/Controls/MDI/MDIWindow.axaml.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace AvaloniaVisualBasic.Controls;
1717

1818
public class MDIWindow : ContentControl
1919
{
20-
private ClassicBorderDecorator border;
21-
private Border titleBar;
20+
private ClassicBorderDecorator? border;
21+
private Border? titleBar;
2222

2323
public static readonly StyledProperty<IImage?> IconProperty = AvaloniaProperty.Register<MDIWindow, IImage?>("Icon");
2424
public static readonly StyledProperty<string> TitleProperty = AvaloniaProperty.Register<MDIWindow, string>("Title");
@@ -79,15 +79,16 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
7979

8080
var contentPresenter = e.NameScope.Get<ContentPresenter>("PART_ContentPresenter");
8181
contentPresenter.GetObservable(ContentPresenter.ChildProperty)
82-
.Subscribe(new ActionObserver<Control>(control =>
82+
.Subscribe(new ActionObserver<Control?>(control =>
8383
{
8484
var child = contentPresenter.Child;
8585
if (child != null)
8686
{
8787
child.GetObservable(CommandManager.CommandBindingsProperty)
88-
.Subscribe(new ActionObserver<IList<CommandBinding>>(bindings =>
88+
.Subscribe(new ActionObserver<IList<CommandBinding>?>(bindings =>
8989
{
90-
CommandManager.SetCommandBindings(this, bindings);
90+
if (bindings != null)
91+
CommandManager.SetCommandBindings(this, bindings);
9192
}));
9293
}
9394
}));
@@ -134,7 +135,8 @@ private void SetResizeCursor(PointerEventArgs e)
134135
}
135136
}
136137

137-
border.Cursor = new Cursor(cursor);
138+
if (border != null)
139+
border.Cursor = new Cursor(cursor);
138140
}
139141

140142
private void OnBorderReleased(object? sender, PointerReleasedEventArgs e)

AvaloniaVisualBasic/Controls/Properties/PropertyColorBox.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace AvaloniaVisualBasic.Controls;
1111
public class PropertyColorBox : TemplatedControl
1212
{
1313
private ListBox? paletteListBox, systemColorsListBox;
14-
private bool systemColorListBoxSetting;
15-
private bool paletteListBoxSetting;
1614
private bool syncing;
1715

1816
public static readonly StyledProperty<VBColor> ColorProperty = AvaloniaProperty.Register<PropertyColorBox, VBColor>(nameof(Color), defaultBindingMode: BindingMode.TwoWay);

AvaloniaVisualBasic/Controls/Properties/PropertyFontBox.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Avalonia.Data;
66
using Avalonia.Interactivity;
77
using AvaloniaVisualBasic.Runtime.BuiltinTypes;
8+
using AvaloniaVisualBasic.Utils;
89
using Classic.CommonControls.Dialogs;
910

1011
namespace AvaloniaVisualBasic.Controls;
@@ -36,15 +37,14 @@ private void OnButtonClick(object? sender, RoutedEventArgs e)
3637
{
3738
async Task OpenFontWindow()
3839
{
39-
var result = await FontDialog.ShowDialog(this.VisualRoot as Window, new FontDialogResult(
40-
Font.FontFamily, Font.Style, Font.Weight, Font.Size));
40+
var result = await Static.RootViewModel.WindowManager.ShowFontDialog(new FontDialogResult(Font.FontFamily, Font.Style, Font.Weight, Font.Size));
4141
if (result != null)
4242
{
4343
SetCurrentValue(FontProperty, new VBFont(result.Family, (int)result.Size, result.Weight, result.Style));
4444
}
4545
}
4646

47-
OpenFontWindow();
47+
OpenFontWindow().ListenErrors();
4848
}
4949

5050
static PropertyFontBox()

0 commit comments

Comments
 (0)