This is a list of stuff that the average software developer does from week to week
- Code design
- Refactoring
- Algorithms
- Profiling
- Code reviews
- Building frameworks
| trigger: | |
| - main | |
| pool: | |
| vmImage: "windows-latest" | |
| steps: | |
| - task: NuGetCommand@2 | |
| inputs: | |
| command: "restore" |
| <?xml version="1.0" encoding="utf-8"?> | |
| <package | |
| xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> | |
| <metadata> | |
| <id>Device.Net</id> | |
| <title>Device.Net</title> | |
| <description>Cross-platform .NET framework for talking to connected devices in a uniform way through dependency injection. | |
| Alpha version. Please use 3.x for a stable release</description> | |
| <summary>Cross-platform .NET framework for talking to connected devices in a uniform way through dependency injection.</summary> |
| <Project Sdk="Microsoft.NET.Sdk"> | |
| <PropertyGroup> | |
| <LangVersion>9.0</LangVersion> | |
| <TargetFrameworks>netstandard2.0;net45;</TargetFrameworks> | |
| <NoWarn>NU5125</NoWarn> | |
| <TreatWarningsAsErrors>false</TreatWarningsAsErrors> | |
| <DocumentationFile>Device.Net.xml</DocumentationFile> | |
| <Version>4.0.5-alpha</Version> | |
| <DebugType>embedded</DebugType> | |
| <DebugSymbols>true</DebugSymbols> |
| //Configure logging | |
| var loggerFactory = LoggerFactory.Create((builder) => | |
| { | |
| _ = builder.AddDebug().SetMinimumLevel(LogLevel.Trace); | |
| }); | |
| //Register the factory for creating Hid devices. | |
| var hidFactory = | |
| new FilterDeviceDefinition(vendorId: 0x534C, productId: 0x0001, label: "Trezor One Firmware 1.6.x", usagePage: 65280) | |
| .CreateWindowsHidDeviceFactory(loggerFactory); |
| public static Task ClearStatusAsync(this IUsbDevice usbDevice) | |
| => usbDevice.PerformControlTransferAsync(new SetupPacket | |
| ( | |
| requestType: new UsbDeviceRequestType( | |
| RequestDirection.In, | |
| RequestType.Class, | |
| RequestRecipient.Interface), | |
| request: DFU_CLEARSTATUS, | |
| length: 0 | |
| )); |
| var cancellationTokenSource = new CancellationTokenSource(); | |
| //Fire a timeout after 1000 milliseconds | |
| cancellationTokenSource.CancelAfter(1000); | |
| var result = await device.WriteAndReadAsync(writeData, cancellationTokenSource.Token); | |
| public static Task<T> PerformControlTransferWithRetry<T>( | |
| this IUsbDevice usbDevice, | |
| Func<IUsbDevice, Task<T>> func, | |
| int retryCount = 3, | |
| int sleepDurationMilliseconds = 250) | |
| { | |
| var retryPolicy = Policy | |
| .Handle<ApiException>() | |
| .Or<ControlTransferException>() | |
| .WaitAndRetryAsync( |
| private static async Task DisplayTemperature() | |
| { | |
| //Connect to the device by product id and vendor id | |
| var temperDevice = await new FilterDeviceDefinition(vendorId: 0x413d, productId: 0x2107, usagePage: 65280) | |
| .CreateWindowsHidDeviceFactory(_loggerFactory) | |
| .ConnectFirstAsync() | |
| .ConfigureAwait(false); | |
| //Create the observable | |
| var observable = Observable |
| using Microsoft.AspNetCore.Mvc; | |
| namespace WebApplication1.Controllers | |
| { | |
| [ApiController] | |
| [Route("[controller]")] | |
| public class PersonController : ControllerBase | |
| { | |
| [HttpGet] | |
| public string Get(string firstName, string lastName) => $"{firstName} {lastName}"; |