<commit_before>﻿/*
 * Copyright 2018 Coati Software KG
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using CoatiSoftware.SourcetrailExtension.Logging;
using Microsoft.VisualStudio.VCProjectEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting;

namespace VCProjectEngineWrapper
{
	public class
#if (VS2012)
		VCConfigurationWrapperVs2012
#elif (VS2013)
		VCConfigurationWrapperVs2013
#elif (VS2015)
		VCConfigurationWrapperVs2015
#elif (VS2017)
		VCConfigurationWrapperVs2017
#endif
		: IVCConfigurationWrapper
	{
		private VCConfiguration _wrapped = null;

		public
#if (VS2012)
			VCConfigurationWrapperVs2012
#elif (VS2013)
			VCConfigurationWrapperVs2013
#elif (VS2015)
			VCConfigurationWrapperVs2015
#elif (VS2017)
			VCConfigurationWrapperVs2017
#endif
			(object wrapped)
		{
			_wrapped = wrapped as VCConfiguration;
		}

		public bool isValid()
		{
			return (_wrapped != null);
		}

		public string GetWrappedVersion()
		{
			return Utility.GetWrappedVersion();
		}

		public bool isMakefileConfiguration()
		{
			ConfigurationTypes configurationType = _wrapped.ConfigurationType;
			if (configurationType == ConfigurationTypes.typeGeneric)
			{
				return true;
			}

			if (configurationType == ConfigurationTypes.typeUnknown && GetNMakeTool() != null && GetNMakeTool().isValid())
			{
				return true;
			}

			return false;
		}

		public string EvaluateMacro(string macro)
		{
			return _wrapped.Evaluate(macro);
		}<commit_msg>fix empty compilation database if project uses a legacy configuration type<commit_after>﻿/*
 * Copyright 2018 Coati Software KG
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using CoatiSoftware.SourcetrailExtension.Logging;
using Microsoft.VisualStudio.VCProjectEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting;

namespace VCProjectEngineWrapper
{
	public class
#if (VS2012)
		VCConfigurationWrapperVs2012
#elif (VS2013)
		VCConfigurationWrapperVs2013
#elif (VS2015)
		VCConfigurationWrapperVs2015
#elif (VS2017)
		VCConfigurationWrapperVs2017
#endif
		: IVCConfigurationWrapper
	{
		private VCConfiguration _wrapped = null;

		public
#if (VS2012)
			VCConfigurationWrapperVs2012
#elif (VS2013)
			VCConfigurationWrapperVs2013
#elif (VS2015)
			VCConfigurationWrapperVs2015
#elif (VS2017)
			VCConfigurationWrapperVs2017
#endif
			(object wrapped)
		{
			_wrapped = wrapped as VCConfiguration;
		}

		public bool isValid()
		{
			return (_wrapped != null);
		}

		public string GetWrappedVersion()
		{
			return Utility.GetWrappedVersion();
		}

		public bool isMakefileConfiguration()
		{
			try
			{
				ConfigurationTypes configurationType = _wrapped.ConfigurationType;
				if (configurationType == ConfigurationTypes.typeGeneric)
				{
					return true;
				}

				if (configurationType == ConfigurationTypes.typeUnknown && GetNMakeTool() != null && GetNMakeTool().isValid())
				{
					return true;
				}
			}
			catch
			{
				Logging.LogWarning("Unable to determine if a makefile configuration is used, falling back to default behavior.");
			}

			return false;
		}

		public string EvaluateMacro(string macro)
		{
			return _wrapped.Evaluate(macro);
		}
{'fraction_non_alphanumeric': 0.07757404795486601, 'fraction_numerical': 0.03385049365303244, 'mean_word_length': 4.279156327543424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4619410', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1168, 'n_words': 378}