Unity 5.3 and .NET | AppendText & CreateText - unity3d

Even though I have already changed the API Compatibility Level from .NET 2.0 Subset to .NET 2.0 in Edit->Project Settings->Player under Optimizations, upon upgrading to Unity 5.3.0 I am still getting the following two error messages:
`System.IO.File' does not contain a definition for `AppendText'
`System.IO.File' does not contain a definition for `CreateText'
They refer to the following code snippets:
using(StreamWriter writer = File.CreateText(saveFilePath))
{
string sLine = "time;joint;pos_x;pos_y;poz_z";
writer.WriteLine(sLine);
}
using(StreamWriter writer = File.AppendText(saveFilePath))
{
string sLine = string.Format("{0:F3};{1};{2:F3};{3:F3};{4:F3}", Time.time, (int)joint, jointPos.x, jointPos.y, jointPos.z);
writer.WriteLine(sLine);
}
How do I resolve this?

Are you tried this case?
using (var f = new StreamWriter("file path", true))
{
f.WriteLine("appended text");
f.Flush();
}

Related

What is a correct way to obtain FOnlineSubsystemSteam instance in c++ code

I'm trying to get steam app id and steam user id in my Unreal Engine 4 project in the following way:
if (SteamAPI_Init())
{
IOnlineSubsystem* ossBase = IOnlineSubsystem::Get();
FOnlineSubsystemSteam* oss = Cast<FOnlineSubsystemSteam*>(ossBase);
if (!oss) {
printText(TEXT("Steam Subsystem is down!"), FColor::Red.WithAlpha(255));
return;
}
auto SteamID = FString(std::to_string(SteamUser()->GetSteamID().ConvertToUint64()).c_str());
auto AppID = FString(std::to_string(oss->GetSteamAppId()).c_str());
But it is not possible to convert IOnlineSubsystem to FOnlineSubsystemSteam. So what is a correct way to obtain the instance of FOnlineSubsystemSteam?
The solution is to use static_cast:
FOnlineSubsystemSteam* oss = static_cast<FOnlineSubsystemSteam*>(ossBase);
This one works. It seems obvious to use UE4 Cast, but in this case it does not work.

Lucene .net + equivalent of SpanMultiTermQueryWrapper<MultiTermQuery> in C#

I need to convert the following Java code to C# but I couldn't find the equivalent of "SpanMultiTermQueryWrapper". Could you please help?
FuzzyQuery firstNameQuery = new FuzzyQuery(new Term("text", firstName), 2);
FuzzyQuery lastNameQuery = new FuzzyQuery(new Term("text", lastName), 2);
SpanQuery[] clauses = new SpanQuery[] {
new SpanMultiTermQueryWrapper<MultiTermQuery>(firstNameQuery),
new SpanMultiTermQueryWrapper<MultiTermQuery>(lastNameQuery)
};
SpanNearQuery spanNearQuery = new SpanNearQuery(clauses, 3, false);
SpanMultiTermQueryWrapper and MultiTermQuery are both available on Lucene.Net 4.8.0-beta00004.
If you need support in earlier versions of Lucene.Net, you can probably just grab the source code from the above links and any dependencies and drop them into a library for your applications.

How can i use Orion as the web editor in Xtext?

I tried to search how i can change the web editor for my Xtext project. But it seems there is missing some documentation.
My question is how can I change the default web editor ace to my prefered editor orion ?
you need to do two things
adapt the workflow to use orion webSupport = { framework = "Orion"} (best done before first generation since generate once files will not be overriden)
since there is no webjar for orion you need to download/unpack it manually and or separately depending on your build system.
you may have a look at the Yeoman generator-xtext (https://github.com/itemis/generator-xtext) which allows you to create a gradle + xtext + web + orion project.
Workflow {
component = XtextGenerator {
...
language = StandardLanguage {
name = "org.xtext.example.mydsl.MyDsl"
fileExtensions = "mydsl"
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
webSupport = {
framework = "Orion"
}
}
}
}

How to generate JSDoc comments for functions when no comment exists?

I'm trying to create a plugin for JSDoc.
I'm following the documentation (which, ironically, is lacking) and I'm not sure how to do this.
My plugin is loaded properly, and I'm trying a simple example. Here's my plugin (which loads, because I can throw an error from there to stop jsdoc from running):
visitNode: function(node, e, parser, currentSourceName) {
if(node.type === 109){
if(!e.comment || e.comment ==="#undocumented"){
var startComment = '/**',
endComment = '\n*/';
var params = node.getParams(),
paramsComment = '';
for(var i=0; i<params.length; i++){
paramsComment += '\n* #param ' + params[i];
}
e.comment = startComment +
paramsComment +
endComment;
}
}
please note that node.type === 109 is equivalent to Token.FUNCTION, which should be available as per their example here, but Token is undefined in the plugin.
If you know of a better site which explains how to write a JSDoc plugin, then that would be very much appreciated too... thanks
I also had this problem and it seems strange that JSDoc does not have some kind of already made option for that or at least a plugin.
Anyway creating this plugin has solved my problem. I am using JSDoc version 3.4:
'use strict';
exports.handlers = {
symbolFound:function(e) {
if(e.astnode.type === "FunctionDeclaration" ) {
if( (e.comment==="#undocumented")){
e.comment = '/** undocumented */';
}
}
}
};

Why are definitions missing ? Lucene.Net 3.0.3 - Fast Vector Highlighter

As a newbie to Lucene.Net/Lucene and to C# I was able to put some lines of code and have a search running.
Now I want to get a snippet of the found area back. I have found below code but Visual Studio keeps telling me that a) "Searcher does contain a definition of getIndexReader" and b) "ScoreDoc does not contain a definition of doc" -and I don't get the point where the problem is!
Is there anybody out there who can help.
I am using Lucene.Net 3.0.3 and Lucene Contrib 3.0.3 on Visual Studio 2010 Express.
See the code I have below.
Thanks for your help!
RC
IndexReader indexReader = IndexReader.Open(directory, true);
Searcher indexSearch = new IndexSearcher(indexReader);
var queryParser = new QueryParser(Version.LUCENE_30, "text", analyzer);
var query = queryParser.Parse("\"system AKZ\"~10");
Console.WriteLine("Searching for: " + query);
TopDocs hits = indexSearch.Search(query,500);
/// Highlighter
FastVectorHighlighter fvHighlighter = new FastVectorHighlighter(true, true);
for (int i = 0; i < hits.ScoreDocs.Length; i++)
{
string bestfragment fvHighlighter.GetBestFragment(fvHighlighter.GetFieldQuery(query),indexSearch.getIndexReader(), hits.ScoreDocs[i].doc, "text", 20);
MessageBox.Show(bestfragment);
}
Console.WriteLine("Results Found: " + hits.TotalHits);
I would pull out something like ILSpy to examine what methods actually are available.
This is just a problem with the case of the method names. It's GetIndexReader() for example not getIndexReader(). You are probably basing this on docs for the Java implementation.
in Lucene.net this method's name is IndexReader.