Skip to content

Commit 4d140d8

Browse files
Merge branch 'master' into feature/nint-guard-apis
2 parents 1069076 + 5553f45 commit 4d140d8

File tree

393 files changed

+12461
-6325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+12461
-6325
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,7 @@ dotnet_diagnostic.SA1652.severity = none
324324

325325
dotnet_diagnostic.SA1629.severity = none # DocumentationTextMustEndWithAPeriod: Let's enable this rule back when we shift to WinUI3 (v8.x). If we do it now, it would mean more than 400 file changes.
326326
dotnet_diagnostic.SA1413.severity = none # UseTrailingCommasInMultiLineInitializers: This would also mean a lot of changes at the end of all multiline initializers. It's also debatable if we want this or not.
327-
dotnet_diagnostic.SA1314.severity = none # TypeParameterNamesMustBeginWithT: We do have a few templates that don't start with T. We need to double check that changing this is not a breaking change. If not, we can re-enable this.
327+
dotnet_diagnostic.SA1314.severity = none # TypeParameterNamesMustBeginWithT: We do have a few templates that don't start with T. We need to double check that changing this is not a breaking change. If not, we can re-enable this.
328+
dotnet_diagnostic.SA1000.severity = none # Hide warnings when using the new() expression from C# 9.
329+
dotnet_diagnostic.SA1313.severity = none # Hide warnings for record parameters.
330+
dotnet_diagnostic.SA1101.severity = none # Hide warnings when accessing properties without "this".

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ assignees: ''
1111

1212
## Describe the problem this feature would solve
1313
<!-- Please describe or link to any existing issues or discussions.
14-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
14+
A clear and concise description of what the problem is, starting with the user story.
15+
Provide examples of the restrictions in the current environment that hinders the work your users or you want to perform. What are the ways this new feature will help transform and deliver those results?
16+
For example, I am currently using the InfiniteCanvas control which lacks the ribbon control feature. I am looking to improve user experience therefore i would like to use that in my project to provide ease of accessibility and a user-friendly interface. This new feature will provide quick access to the toolbar, enhance space utilization, etc [...] -->
17+
1518

1619
## Describe the solution
17-
<!-- A clear and concise description of what you want to happen. -->
20+
<!-- A clear and concise description of what you want to happen. Define how do you think it will help the community and adds value to the toolkit? -->
21+
1822

1923
## Describe alternatives you've considered
2024
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
2125

26+
2227
## Additional context & Screenshots
2328
<!-- Add any other context or screenshots about the feature request here.-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Please check if your PR fulfills the following requirements:
3838
- [ ] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->
3939
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
4040
- [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)
41+
- [ ] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/windows-toolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
4142
- [ ] Tests for the changes have been added (for bug fixes / features) (if applicable)
4243
- [ ] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
4344
- [ ] Contains **NO** breaking changes

Directory.Build.targets

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<Project>
22

33
<PropertyGroup>
4-
<UseUWP Condition="'$(TargetFramework)' == 'uap10.0' or '$(TargetFramework)' == 'uap10.0.17763' or '$(TargetFramework)' == 'native' or '$(TargetFramework)' == 'net461'">true</UseUWP>
4+
<UseUWP Condition="$(TargetFramework.Contains(`uap10.0`)) or '$(TargetFramework)' == 'net461'">true</UseUWP>
55
</PropertyGroup>
66

77
<Choose>
8-
<When Condition="!$(TargetFramework.Contains(`uap10.0`)) and '$(TargetFramework)' != 'native' and '$(IsSampleProject)' != 'true'">
8+
<!--We'll include signing the Notifications library since we need the DLL signature to match for interop from class libraries to main projects-->
9+
<When Condition="(!$(TargetFramework.Contains(`uap10.0`)) and '$(TargetFramework)' != 'native' and '$(IsSampleProject)' != 'true') or $(MSBuildProjectName) == 'Microsoft.Toolkit.Uwp.Notifications'">
910
<PropertyGroup>
1011
<SignAssembly>true</SignAssembly>
1112
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)toolkit.snk</AssemblyOriginatorKeyFile>
1213
</PropertyGroup>
1314
</When>
1415
</Choose>
15-
16-
<Import Project="$(MSBuildThisFileDirectory)build\Windows.Toolkit.Uwp.Build.targets" Condition="'$(UseUWP)' == 'true'"/>
16+
17+
<!--Exclude Notifications project from this since it sets different min versions than what we want for notifications-->
18+
<Import Project="$(MSBuildThisFileDirectory)build\Windows.Toolkit.Uwp.Build.targets" Condition="'$(UseUWP)' == 'true' and $(MSBuildProjectName) != 'Microsoft.Toolkit.Uwp.Notifications'"/>
1719

