Skip to content

Commit

Permalink
Merge pull request #374 from nventive/main
Browse files Browse the repository at this point in the history
Merge Main into feature/uno5
  • Loading branch information
carlh98 authored Nov 3, 2023
2 parents 47bc3e5 + c37ccd0 commit f35eda8
Show file tree
Hide file tree
Showing 43 changed files with 277 additions and 457 deletions.
15 changes: 12 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ dotnet_diagnostic.SA1515.severity = none
# SA1202:Elements should be ordered by access
dotnet_diagnostic.SA1202.severity = suggestion
# SA1600:Elements should be documented
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1600.severity = warning
# SA1601:Elements should be documented
dotnet_diagnostic.SA1601.severity = suggestion
# SA1116:Split parameters should start on line after declaration
Expand Down Expand Up @@ -354,9 +354,9 @@ dotnet_diagnostic.SA1649.severity = suggestion
# SA1201: Elements should appear in the correct order (Fields vs Properties)
dotnet_diagnostic.SA1201.severity = suggestion
# SA1629: Documentation text should end with a period
dotnet_diagnostic.SA1629.severity = suggestion
dotnet_diagnostic.SA1629.severity = warning
# SA1514: Element documentation header should be preceded by blank line
dotnet_diagnostic.SA1514.severity = suggestion
dotnet_diagnostic.SA1514.severity = warning
# SA1134: Attributes should not share line
dotnet_diagnostic.SA1134.severity = none
# SA1413: Use trailing comma in multi-line initializers
Expand Down Expand Up @@ -391,3 +391,12 @@ dotnet_diagnostic.SA1210.severity = suggestion
dotnet_diagnostic.CA1308.severity = none
# CS1587: XML comment is not placed on a valid language element
dotnet_diagnostic.CS1587.severity = none

# VSTHRD110: This one is bugged: https://github.com/microsoft/vs-threading/issues/899
dotnet_diagnostic.VSTHRD110.severity = none
# VSTHRD200: Use `Async` naming convention
dotnet_diagnostic.VSTHRD200.severity = none
# VSTHRD100: Avoid async void methods
dotnet_diagnostic.VSTHRD100.severity = error
# VSTHRD101: Avoid unsupported async delegates
dotnet_diagnostic.VSTHRD101.severity = error
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
Prefix your items with `(Template)` if the change is about the template and not the resulting application.

## 2.1.X
- Install `GooseAnalyzers` to enable the `SA1600` rule with its scope limited to interfaces and improve xml documentation.
- Replace local `DispatcherQueue` extension methods with the ones from the WinUI and Uno.WinUI Community Toolkit.
- Add `Microsoft.VisualStudio.Threading.Analyzers` to check for async void usages and fix async void usages.
- Enable `TreatWarningsAsErrors` for the Access, Business, and Presentation projects.
- Update analyzers packages and severity of rules.
- Fix crash from ARM base mac on net7.0-iOS. Add `ForceSimulatorX64ArchitectureInIDE` property to mobile head.

## 2.0.X
- Renamed the classes providing data to use the `Repository` suffix instead of `Endpoint` or `Service`.
Expand Down
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<!-- Microsoft.VisualStudio.Threading.Analyzers has the async void analyzers. -->
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.5.22" PrivateAssets="all" />
<PackageReference Include="GooseAnalyzers" Version="0.2.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,41 @@

namespace ApplicationTemplate.DataAccess;

