Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: warn on sufix #82

Merged
merged 4 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 39 additions & 36 deletions src/SymbolCollector.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Threading.Tasks;
using Android.App;
Expand Down Expand Up @@ -30,21 +30,21 @@ public class MainActivity : AppCompatActivity
private readonly IHost _host;
private readonly IServiceProvider _serviceProvider;

protected override void OnCreate(Bundle savedInstanceState)
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);

var footerText = (TextView)base.FindViewById(Resource.Id.footer);
var versionName = Application.Context.ApplicationContext.PackageManager
.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName;
var footerText = (TextView)base.FindViewById(Resource.Id.footer)!;
var versionName = Application.Context.ApplicationContext?.PackageManager?
.GetPackageInfo(Application.Context.ApplicationContext?.PackageName ?? "", 0)?.VersionName;
footerText.Text = $"Version: {versionName}\n" + footerText.Text;

var uploader = _serviceProvider.GetRequiredService<AndroidUploader>();
var metrics = _serviceProvider.GetRequiredService<ClientMetrics>();
var uploadButton = (Button)base.FindViewById(Resource.Id.btnUpload);
var cancelButton = (Button)base.FindViewById(Resource.Id.btnCancel);
var url = (EditText)base.FindViewById(Resource.Id.server_url);
var uploadButton = (Button)base.FindViewById(Resource.Id.btnUpload)!;
var cancelButton = (Button)base.FindViewById(Resource.Id.btnCancel)!;
var url = (EditText)base.FindViewById(Resource.Id.server_url)!;
var source = new CancellationTokenSource();

url.FocusChange += (sender, args) =>
Expand Down Expand Up @@ -73,7 +73,7 @@ async void OnUploadButtonOnClick(object sender, EventArgs args)
var uploadTask = uploader.StartUpload(_friendlyName, source.Token);
var updateUiTask = StartUiUpdater(source.Token, metrics);

await Upload(uploadTask, updateUiTask, metrics, cancelButton, uploadButton, source);
await UploadAsync(uploadTask, updateUiTask, metrics, cancelButton, uploadButton, source);
}

void OnCancelButtonOnClick(object sender, EventArgs args)
Expand All @@ -92,21 +92,21 @@ private void Unfocus()
}
}