1820
<Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
1921
<ItemGroup>

Microsoft.Toolkit.HighPerformance/Helpers/ParallelHelper.ForEach.IInAction.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,14 @@ public void Invoke(int i)
143143
end = Math.Min(high, this.memory.Length);
144144

145145
ref TItem r0 = ref MemoryMarshal.GetReference(this.memory.Span);
146+
ref TItem rStart = ref Unsafe.Add(ref r0, low);
147+
ref TItem rEnd = ref Unsafe.Add(ref r0, end);
146148

147-
for (int j = low; j < end; j++)
149+
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
148150
{
149-
ref TItem rj = ref Unsafe.Add(ref r0, (nint)(uint)j);
151+
Unsafe.AsRef(this.action).Invoke(in rStart);
150152

151-
Unsafe.AsRef(this.action).Invoke(rj);
153+
rStart = ref Unsafe.Add(ref rStart, 1);
152154
}
153155
}
154156
}

Microsoft.Toolkit.HighPerformance/Helpers/ParallelHelper.ForEach.IInAction2D.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,14 @@ public void Invoke(int i)
145145

146146
for (int y = lowY; y < stopY; y++)
147147
{
148-
ref TItem r0 = ref span.DangerousGetReferenceAt(y, 0);
148+
ref TItem rStart = ref span.DangerousGetReferenceAt(y, 0);
149+
ref TItem rEnd = ref Unsafe.Add(ref rStart, width);
149150

150-
for (int x = 0; x < width; x++)
151+
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
151152
{
152-
ref TItem ryx = ref Unsafe.Add(ref r0, (nint)(uint)x);
153+
Unsafe.AsRef(this.action).Invoke(in rStart);
153154

154-
Unsafe.AsRef(this.action).Invoke(ryx);
155+
rStart = ref Unsafe.Add(ref rStart, 1);
155156
}
156157
}
157158
}

Microsoft.Toolkit.HighPerformance/Helpers/ParallelHelper.ForEach.IRefAction.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,14 @@ public void Invoke(int i)
143143
end = Math.Min(high, this.memory.Length);
144144

145145
ref TItem r0 = ref MemoryMarshal.GetReference(this.memory.Span);
146+
ref TItem rStart = ref Unsafe.Add(ref r0, low);
147+
ref TItem rEnd = ref Unsafe.Add(ref r0, end);
146148

147-
for (int j = low; j < end; j++)
149+
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
148150
{
149-
ref TItem rj = ref Unsafe.Add(ref r0, (nint)(uint)j);
151+
Unsafe.AsRef(this.action).Invoke(ref rStart);
150152

151-
Unsafe.AsRef(this.action).Invoke(ref rj);
153+
rStart = ref Unsafe.Add(ref rStart, 1);
152154
}
153155
}
154156
}

Microsoft.Toolkit.HighPerformance/Helpers/ParallelHelper.ForEach.IRefAction2D.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,14 @@ public void Invoke(int i)
152152

153153
for (int y = lowY; y < stopY; y++)
154154
{
155-
ref TItem r0 = ref span.DangerousGetReferenceAt(y, 0);
155+
ref TItem rStart = ref span.DangerousGetReferenceAt(y, 0);
156+
ref TItem rEnd = ref Unsafe.Add(ref rStart, width);
156157

157-
for (int x = 0; x < width; x++)
158+
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
158159
{
159-
ref TItem ryx = ref Unsafe.Add(ref r0, (nint)(uint)x);
160+
Unsafe.AsRef(this.action).Invoke(ref rStart);
160161

161-
Unsafe.AsRef(this.action).Invoke(ref ryx);
162+
rStart = ref Unsafe.Add(ref rStart, 1);
162163
}
163164
}
164165
}

Microsoft.Toolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,18 @@ public void CopyTo(Span<T> destination)
628628
nint width = (nint)(uint)this.width;
629629

630630
ref T destinationRef = ref MemoryMarshal.GetReference(destination);
631-
nint offset = 0;
632631

633632
for (int i = 0; i < height; i++)
634633
{
635-
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
634+
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
635+
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
636636

637-
for (nint j = 0; j < width; j += 1, offset += 1)
637+
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
638638
{
639-
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
639+
destinationRef = sourceStart;
640+
641+
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
642+
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
640643
}
641644
}
642645
#endif
@@ -682,12 +685,16 @@ public void CopyTo(Span2D<T> destination)
682685

