Skip to content

Commit

Permalink
Centralize C# language version in shared .props
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Dec 29, 2022
1 parent 6c07620 commit ccbc5ef
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
21 changes: 21 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project>
<PropertyGroup>
<LangVersion>11.0</LangVersion>

<!--
Enable the latest warning wave, which shows additional warnings for invalid language features that are disabled by default.
For additional info, see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/warning-waves.
-->
<AnalysisLevel>7</AnalysisLevel>

<!-- Import the global configs from the CodeStyle package (enables all IDExxxx warnings)-->
<AnalysisLevelStyle>7-all</AnalysisLevelStyle>

<!--
Enable the compiler strict mode (see https://www.meziantou.net/csharp-compiler-strict-mode.htm).
This (poorly documented) mode enables additional warnings for incorrect usages of some features.
For instance, this will warn when using the == operator to compare a struct with a null literal.
-->
<Features>strict</Features>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion src/AmbientSounds.Uwp/AmbientSounds.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<LangVersion>11.0</LangVersion>
<UseDotNetNativeSharedAssemblyFrameworkPackage>false</UseDotNetNativeSharedAssemblyFrameworkPackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
Expand Down
8 changes: 5 additions & 3 deletions src/AmbientSounds.Uwp/Controls/ObservableUserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

#nullable enable

namespace AmbientSounds.Controls
{
// Source: https://gist.github.com/dpaulino/2e988a78fee6d99198d306681b234437

public abstract class ObservableUserControl : UserControl, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangedEventHandler? PropertyChanged;

protected void SetValueDp(DependencyProperty property, object value,
[System.Runtime.CompilerServices.CallerMemberName] string p = null)
[System.Runtime.CompilerServices.CallerMemberName] string? p = null)
{
SetValue(property, value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(p));
}

protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string p = null)
protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string? p = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(p));
}
Expand Down
1 change: 0 additions & 1 deletion src/AmbientSounds/AmbientSounds.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
4 changes: 4 additions & 0 deletions src/AmbientSounds/ViewModels/SoundViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ public bool PlusBadgeVisible
else
{
// backwards compatibility
#pragma warning disable CS0618
return _sound.IsPremium && _sound.IapId == IapConstants.MsStoreAmbiePlusId;
#pragma warning restore CS0618
}
}
}
Expand Down Expand Up @@ -303,7 +305,9 @@ private async Task PlayAsync()

var owned = _sound.IapIds.Count > 0
? await _iapService.IsAnyOwnedAsync(_sound.IapIds)
#pragma warning disable CS0618
: await _iapService.IsOwnedAsync(_sound.IapId); // backwards compatibility
#pragma warning restore CS0618

if (!owned)
{
Expand Down

0 comments on commit ccbc5ef

Please sign in to comment.