Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libraries/System.Speech/pkg/System.Speech.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<ItemGroup>
<ProjectReference Include="..\ref\System.Speech.csproj">
<SupportedFramework>netcoreapp3.0;net45;$(AllXamarinFrameworks)</SupportedFramework>
<SupportedFramework>netcoreapp2.0;net45;uap10.0.16299;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.Speech.csproj" />
<InboxOnTargetFramework Include="net45">
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Speech/ref/System.Speech.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Speech.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ private void Dispose(bool disposing)
});
((IDisposable)_process).Dispose();
((IDisposable)_done).Dispose();
_mta.Abort();
Copy link
Author

Choose a reason for hiding this comment

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

Here's another PNSE to avoid. I just removed this call and added a catch for the ObjectDisposedException that'll happen to let the thread die gracefully.

Copy link
Owner

Choose a reason for hiding this comment

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

Ugh, how could I have found these - did I not run the right analyzer?

}
base.Dispose();
}
Expand Down Expand Up @@ -177,7 +176,14 @@ private void SapiMTAThread()
{
Exception ex = _exception = exception;
}
_done.Set();
try
{
_done.Set();
}
catch (ObjectDisposedException)
{
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ internal void CloneTags(Arc arc, List<Tag> _tags, Dictionary<Tag, Tag> endArcs,
if (be != null)
{
tag._cfgTag._nameOffset = be.Symbols.Add(startTag._be.Symbols.FromOffset(startTag._cfgTag._nameOffset), out int idWord);
#pragma warning disable 0618
if (startTag._cfgTag._valueOffset != 0 && startTag._cfgTag.PropVariantType == VarEnum.VT_EMPTY)
#pragma warning restore 0618
{
tag._cfgTag._valueOffset = be.Symbols.Add(startTag._be.Symbols.FromOffset(startTag._cfgTag._valueOffset), out idWord);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ internal class CfgProperty

internal uint _ulId;

#pragma warning disable 0618
internal VarEnum _comType;
#pragma warning restore 0618

internal object _comValue;
}
Expand Down Expand Up @@ -369,7 +371,9 @@ private static void CheckValidCfgFormat(CfgSerializedHeader pFH, CfgHeader heade
int startArcIndex = (int)header.tags[i].StartArcIndex;
int endArcIndex = (int)header.tags[i].EndArcIndex;
int num = header.arcs.Length;
#pragma warning disable 0618
if (startArcIndex == 0 || startArcIndex >= num || endArcIndex == 0 || endArcIndex >= num || (header.tags[i].PropVariantType != 0 && header.tags[i].PropVariantType == VarEnum.VT_BSTR && header.tags[i].PropVariantType == VarEnum.VT_BOOL && header.tags[i].PropVariantType == VarEnum.VT_R8 && header.tags[i].PropVariantType == VarEnum.VT_I4))
#pragma warning restore 0618
{
XmlParser.ThrowSrgsException(SRID.UnsupportedFormat);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ internal uint EndArcIndex
}
}

#pragma warning disable 0618
internal VarEnum PropVariantType
{
get
Expand All @@ -83,6 +84,7 @@ internal VarEnum PropVariantType
_flag3 |= (uint)value;
}
}
#pragma warning restore 0618

internal uint ArcIndex
{
Expand Down Expand Up @@ -117,6 +119,7 @@ internal CfgSemanticTag(StringBlob symbols, CfgGrammar.CfgProperty property)
{
_nameOffset = 0;
}
#pragma warning disable 0618
switch (property._comType)
{
case VarEnum.VT_EMPTY:
Expand All @@ -140,6 +143,7 @@ internal CfgSemanticTag(StringBlob symbols, CfgGrammar.CfgProperty property)
_varDouble = (double)property._comValue;
break;
}
#pragma warning restore 0618
PropVariantType = property._comType;
ArcIndex = 0u;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,37 +514,24 @@ private static CompilerParameters GetCompilerParameters(string outputFile, List<
private void CheckValidAssembly(int iCfg, byte[] il)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
AppDomain appDomain = null;
try
AppDomainCompilerProxy appDomainCompilerProxy = new AppDomainCompilerProxy();
int count = _scriptRefs.Count;
string[] array = new string[count];
string[] array2 = new string[count];
int[] array3 = new int[count];
for (int i = 0; i < count; i++)
{
appDomain = AppDomain.CreateDomain("Loading Domain");
AppDomainCompilerProxy appDomainCompilerProxy = (AppDomainCompilerProxy)appDomain.CreateInstanceFromAndUnwrap(executingAssembly.GetName().CodeBase, "System.Speech.Internal.SrgsCompiler.AppDomainCompilerProxy");
int count = _scriptRefs.Count;
string[] array = new string[count];
string[] array2 = new string[count];
int[] array3 = new int[count];
for (int i = 0; i < count; i++)
{
ScriptRef scriptRef = _scriptRefs[i];
array[i] = scriptRef._rule;
array2[i] = scriptRef._sMethod;
array3[i] = (int)scriptRef._method;
}
Exception ex = appDomainCompilerProxy.CheckAssembly(il, iCfg, _language, _namespace, array, array2, array3);
if (ex != null)
{
throw ex;
}
AssociateConstructorsWithRules(appDomainCompilerProxy, array, _rules, iCfg, _language);
ScriptRef scriptRef = _scriptRefs[i];
array[i] = scriptRef._rule;
array2[i] = scriptRef._sMethod;
array3[i] = (int)scriptRef._method;
}
finally
Exception ex = appDomainCompilerProxy.CheckAssembly(il, iCfg, _language, _namespace, array, array2, array3);
if (ex != null)
{
if (appDomain != null)
{
AppDomain.Unload(appDomain);
appDomain = null;
}
throw ex;
}
AssociateConstructorsWithRules(appDomainCompilerProxy, array, _rules, iCfg, _language);
}

private static void AssociateConstructorsWithRules(AppDomainCompilerProxy proxy, string[] names, List<Rule> rules, int iCfg, string language)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void IPropertyTag.NameValue(IElement parent, string name, object value)
_propInfo._pszName = "=";
}
_propInfo._comValue = value;
#pragma warning disable 0618
if (value == null)
{
_propInfo._comType = VarEnum.VT_EMPTY;
Expand All @@ -49,6 +50,7 @@ void IPropertyTag.NameValue(IElement parent, string name, object value)
{
_propInfo._comType = VarEnum.VT_BOOL;
}
#pragma warning restore 0618
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ internal RuleRef(ParseElementCollection parent, Backend backend, Uri uri, List<R
{
_pszName = "SemanticKey",
_comValue = semanticKey,
#pragma warning disable 0618
_comType = VarEnum.VT_EMPTY
#pragma warning restore 0618
});
}
parent.AddArc(arc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void ParseToken(ParseElementCollection parent, string sToken, string pro
string text2 = (display == null) ? text : EscapeToken(display);
if (pronunciation != null)
{
OneOf oneOf = (pronunciation.Contains(';')) ? new OneOf(parent._rule, _backend) : null;
OneOf oneOf = (pronunciation.IndexOf(';') >= 0) ? new OneOf(parent._rule, _backend) : null;
int num = 0;
int num2 = 0;
while (num < pronunciation.Length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Subset(ParseElementCollection parent, Backend backend, string text, Match
char[] achTrimChars = Helpers._achTrimChars;
foreach (char c in achTrimChars)
{
if (c != ' ' && text.Contains(c))
if (c != ' ' && text.IndexOf(c) >= 0)
{
text = text.Replace(c, ' ');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ private IToken ParseToken(IElement parent, XmlReader reader)
{
ThrowSrgsException(SRID.InvalidEmptyElement, "token");
}
if (text3.Contains('"'))
if (text3.IndexOf('"') >= 0)
{
ThrowSrgsException(SRID.InvalidTokenString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ internal Stream LoadFile(Uri uri, out string localPath, out Uri redirectedUri)

private static Stream DownloadData(Uri uri, out Uri redirectedUri)
{
#pragma warning disable SYSLIB0014
WebRequest webRequest = WebRequest.Create(uri);
webRequest.Credentials = CredentialCache.DefaultCredentials;
using (HttpWebResponse httpWebResponse = (HttpWebResponse)webRequest.GetResponse())
Expand All @@ -70,6 +71,7 @@ private static Stream DownloadData(Uri uri, out Uri redirectedUri)
}
}
}
#pragma warning restore SYSLIB0014
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public string Text
{
Helpers.ThrowIfEmptyOrNull(value, nameof(value));
string text = value.Trim(Helpers._achTrimChars);
if (string.IsNullOrEmpty(text) || text.Contains('"'))
if (string.IsNullOrEmpty(text) || text.IndexOf('"') >= 0)
{
throw new ArgumentException(SR.Get(SRID.InvalidTokenString), nameof(value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ private struct NameValuePair

internal GrammarOptions _semanticTag;

internal AppDomain _appDomain;

internal AppDomainGrammarProxy _proxy;

internal ScriptRef[] _scripts;
Expand Down Expand Up @@ -196,11 +194,6 @@ internal GrammarState State
case GrammarState.Unloaded:
_loadException = null;
_recognizer = null;
if (_appDomain != null)
{
AppDomain.Unload(_appDomain);
_appDomain = null;
}
break;
default:
_ = 3;
Expand Down Expand Up @@ -924,8 +917,7 @@ private void CreateSandbox(MemoryStream stream)
if (CfgGrammar.LoadIL(stream, out byte[] assemblyContent, out byte[] assemblyDebugSymbols, out ScriptRef[] scripts))
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_appDomain = AppDomain.CreateDomain("sandbox");
_proxy = (AppDomainGrammarProxy)_appDomain.CreateInstanceFromAndUnwrap(executingAssembly.GetName().CodeBase, "System.Speech.Internal.SrgsCompiler.AppDomainGrammarProxy");
_proxy = new AppDomainGrammarProxy();
_proxy.Init(_ruleName, assemblyContent, assemblyDebugSymbols);
_scripts = scripts;
}
Expand Down
Loading