Skip to content

Commit a452af2

Browse files
authored
Explicitly separate 3rd party IP from Microsoft IP (#4899)
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1139604 > Keeping Third-Party IP in a source control system separate from > Microsoft source code and other assets is the preferred engineering > practice… Begin following this preferred engineering practice: move source code which was copied into this repo into a separate `src-ThirdParty` directory, so that it is easier to track and manage them. Move the NUnitLite sources into `src-ThirdParty\NUnitLite`. Move the force-net/crc32.net sources into `src-ThirdParty\crc32.net`. Move the bazelbuild/bazel sources into `src-ThirdParty\bazel`. Move the *C# ported* android/platform/tools/base sources into `src-ThirdParty\android-platform-tools-base`.
1 parent 5d1ac0a commit a452af2

File tree

281 files changed

+468
-422
lines changed

Some content is hidden

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

281 files changed

+468
-422
lines changed

build-tools/xaprepare/xaprepare/Steps/Step_Get_Windows_Binutils.cs

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Text;
88
using System.Threading.Tasks;
99

10+
using Force.Crc32;
11+
1012
namespace Xamarin.Android.Prepare
1113
{
1214
class Step_Get_Windows_Binutils : Step
@@ -679,72 +681,4 @@ uint ReadUInt (BinaryReader br, long dataLength, ref long nread, out bool succes
679681
return (true, resp.Content.Headers.ContentLength.Value);
680682
}
681683
}
682-
683-
//
684-
// Taken from:
685-
// https://github.com/force-net/Crc32.NET/blob/fbc1061b0cb53df2322d5aed33167a2e6335970b/Crc32.NET/SafeProxy.cs
686-
//
687-
// License: MIT
688-
// https://github.com/force-net/Crc32.NET/blob/fbc1061b0cb53df2322d5aed33167a2e6335970b/LICENSE
689-
//
690-
class CRC32
691-
{
692-
const uint Poly = 0xedb88320u;
693-
694-
readonly uint[] _table = new uint[16 * 256];
695-
696-
internal CRC32 ()
697-
{
698-
Init (Poly);
699-
}
700-
701-
protected void Init (uint poly)
702-
{
703-
var table = _table;
704-
for (uint i = 0; i < 256; i++) {
705-
uint res = i;
706-
for (int t = 0; t < 16; t++) {
707-
for (int k = 0; k < 8; k++) res = (res & 1) == 1 ? poly ^ (res >> 1) : (res >> 1);
708-
table[(t * 256) + i] = res;
709-
}
710-
}
711-
}
712-
713-
public uint Append (uint crc, byte[] input, int offset, int length)
714-
{
715-
uint crcLocal = uint.MaxValue ^ crc;
716-
717-
uint[] table = _table;
718-
while (length >= 16) {
719-
var a = table[(3 * 256) + input[offset + 12]]
720-
^ table[(2 * 256) + input[offset + 13]]
721-
^ table[(1 * 256) + input[offset + 14]]
722-
^ table[(0 * 256) + input[offset + 15]];
723-
724-
var b = table[(7 * 256) + input[offset + 8]]
725-
^ table[(6 * 256) + input[offset + 9]]
726-
^ table[(5 * 256) + input[offset + 10]]
727-
^ table[(4 * 256) + input[offset + 11]];
728-
729-
var c = table[(11 * 256) + input[offset + 4]]
730-
^ table[(10 * 256) + input[offset + 5]]
731-
^ table[(9 * 256) + input[offset + 6]]
732-
^ table[(8 * 256) + input[offset + 7]];
733-
734-
var d = table[(15 * 256) + ((byte)crcLocal ^ input[offset])]
735-
^ table[(14 * 256) + ((byte)(crcLocal >> 8) ^ input[offset + 1])]
736-
^ table[(13 * 256) + ((byte)(crcLocal >> 16) ^ input[offset + 2])]
737-
^ table[(12 * 256) + ((crcLocal >> 24) ^ input[offset + 3])];
738-
739-
crcLocal = d ^ c ^ b ^ a;
740-
offset += 16;
741-
length -= 16;
742-
}
743-
744-
while (--length >= 0)
745-
crcLocal = table[(byte)(crcLocal ^ input[offset++])] ^ crcLocal >> 8;
746-
747-
return crcLocal ^ uint.MaxValue;
748-
}
749-
}
750684
}

build-tools/xaprepare/xaprepare/xaprepare.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@
272272
<Compile Include="Steps\Step_PrepareExternal.Windows.cs" />
273273
<Compile Include="Steps\Step_PrepareExternalJavaInterop.Windows.cs" />
274274
</ItemGroup>
275+
<ItemGroup>
276+
<Compile Include="..\..\..\src-ThirdParty\crc32.net\SafeProxy.cs" />
277+
</ItemGroup>
275278
<ItemGroup>
276279
<None Include="App.config" />
277280
<None Include="app.manifest">

0 commit comments

Comments
 (0)