/// <summary>
/// Provides access to the authentication API.
/// </summary>
public interface IAuthenticationRepository
{
/// <summary>
/// Logs the user in using the provided <paramref name="email"/> and <paramref name="password"/>.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="email">Email</param>
/// <param name="password">Password</param>
/// <returns><see cref="AuthenticationData"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
/// <returns>The <see cref="AuthenticationData"/>.</returns>
Task<AuthenticationData> Login(CancellationToken ct, string email, string password);

/// <summary>
/// Refreshes the user token.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="unauthorizedToken">Unauthorized token</param>
/// <returns><see cref="AuthenticationData"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="unauthorizedToken">The unauthorized token.</param>
/// <returns>The <see cref="AuthenticationData"/>.</returns>
Task<AuthenticationData> RefreshToken(CancellationToken ct, AuthenticationData unauthorizedToken);

/// <summary>
/// Creates a user account.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="email">Email</param>
/// <param name="password">Password</param>
/// <returns><see cref="AuthenticationData"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
/// <returns>The <see cref="AuthenticationData"/>.</returns>
Task<AuthenticationData> CreateAccount(CancellationToken ct, string email, string password);

/// <summary>
/// Resets the password.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="email">Email</param>
/// <returns><see cref="Task"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="email">The email.</param>
Task ResetPassword(CancellationToken ct, string email);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@

namespace ApplicationTemplate.DataAccess;

/// <summary>
/// Provides access to the dad jokes API.
/// </summary>
public interface IDadJokesRepository
{
/// <summary>
/// Returns a list of dad jokes based on /r/dadjokes.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="typePost"><see cref="string"/></param>
/// <returns>List of quotes</returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="typePost">The type of post.</param>
/// <returns>A list of jokes.</returns>
[Get("/{typePost}.json")]
Task<DadJokesResponse> FetchData(CancellationToken ct, string typePost);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,53 @@

namespace ApplicationTemplate.DataAccess;

/// <summary>
/// Provides access to the posts API.
/// </summary>
[Headers("Authorization: Bearer")]
public interface IPostsRepository
{
/// <summary>
/// Gets the list of all posts.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <returns>List of posts</returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <returns>A list of posts.</returns>
[Get("/posts")]
Task<PostData[]> GetAll(CancellationToken ct);

/// <summary>
/// Gets the post of the specified id.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="postId">Post id</param>
/// <returns>Post</returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="postId">The post identifier.</param>
/// <returns>The post.</returns>
[Get("/posts/{id}")]
Task<PostData> Get(CancellationToken ct, [AliasAs("id")] long postId);

/// <summary>
/// Creates a post.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="post">Post</param>
/// <returns>New <see cref="PostData"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="post">The post data.</param>
/// <returns>A new <see cref="PostData"/>.</returns>
[Post("/posts")]
Task<PostData> Create(CancellationToken ct, [Body] PostData post);

/// <summary>
/// Updates a post.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="postId">Post id</param>
/// <param name="post">Post</param>
/// <returns>Updated <see cref="PostData"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="postId">The post identifier.</param>
/// <param name="post">The updated post data.</param>
/// <returns>The updated <see cref="PostData"/>.</returns>
[Put("/posts/{id}")]
Task<PostData> Update(CancellationToken ct, [AliasAs("id")] long postId, [Body] PostData post);

/// <summary>
/// Delets a post.
/// Deletes a post.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="postId">Post id</param>
/// <returns><see cref="Task"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="postId">The post identifier.</param>
[Delete("/posts/{id}")]
Task Delete(CancellationToken ct, [AliasAs("id")] long postId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@

namespace ApplicationTemplate.DataAccess;

/// <summary>
/// Provides access to the user profile API.
/// </summary>
[Headers("Authorization: Bearer")]
public interface IUserProfileRepository
{
/// <summary>
/// Returns the current user profile.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <returns><see cref="UserProfileData"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <returns>The <see cref="UserProfileData"/>.</returns>
[Get("/me")]
Task<UserProfileData> Get(CancellationToken ct);

/// <summary>
/// Updates the current user profile.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="userProfile">User profile</param>
/// <returns><see cref="UserProfileData"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="userProfile">The user profile.</param>
[Put("/me")]
Task Update(CancellationToken ct, UserProfileData userProfile);
}
16 changes: 8 additions & 8 deletions src/app/ApplicationTemplate.Access/Framework/BaseMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public BaseMock(JsonSerializerOptions serializerOptions)
/// <summary>
/// Gets the deserialized value of the specified embedded resource.
/// </summary>
/// <typeparam name="T">Type of value</typeparam>
/// <param name="resourceName">Name of the resource</param>
/// <param name="callerMemberName">Caller member name</param>
/// <returns>Deserialized value</returns>
/// <typeparam name="T">The type of value.</typeparam>
/// <param name="resourceName">The name of the resource.</param>
/// <param name="callerMemberName">The caller member name.</param>
/// <returns>The deserialized value.</returns>
/// <remarks>
/// If left empty, the <paramref name="resourceName" /> will implicitly be treated as "{callerTypeName}.{callerMemberName}.json".
/// Note that this will deserialize the first embedded resource whose name ends with the specified <paramref name="resourceName" />.
Expand Down Expand Up @@ -63,10 +63,10 @@ protected T GetFromEmbeddedResource<T>(
/// If left empty, the <paramref name="resourceName" /> will implicitly be treated as "{callerTypeName}.{callerMemberName}.json".
/// Note that this will deserialize the first embedded resource whose name ends with the specified <paramref name="resourceName" />.
/// </remarks>
/// <typeparam name="T">Type of object</typeparam>
/// <param name="resourceName">Name of the resource</param>
/// <param name="callerMemberName">Name of the caller (used if no resource name provided)</param>
/// <returns>Deserialized object</returns>
/// <typeparam name="T">The type of object.</typeparam>
/// <param name="resourceName">The name of the resource.</param>
/// <param name="callerMemberName">The name of the caller (used if no resource name provided).</param>
/// <returns>The deserialized object.</returns>
protected Task<T> GetTaskFromEmbeddedResource<T>(
string resourceName = null,
[CallerMemberName] string callerMemberName = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ApplicationTemplate;
/// <summary>
/// Specialized type to hold RFC 7519 JSON Web Token (JWT) information.
/// </summary>
/// <typeparam name="TPayload">The type of the Payload to deserialize</typeparam>
/// <typeparam name="TPayload">The type of the Payload to deserialize.</typeparam>
public class JwtData<TPayload>
where TPayload : class
{
Expand Down Expand Up @@ -37,34 +37,34 @@ public JwtData(string token, JsonSerializerOptions jsonSerializerOptions = null)
}

/// <summary>
/// Represents the raw token as received as constructor parameter
/// Gets the raw token as received as constructor parameter.
/// </summary>
public string Token { get; }

/// <summary>
/// Represents the decoded (but non-deserialized) header part of the JWT - in JSON text
/// Gets the decoded (but non-deserialized) header part of the JWT - in JSON text.
/// </summary>
public string RawHeader { get; }

/// <summary>
/// Represents the decoded (but non-deserialized) payload part of the JWT - in JSON text
/// Gets the decoded (but non-deserialized) payload part of the JWT - in JSON text.
/// </summary>
public string RawPayload { get; }

/// <summary>
/// Deserialized header
/// Gets the deserialized header.
/// </summary>
public IDictionary<string, string> Header
=> _header ?? (_header = JsonSerializer.Deserialize(RawHeader, typeof(IDictionary<string, string>), _jsonSerializerOptions) as IDictionary<string, string>);

/// <summary>
/// Deserialized payload
/// Gets the deserialized payload.
/// </summary>
public TPayload Payload
=> _payload ?? (_payload = JsonSerializer.Deserialize(RawPayload, typeof(TPayload), _jsonSerializerOptions) as TPayload);

/// <summary>
/// Decoded signature of the JWT
/// Gets the decoded signature of the JWT.
/// </summary>
public byte[] Signature { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,47 @@

namespace ApplicationTemplate.DataAccess;

/// <summary>
/// Provides access to the local storage.
/// </summary>
public interface IApplicationSettingsRepository
{
/// <summary>
/// Gets and observes the current <see cref="ApplicationSettings"/>.
/// </summary>
/// <returns>Current <see cref="ApplicationSettings"/></returns>
/// <returns>An observable sequence yielding the current <see cref="ApplicationSettings"/>.</returns>
IObservable<ApplicationSettings> GetAndObserveCurrent();

/// <summary>
/// Gets the current <see cref="ApplicationSettings"/>.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <returns>Current <see cref="ApplicationSettings"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <returns>The current <see cref="ApplicationSettings"/>.</returns>
Task<ApplicationSettings> GetCurrent(CancellationToken ct);

/// <summary>
/// Discards any settings that are related to the user.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <returns><see cref="Task"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
Task DiscardUserSettings(CancellationToken ct);

/// <summary>
/// Flags that the onboarding has been completed.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <returns><see cref="Task"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
Task CompleteOnboarding(CancellationToken ct);

/// <summary>
/// Sets the current <see cref="AuthenticationData"/>.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="authenticationData"><see cref="AuthenticationData"/></param>
/// <returns><see cref="Task"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="authenticationData">The <see cref="AuthenticationData"/>.</param>
Task SetAuthenticationData(CancellationToken ct, AuthenticationData authenticationData);

/// <summary>
/// Sets the favorite quotes.
/// </summary>
/// <param name="ct"><see cref="CancellationToken"/></param>
/// <param name="quotes">Favorite quotes</param>
/// <returns><see cref="Task"/></returns>
/// <param name="ct">The <see cref="CancellationToken"/>.</param>
/// <param name="quotes">The favorite quotes.</param>
Task SetFavoriteQuotes(CancellationToken ct, ImmutableDictionary<string, FavoriteJokeData> quotes);
}
Loading

0 comments on commit f35eda8

Please sign in to comment.