Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] Parser: Adds Antlr Dependancy #1691

Merged
merged 15 commits into from Sep 23, 2020
5 changes: 4 additions & 1 deletion Microsoft.Azure.Cosmos/src/Microsoft.Azure.Cosmos.csproj
Expand Up @@ -50,6 +50,10 @@
<Compile Remove="RuntimePerfCounters.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\ThirdPartyNotice.txt" Link="ThirdPartyNotice.txt" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Batch\HybridRowBatchSchemas.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
Expand Down Expand Up @@ -85,7 +89,6 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Antlr4.Runtime.Standard" Version="4.8.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.0.102" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
Expand Down
5 changes: 5 additions & 0 deletions Microsoft.Azure.Cosmos/src/OSS/AddStyleCopIgnoreToFile.ps1
@@ -0,0 +1,5 @@
$a = Get-Content $args[0]
$b = "// This file isn't generated, but this comment is necessary to exclude it from StyleCop analysis."
$c = "// <auto-generated/>"
$d = ""
Set-Content $args[0] -value $b, $c, $d, $a
97 changes: 97 additions & 0 deletions Microsoft.Azure.Cosmos/src/OSS/Antlr/AntlrFileStream.cs
@@ -0,0 +1,97 @@
// This file isn't generated, but this comment is necessary to exclude it from StyleCop analysis.
// <auto-generated/>

/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirankumarkolli is there clarification on requirements for the license?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He literally said in the last meeting that he would work with the legal team about the licensing and that there is no need to block on it. I feel like we attend different meetings at this point. From now on I am requesting that all meetings are recorded for transparency.

Copy link
Contributor

@j82w j82w Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this merged before legal is done then master is in a broken state and we can't do a release. Having master in a state where it can't be shipped is unacceptable, and worse is if someone does do a release it becomes a legal issue. The meeting recording is here. I might have missed it but the only agreement I found and remember was @kirankumarkolli agreeing to follow up with legal. I did not find anything saying this would be allowed to be merged without legal being done first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me clarify here.

  1. Work progress (working, PR, reviews etc...) don't need to get blocked on legal clearance (very high probability of clearance).
  2. PR merge do need clearance, so its a blocker.
  3. I am supposed to start the legal process last week and slipped it. Will do submit today.

* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/

#if !PORTABLE

using Antlr4.Runtime.Sharpen;
using Encoding = System.Text.Encoding;
using File = System.IO.File;

namespace Antlr4.Runtime
{
#if COMPACT
using StreamReader = System.IO.StreamReader;
#endif

/// <summary>
/// This is an
/// <see cref="AntlrInputStream"/>
/// that is loaded from a file all at once
/// when you construct the object.
/// </summary>
internal class AntlrFileStream : AntlrInputStream
{
protected internal string fileName;

/// <exception cref="System.IO.IOException"/>
public AntlrFileStream(string fileName)
: this(fileName, null)
{
}

/// <exception cref="System.IO.IOException"/>
public AntlrFileStream(string fileName, Encoding encoding)
{
this.fileName = fileName;
Load(fileName, encoding);
}

/// <exception cref="System.IO.IOException"/>
public virtual void Load(string fileName, Encoding encoding)
{
if (fileName == null)
{
return;
}

string text;
#if !COMPACT
if (encoding != null)
text = File.ReadAllText(fileName, encoding);
else
text = File.ReadAllText(fileName);
#else
if (encoding != null)
text = ReadAllText(fileName, encoding);
else
text = ReadAllText(fileName);
#endif

data = text.ToCharArray();
n = data.Length;
}

public override string SourceName
{
get
{
return fileName;
}
}

#if COMPACT
private static string ReadAllText(string path)
{
using (var reader = new StreamReader(path))
{
return reader.ReadToEnd();
}
}

private static string ReadAllText(string path, Encoding encoding)
{
using (var reader = new StreamReader(path, encoding ?? Encoding.Default))
{
return reader.ReadToEnd();
}
}
#endif
}
}

#endif