683686
for (int i = 0; i < height; i++)
684687
{
685-
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
688+
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
689+
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
686690
ref T destinationRef = ref destination.DangerousGetReferenceAt(i, 0);
687691

688-
for (nint j = 0; j < width; j += 1)
692+
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
689693
{
690-
Unsafe.Add(ref destinationRef, j) = Unsafe.Add(ref sourceRef, j);
694+
destinationRef = sourceStart;
695+
696+
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
697+
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
691698
}
692699
}
693700
#endif
@@ -928,15 +935,18 @@ public bool TryGetSpan(out ReadOnlySpan<T> span)
928935
nint width = (nint)(uint)this.width;
929936

930937
ref T destinationRef = ref array.DangerousGetReference();
931-
nint offset = 0;
932938

933939
for (int i = 0; i < height; i++)
934940
{
935-
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
941+
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
942+
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
936943

937-
for (nint j = 0; j < width; j += 1, offset += 1)
944+
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
938945
{
939-
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
946+
destinationRef = sourceStart;
947+
948+
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
949+
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
940950
}
941951
}
942952
}

Microsoft.Toolkit.HighPerformance/Memory/Span2D{T}.cs

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,14 @@ public void Clear()
691691

692692
for (int i = 0; i < height; i++)
693693
{
694-
ref T r0 = ref DangerousGetReferenceAt(i, 0);
694+
ref T rStart = ref DangerousGetReferenceAt(i, 0);
695+
ref T rEnd = ref Unsafe.Add(ref rStart, width);
695696

696-
for (nint j = 0; j < width; j += 1)
697+
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
697698
{
698-
Unsafe.Add(ref r0, j) = default!;
699+
rStart = default!;
700+
701+
rStart = ref Unsafe.Add(ref rStart, 1);
699702
}
700703
}
701704
#endif
@@ -738,15 +741,18 @@ public void CopyTo(Span<T> destination)
738741
nint width = (nint)(uint)this.width;
739742

740743
ref T destinationRef = ref MemoryMarshal.GetReference(destination);
741-
nint offset = 0;
742744

743745
for (int i = 0; i < height; i++)
744746
{
745-
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
747+
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
748+
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
746749

747-
for (nint j = 0; j < width; j += 1, offset += 1)
750+
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
748751
{
749-
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
752+
destinationRef = sourceStart;
753+
754+
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
755+
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
750756
}
751757
}
752758
#endif
@@ -792,12 +798,16 @@ public void CopyTo(Span2D<T> destination)
792798

793799
for (int i = 0; i < height; i++)
794800
{
795-
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
801+
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
802+
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
796803
ref T destinationRef = ref destination.DangerousGetReferenceAt(i, 0);
797804

798-
for (nint j = 0; j < width; j += 1)
805+
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
799806
{
800-
Unsafe.Add(ref destinationRef, j) = Unsafe.Add(ref sourceRef, j);
807+
destinationRef = sourceStart;
808+
809+
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
810+
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
801811
}
802812
}
803813
#endif
@@ -868,11 +878,14 @@ public void Fill(T value)
868878

869879
for (int i = 0; i < height; i++)
870880
{
871-
ref T r0 = ref DangerousGetReferenceAt(i, 0);
881+
ref T rStart = ref DangerousGetReferenceAt(i, 0);
882+
ref T rEnd = ref Unsafe.Add(ref rStart, width);
872883

873-
for (nint j = 0; j < width; j += 1)
884+
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
874885
{
875-
Unsafe.Add(ref r0, j) = value;
886+
rStart = value;
887+
888+
rStart = ref Unsafe.Add(ref rStart, 1);
876889
}
877890
}
878891
#endif
@@ -1078,15 +1091,18 @@ public bool TryGetSpan(out Span<T> span)
10781091
nint width = (nint)(uint)this.width;
10791092

10801093
ref T destinationRef = ref array.DangerousGetReference();
1081-
nint offset = 0;
10821094

10831095
for (int i = 0; i < height; i++)
10841096
{
1085-
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
1097+
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
1098+
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
10861099

1087-
for (nint j = 0; j < width; j += 1, offset += 1)
1100+
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
10881101
{
1089-
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
1102+
destinationRef = sourceStart;
1103+
1104+
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
1105+
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
10901106
}
10911107
}
10921108
}

0 commit comments

Comments
 (0)