Skip to content

Commit

Permalink
Project: warning as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BAndysc committed Nov 17, 2024
1 parent 9a1d5a1 commit 0b5b0fc
Show file tree
Hide file tree
Showing 34 changed files with 202 additions and 109 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
dotnet-version: '9.0.x'

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

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

- name: Remove Debug Symbols (Windows)
run: |
Expand Down Expand Up @@ -66,10 +66,10 @@ jobs:
java-version: '21'

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

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

- name: Remove Debug Symbols (Linux)
run: |
Expand Down Expand Up @@ -112,10 +112,10 @@ jobs:
dotnet-version: '9.0.x'

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

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

- name: Remove Debug Symbols (macOS)
run: |
Expand Down
17 changes: 0 additions & 17 deletions AvaloniaVisualBasic.Browser/AvaloniaVisualBasic.Browser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,4 @@
<ItemGroup>
<ProjectReference Include="..\AvaloniaVisualBasic\AvaloniaVisualBasic.csproj" />
</ItemGroup>

<!-- https://github.com/dotnet/runtime/issues/109289#issuecomment-2448960065 -->
<Target Name="Issue109289_Workaround" AfterTargets="_BrowserWasmWriteRspForLinking" Condition=" $(NETCoreSdkVersion.Contains('rc.2')) ">
<ItemGroup>
<_WasmLinkStepArgs Remove="@(_EmccLinkStepArgs)" />
<_EmccLinkStepArgs Remove="&quot;%(_WasmNativeFileForLinking.Identity)&quot;" />
<_WasmLinkDependencies Remove="@(_WasmNativeFileForLinking)" />

<_SkiaSharpToReorder Include="@(_WasmNativeFileForLinking)" Condition="$([System.String]::Copy('%(FullPath)').Contains('SkiaSharp'))" />
<_WasmNativeFileForLinking Remove="@(_SkiaSharpToReorder)" />
<_WasmNativeFileForLinking Include="@(_SkiaSharpToReorder)" />

<_EmccLinkStepArgs Include="&quot;%(_WasmNativeFileForLinking.Identity)&quot;" />
<_WasmLinkDependencies Include="@(_WasmNativeFileForLinking)" />
<_WasmLinkStepArgs Include="@(_EmccLinkStepArgs)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationIcon>vb6icon.ico</ApplicationIcon>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS1998</NoWarn>
<WarningsNotAsErrors>IL2026;IL3053;IL2104;</WarningsNotAsErrors>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -15,6 +18,7 @@

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ public static Vb6Value Call(this Control c, string method, IReadOnlyList<Vb6Valu
}

throw new Exception($"Unknown method {method} on {c}");
return Vb6Value.Nothing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<WarningsAsErrors>nullable</WarningsAsErrors>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<TrimMode>full</TrimMode>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS1998</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions AvaloniaVisualBasic.Runtime/BuiltinControls/VBLabel.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public bool RecognizesAccessKey
}

private ClassicBorderDecorator? decorator;
private TextBlock? textblock;
private AccessText? accessText;

protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public async Task<string> ExtractIdentifier(VB6Parser.ICS_S_VariableOrProcedureC
{
return array.GetValue(AsType<int>(args));
}
catch (IndexOutOfRangeException _)
catch (IndexOutOfRangeException)
{
throw new VBRunTimeException(procOrArrayCall, VBStandardError.SubscriptOutOfRange);
}
Expand Down
2 changes: 0 additions & 2 deletions AvaloniaVisualBasic.Runtime/Interpreter/StatementExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,6 @@ public override async Task<ControlFlow> VisitLetStmt(VB6Parser.LetStmtContext co
{
throw new NotImplementedException($"{context.implicitCallStmt_InStmt()} is not supported");
}

return default;
}

public override async Task<ControlFlow> VisitLineInputStmt(VB6Parser.LineInputStmtContext context)
Expand Down
36 changes: 18 additions & 18 deletions AvaloniaVisualBasic.Runtime/Interpreter/VB6Visitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,76 @@ namespace AvaloniaVisualBasic.Runtime.Interpreter;

public abstract class VB6Visitor<T> : VB6BaseVisitor<T>
{
public T AsType<T>(Vb6Value value)
public TT AsType<TT>(Vb6Value value)
{
if (!TryUnpack(value, out T val))
if (!TryUnpack(value, out TT val))
throw new VBCompileErrorException("Type mismatch");
return val;
}

public List<T> AsType<T>(IReadOnlyList<Vb6Value> indexes)
public List<TT> AsType<TT>(IReadOnlyList<Vb6Value> indexes)
{
return indexes.Select(AsType<T>).ToList();
return indexes.Select(AsType<TT>).ToList();
}

public bool TryUnpack<T>(Vb6Value val, out T tout)
public bool TryUnpack<TT>(Vb6Value val, out TT tout)
{
tout = default!;
if (typeof(T) == typeof(int))
if (typeof(TT) == typeof(int))
{
if (val.Type == Vb6Value.ValueType.Integer)
{
tout = (T)(object)(int)val.Value!;
tout = (TT)(object)(int)val.Value!;
return true;
}
if (val.Type == Vb6Value.ValueType.String)
{
if (int.TryParse((string?)val.Value ?? "", out var asInt))
{
tout = (T)(object)asInt;
tout = (TT)(object)asInt;
return true;
}
}
return false;
}
if (typeof(T) == typeof(bool))
if (typeof(TT) == typeof(bool))
{
if (val.Type == Vb6Value.ValueType.Boolean)
{
tout = (T)(object)(bool)val.Value!;
tout = (TT)(object)(bool)val.Value!;
return true;
}
return false;
}
if (typeof(T) == typeof(float))
if (typeof(TT) == typeof(float))
{
if (val.Type == Vb6Value.ValueType.Integer)
{
tout = (T)(object)(float)(int)val.Value!;
tout = (TT)(object)(float)(int)val.Value!;
return true;
}
if (val.Type == Vb6Value.ValueType.Single)
{
tout = (T)(object)(float)val.Value!;
tout = (TT)(object)(float)val.Value!;
return true;
}
return false;
}
if (typeof(T) == typeof(double))
if (typeof(TT) == typeof(double))
{
if (val.Type == Vb6Value.ValueType.Integer)
{
tout = (T)(object)(double)(int)val.Value!;
tout = (TT)(object)(double)(int)val.Value!;
return true;
}
if (val.Type == Vb6Value.ValueType.Single)
{
tout = (T)(object)(float)val.Value!;
tout = (TT)(object)(float)val.Value!;
return true;
}
if (val.Type == Vb6Value.ValueType.Double)
{
tout = (T)(object)(double)val.Value!;
tout = (TT)(object)(double)val.Value!;
return true;
}
return false;
Expand All @@ -84,7 +84,7 @@ public bool TryUnpack<T>(Vb6Value val, out T tout)
return false;
}

public bool TryUnpack<T>(Vb6Value left, Vb6Value right, out T tleft, out T tright)
public bool TryUnpack<TT>(Vb6Value left, Vb6Value right, out TT tleft, out TT tright)
{
tright = default!;
return TryUnpack(left, out tleft) && TryUnpack(right, out tright);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<ApplicationIcon>form.ico</ApplicationIcon>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS1998</NoWarn>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -26,6 +28,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions AvaloniaVisualBasic/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public override void Initialize()
public override void OnFrameworkInitializationCompleted()
{
var rootViewModel = new DISetup().Root;
Static.RootViewModel = rootViewModel;

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
Expand Down
2 changes: 2 additions & 0 deletions AvaloniaVisualBasic/ApplicationCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ private class BaseDisabledCommand : ICommand
{
public bool CanExecute(object? parameter) => false;
public void Execute(object? parameter) { }
#pragma warning disable CS0067
public event EventHandler? CanExecuteChanged;
#pragma warning restore CS0067
}

private static KeyModifiers GetPlatformCommandKey()
Expand Down
4 changes: 4 additions & 0 deletions AvaloniaVisualBasic/AvaloniaVisualBasic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<LangVersion>latest</LangVersion>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<TrimMode>full</TrimMode>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS1998</NoWarn>
<WarningsNotAsErrors>IL2026;IL3053;IL2104;</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -32,6 +35,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="R3" Version="1.2.9" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion AvaloniaVisualBasic/Controls/MDI/MDICaptionButtons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void Attach(MDIWindow hostWindow)
}
}

private void Detach()
private new void Detach()
{
if (disposables != null)
{
Expand Down
4 changes: 4 additions & 0 deletions AvaloniaVisualBasic/Controls/MDI/MDIHost.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public void Tile(Orientation orientation)
for (int i = 0; i < windowCount; ++i)
{
var container = ContainerFromIndex(i);
if (container == null)
continue;
MDIHostPanel.SetWindowState(container, WindowState.Normal);
MDIHostPanel.SetWindowLocation(container, orientation == Orientation.Horizontal ? new Point(x, 0) : new Point(0, y));
MDIHostPanel.SetWindowSize(container, windowSize);
Expand All @@ -77,6 +79,8 @@ public void Cascade()
x += 20;
y += 20;
var container = ContainerFromIndex(i);
if (container == null)
continue;
MDIHostPanel.SetWindowState(container, WindowState.Normal);
MDIHostPanel.SetWindowLocation(container, new Point(x, y));
MDIHostPanel.SetWindowSize(container, windowSize);
Expand Down
14 changes: 8 additions & 6 deletions AvaloniaVisualBasic/Controls/MDI/MDIWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace AvaloniaVisualBasic.Controls;

public class MDIWindow : ContentControl
{
private ClassicBorderDecorator border;
private Border titleBar;
private ClassicBorderDecorator? border;
private Border? titleBar;

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

var contentPresenter = e.NameScope.Get<ContentPresenter>("PART_ContentPresenter");
contentPresenter.GetObservable(ContentPresenter.ChildProperty)
.Subscribe(new ActionObserver<Control>(control =>
.Subscribe(new ActionObserver<Control?>(control =>
{
var child = contentPresenter.Child;
if (child != null)
{
child.GetObservable(CommandManager.CommandBindingsProperty)
.Subscribe(new ActionObserver<IList<CommandBinding>>(bindings =>
.Subscribe(new ActionObserver<IList<CommandBinding>?>(bindings =>
{
CommandManager.SetCommandBindings(this, bindings);
if (bindings != null)
CommandManager.SetCommandBindings(this, bindings);
}));
}
}));
Expand Down Expand Up @@ -134,7 +135,8 @@ private void SetResizeCursor(PointerEventArgs e)
}
}

border.Cursor = new Cursor(cursor);
if (border != null)
border.Cursor = new Cursor(cursor);
}

private void OnBorderReleased(object? sender, PointerReleasedEventArgs e)
Expand Down
2 changes: 0 additions & 2 deletions AvaloniaVisualBasic/Controls/Properties/PropertyColorBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace AvaloniaVisualBasic.Controls;
public class PropertyColorBox : TemplatedControl
{
private ListBox? paletteListBox, systemColorsListBox;
private bool systemColorListBoxSetting;
private bool paletteListBoxSetting;
private bool syncing;

public static readonly StyledProperty<VBColor> ColorProperty = AvaloniaProperty.Register<PropertyColorBox, VBColor>(nameof(Color), defaultBindingMode: BindingMode.TwoWay);
Expand Down
6 changes: 3 additions & 3 deletions AvaloniaVisualBasic/Controls/Properties/PropertyFontBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Avalonia.Data;
using Avalonia.Interactivity;
using AvaloniaVisualBasic.Runtime.BuiltinTypes;
using AvaloniaVisualBasic.Utils;
using Classic.CommonControls.Dialogs;

namespace AvaloniaVisualBasic.Controls;
Expand Down Expand Up @@ -36,15 +37,14 @@ private void OnButtonClick(object? sender, RoutedEventArgs e)
{
async Task OpenFontWindow()
{
var result = await FontDialog.ShowDialog(this.VisualRoot as Window, new FontDialogResult(
Font.FontFamily, Font.Style, Font.Weight, Font.Size));
var result = await Static.RootViewModel.WindowManager.ShowFontDialog(new FontDialogResult(Font.FontFamily, Font.Style, Font.Weight, Font.Size));
if (result != null)
{
SetCurrentValue(FontProperty, new VBFont(result.Family, (int)result.Size, result.Weight, result.Style));
}
}

OpenFontWindow();
OpenFontWindow().ListenErrors();
}

static PropertyFontBox()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace AvaloniaVisualBasic.Converters;

public class StringMultiplierConverter : IValueConverter
{
public string String { get; set; }
public string String { get; set; } = "";

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
Expand Down
Loading

0 comments on commit 0b5b0fc

Please sign in to comment.