private async Task Upload(
private async Task UploadAsync(
Task uploadTask,
Task updateUiTask,
ClientMetrics metrics,
View cancelButton,
View uploadButton,
CancellationTokenSource source)
{
var container = base.FindViewById(Resource.Id.metrics_container);
var container = base.FindViewById(Resource.Id.metrics_container)!;
container.Visibility = ViewStates.Visible;

var doneText = (TextView)base.FindViewById(Resource.Id.done_text);
var ranForLabel = (TextView)base.FindViewById(Resource.Id.ran_for_label);
var ranForContainer = base.FindViewById(Resource.Id.ran_for_container);
var ranForView = base.FindViewById(Resource.Id.ran_for_view);
var doneText = (TextView)base.FindViewById(Resource.Id.done_text)!;
var ranForLabel = (TextView)base.FindViewById(Resource.Id.ran_for_label)!;
var ranForContainer = base.FindViewById(Resource.Id.ran_for_container)!;
var ranForView = base.FindViewById(Resource.Id.ran_for_view)!;

try
{
Expand Down Expand Up @@ -146,18 +146,18 @@ private async Task Upload(
private Task StartUiUpdater(CancellationToken token, ClientMetrics metrics) =>
Task.Run(async () =>
{
var uploadedCount = (TextView)base.FindViewById(Resource.Id.uploaded_count);
var startedTime = (TextView)base.FindViewById(Resource.Id.started_time);
var alreadyExisted = (TextView)base.FindViewById(Resource.Id.already_existed);
var filesProcessed = (TextView)base.FindViewById(Resource.Id.files_processed);
var successfullyUpload = (TextView)base.FindViewById(Resource.Id.successfully_upload);
var elfFiles = (TextView)base.FindViewById(Resource.Id.elf_files);
var failedParsing = (TextView)base.FindViewById(Resource.Id.failed_parsing);
var failedUploading = (TextView)base.FindViewById(Resource.Id.failed_uploading);
var jobsInFlight = (TextView)base.FindViewById(Resource.Id.jobs_in_flight);
var directoryNotFound = (TextView)base.FindViewById(Resource.Id.directory_not_found);
var fileNotFound = (TextView)base.FindViewById(Resource.Id.file_not_found);
var unauthorizedAccess = (TextView)base.FindViewById(Resource.Id.unauthorized_access);
var uploadedCount = (TextView)base.FindViewById(Resource.Id.uploaded_count)!;
var startedTime = (TextView)base.FindViewById(Resource.Id.started_time)!;
var alreadyExisted = (TextView)base.FindViewById(Resource.Id.already_existed)!;
var filesProcessed = (TextView)base.FindViewById(Resource.Id.files_processed)!;
var successfullyUpload = (TextView)base.FindViewById(Resource.Id.successfully_upload)!;
var elfFiles = (TextView)base.FindViewById(Resource.Id.elf_files)!;
var failedParsing = (TextView)base.FindViewById(Resource.Id.failed_parsing)!;
var failedUploading = (TextView)base.FindViewById(Resource.Id.failed_uploading)!;
var jobsInFlight = (TextView)base.FindViewById(Resource.Id.jobs_in_flight)!;
var directoryNotFound = (TextView)base.FindViewById(Resource.Id.directory_not_found)!;
var fileNotFound = (TextView)base.FindViewById(Resource.Id.file_not_found)!;
var unauthorizedAccess = (TextView)base.FindViewById(Resource.Id.unauthorized_access)!;

while (!token.IsCancellationRequested)
{
Expand Down Expand Up @@ -198,25 +198,28 @@ private void ShowError(Exception e)
e = ae.InnerExceptions[0];
}

var uploadButton = (Button)base.FindViewById(Resource.Id.btnUpload);
var cancelButton = (Button)base.FindViewById(Resource.Id.btnCancel);
var uploadButton = (Button)base.FindViewById(Resource.Id.btnUpload)!;
var cancelButton = (Button)base.FindViewById(Resource.Id.btnCancel)!;

var lastEvent = SentrySdk.LastEventId;
// TODO: SentryId.Empty should operator overload ==
var message = SentryId.Empty.ToString() == lastEvent.ToString()
? e?.ToString() ?? "Something didn't quite work."
: $"Sentry id {lastEvent}:\n{e}";

var builder = new AlertDialog.Builder(this);
builder
var builder = new AlertDialog.Builder(this)
.SetTitle("Error")
.SetMessage(message)
.SetNeutralButton("Ironic eh?", (o, eventArgs) =>
?.SetMessage(message)
?.SetNeutralButton("Ironic eh?", (o, eventArgs) =>
{
uploadButton.Enabled = true;
cancelButton.Enabled = false;
})
.Show();
});
if (builder is null)
{
throw new InvalidOperationException("Couldn't get a dialog built.");
}
builder.Show();
}

public MainActivity()
Expand All @@ -228,7 +231,7 @@ public MainActivity()
try
{
uname = Os.Uname();
_friendlyName += $"-kernel-{uname.Release}";
_friendlyName += $"-kernel-{uname?.Release ?? "??"}";
}
catch
{
Expand Down
8 changes: 4 additions & 4 deletions src/SymbolCollector.Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
223 changes: 114 additions & 109 deletions src/SymbolCollector.Android/SymbolCollector.Android.csproj
Original file line number Diff line number Diff line change
@@ -1,109 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B66B3A36-CE78-4278-998B-D43F6E0C63E8}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SymbolCollector.Android</RootNamespace>
<AssemblyName>SymbolCollector.Android</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>debug.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>android</AndroidSigningStorePass>
<AndroidSigningKeyAlias>androiddebugkey</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>android</AndroidSigningKeyPass>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<AndroidSupportedAbis>armeabi-v7a;arm64-v8a;x86;x86_64</AndroidSupportedAbis>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>debug.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>android</AndroidSigningStorePass>
<AndroidSigningKeyAlias>androiddebugkey</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>android</AndroidSigningKeyPass>
</PropertyGroup>
<PropertyGroup>
<AndroidUseIntermediateDesignerFile>True</AndroidUseIntermediateDesignerFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
</ItemGroup>
<ItemGroup>
<Compile Include="AndroidUploader.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\activity_main.axml">
<SubType>Designer</SubType>
</AndroidResource>
<AndroidResource Include="Resources\values\colors.xml" />
<AndroidResource Include="Resources\values\ic_launcher_background.xml" />
<AndroidResource Include="Resources\values\strings.xml" />
<AndroidResource Include="Resources\values\styles.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5" />
<PackageReference Include="Sentry" Version="2.1.5-beta" />
<PackageReference Include="Sentry.Extensions.Logging" Version="2.1.5-beta" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SymbolCollector.Core\SymbolCollector.Core.csproj">
<Project>{5c904261-899c-4b8f-bea4-5cf93fedd505}</Project>
<Name>SymbolCollector.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B66B3A36-CE78-4278-998B-D43F6E0C63E8}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SymbolCollector.Android</RootNamespace>
<AssemblyName>SymbolCollector.Android</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>debug.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>android</AndroidSigningStorePass>
<AndroidSigningKeyAlias>androiddebugkey</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>android</AndroidSigningKeyPass>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
<AndroidUseAapt2>true</AndroidUseAapt2>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<AndroidSupportedAbis>armeabi-v7a;arm64-v8a;x86;x86_64</AndroidSupportedAbis>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>debug.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>android</AndroidSigningStorePass>
<AndroidSigningKeyAlias>androiddebugkey</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>android</AndroidSigningKeyPass>
</PropertyGroup>
<PropertyGroup>
<AndroidUseIntermediateDesignerFile>True</AndroidUseIntermediateDesignerFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
</ItemGroup>
<ItemGroup>
<Compile Include="AndroidUploader.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\activity_main.axml">
<SubType>Designer</SubType>
</AndroidResource>
<AndroidResource Include="Resources\values\colors.xml" />
<AndroidResource Include="Resources\values\ic_launcher_background.xml" />
<AndroidResource Include="Resources\values\strings.xml" />
<AndroidResource Include="Resources\values\styles.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5" />
<PackageReference Include="Sentry" Version="2.1.5-beta" />
<PackageReference Include="Sentry.Extensions.Logging" Version="2.1.5-beta" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SymbolCollector.Core\SymbolCollector.Core.csproj">
<Project>{5c904261-899c-4b8f-bea4-5cf93fedd505}</Project>
<Name>SymbolCollector.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>