PS-785 Added logs for exceptions on UpdateTemplatedCell and the extra data on each ExtendedCollectionView usage (#1943)

This commit is contained in:
Federico Maccaroni 2022-06-07 15:57:53 -03:00 committed by GitHub
parent b223f5f16e
commit ec71b21264
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 68 additions and 11 deletions

View file

@ -4,5 +4,6 @@ namespace Bit.App.Controls
{
public class ExtendedCollectionView : CollectionView
{
public string ExtraDataForLogging { get; set; }
}
}

View file

@ -48,7 +48,8 @@
IsVisible="{Binding ShowNoData, Converter={StaticResource inverseBool}}"
ItemsSource="{Binding History}"
VerticalOptions="FillAndExpand"
StyleClass="list, list-platform">
StyleClass="list, list-platform"
ExtraDataForLogging="Generator History Page">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="domain:GeneratedPasswordHistory">
<Grid

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<pages:BaseContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Pages.SendGroupingsPage"
@ -138,7 +138,8 @@
ItemTemplate="{StaticResource sendListItemDataTemplateSelector}"
SelectionMode="Single"
SelectionChanged="RowSelected"
StyleClass="list, list-platform" />
StyleClass="list, list-platform"
ExtraDataForLogging="Send Groupings Page" />
</RefreshView>
</StackLayout>
</ResourceDictionary>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<pages:BaseContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
@ -66,7 +66,8 @@
VerticalOptions="FillAndExpand"
SelectionMode="Single"
SelectionChanged="RowSelected"
StyleClass="list, list-platform">
StyleClass="list, list-platform"
ExtraDataForLogging="Sends Page">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="views:SendView">
<controls:SendViewCell

View file

@ -38,7 +38,8 @@
VerticalOptions="FillAndExpand"
SelectionMode="Single"
SelectionChanged="RowSelected"
StyleClass="list, list-platform">
StyleClass="list, list-platform"
ExtraDataForLogging="Folders Page">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="views:FolderView">
<controls:ExtendedStackLayout

View file

@ -113,6 +113,7 @@
ItemTemplate="{StaticResource listItemDataTemplateSelector}"
SelectionMode="Single"
SelectionChanged="RowSelected"
StyleClass="list, list-platform" />
StyleClass="list, list-platform"
ExtraDataForLogging="Settings Page" />
</pages:BaseContentPage>

View file

@ -85,7 +85,8 @@
ItemTemplate="{StaticResource listItemDataTemplateSelector}"
SelectionMode="Single"
SelectionChanged="RowSelected"
StyleClass="list, list-platform" />
StyleClass="list, list-platform"
ExtraDataForLogging="Autofill Ciphers Page" />
</StackLayout>
</ResourceDictionary>
</ContentPage.Resources>

View file

@ -68,7 +68,8 @@
VerticalOptions="FillAndExpand"
SelectionMode="Single"
SelectionChanged="RowSelected"
StyleClass="list, list-platform">
StyleClass="list, list-platform"
ExtraDataForLogging="Ciphers Page">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="views:CipherView">
<controls:CipherViewCell

View file

@ -155,7 +155,8 @@
ItemTemplate="{StaticResource listItemDataTemplateSelector}"
SelectionMode="Single"
SelectionChanged="RowSelected"
StyleClass="list, list-platform" />
StyleClass="list, list-platform"
ExtraDataForLogging="Groupings Page" />
</RefreshView>
</StackLayout>
</ResourceDictionary>

View file

@ -39,7 +39,8 @@
IsVisible="{Binding ShowNoData, Converter={StaticResource inverseBool}}"
ItemsSource="{Binding History}"
VerticalOptions="FillAndExpand"
StyleClass="list, list-platform">
StyleClass="list, list-platform"
ExtraDataForLogging="Password History Page">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="views:PasswordHistoryView">
<Grid

View file

@ -0,0 +1,16 @@
using Bit.App.Controls;
using Bit.iOS.Core.Renderers.CollectionView;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ExtendedCollectionView), typeof(ExtendedCollectionViewRenderer))]
namespace Bit.iOS.Core.Renderers.CollectionView
{
public class ExtendedCollectionViewRenderer : GroupableItemsViewRenderer<ExtendedCollectionView, GroupableItemsViewController<ExtendedCollectionView>>
{
protected override GroupableItemsViewController<ExtendedCollectionView> CreateController(ExtendedCollectionView itemsView, ItemsViewLayout layout)
{
return new ExtendedGroupableItemsViewController<ExtendedCollectionView>(itemsView, layout);
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using Bit.App.Controls;
using Foundation;
using Xamarin.Forms.Platform.iOS;
namespace Bit.iOS.Core.Renderers.CollectionView
{
public class ExtendedGroupableItemsViewController<TItemsView> : GroupableItemsViewController<TItemsView>
where TItemsView : ExtendedCollectionView
{
public ExtendedGroupableItemsViewController(TItemsView groupableItemsView, ItemsViewLayout layout)
: base(groupableItemsView, layout)
{
}
protected override void UpdateTemplatedCell(TemplatedCell cell, NSIndexPath indexPath)
{
try
{
base.UpdateTemplatedCell(cell, indexPath);
}
catch (Exception ex) when (ItemsView?.ExtraDataForLogging != null)
{
throw new Exception("Error in ExtendedCollectionView, extra data: " + ItemsView.ExtraDataForLogging, ex);
}
}
}
}

View file

@ -138,6 +138,7 @@
<ItemGroup>
<Folder Include="Resources\" />
<Folder Include="Effects\" />
<Folder Include="Renderers\CollectionView\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Constants.cs" />
@ -194,6 +195,8 @@
<Compile Include="Services\ClipboardService.cs" />
<Compile Include="Utilities\FontElementExtensions.cs" />
<Compile Include="Effects\ScrollViewContentInsetAdjustmentBehaviorEffect.cs" />
<Compile Include="Renderers\CollectionView\ExtendedCollectionViewRenderer.cs" />
<Compile Include="Renderers\CollectionView\ExtendedGroupableItemsViewController.cs" />
<Compile Include="Utilities\UISearchBarExtensions.cs" />
</ItemGroup>
<ItemGroup>